Project Structure

This document provides detailed information about each directory in the OpenZeppelin Monitor project.

Source Code Organization:

src/ Directory:

The main source code directory contains the core implementation files organized into several modules:

  • bootstrap/: Application initialization and setup for main.rs

    • Handles service initialization and dependency injection

  • models/: Core data structures and types

    • blockchain/: Platform-specific implementations

      • evm/: Ethereum Virtual Machine specific types

      • stellar/: Stellar blockchain specific types

    • config/: Configuration loading and validation

    • core/: Core domain models

  • repositories/: Configuration storage

    • Handles loading and validating configuration files

    • Provides storage interfaces for monitors, networks, and triggers

    • Implements validation of configuration references

  • services/: Core business logic

    • blockchain/: Blockchain client interfaces

      • transports/: Transport clients

        • evm/: Ethereum Virtual Machine transport client

        • stellar/: Stellar transport client

      • clients/: Client implementations

        • evm/: Ethereum Virtual Machine client

        • stellar/: Stellar client

    • blockwatcher/: Block monitoring and processing

    • filter/: Transaction and event filtering

      • filters/: Filter implementations

        • evm/: Ethereum Virtual Machine filter

        • stellar/: Stellar filter

    • notification/: Alert handling

    • trigger/: Trigger evaluation and execution

  • utils/: Helper functions

    • cron_utils: Cron schedule utilities

    • expression: Expression evaluation

    • logging/: Logging utilities

    • metrics/: Metrics utilities

    • script/: Script execution utilities

Configuration and Data:

config/ Directory:

Contains JSON configuration files for:

  • Network configurations (networks/)

    • Connection details for blockchain networks

    • RPC endpoints and network parameters

  • Monitor configurations (monitors/)

    • Monitoring rules and conditions

    • Network and trigger references

  • Trigger configurations (triggers/)

    • Notification settings

    • Script definitions

  • Filter configurations (filters/)

    • Match filter scripts

data/ Directory:

Runtime data storage:

  • Block processing state

  • Operational data

  • Temporary files

The data/, logs/ and config/ directories are gitignored except for example files. These directories mounted to persist the configs and runtime data.

Metrics and Monitoring:

cmd/prometheus/ Directory:

Prometheus exporters:

  • dashboards/: Grafana dashboards

  • datasources/: Prometheus datasources

  • prometheus.yml: Prometheus configuration

  • grafana.ini: Grafana configuration

Testing and Documentation:

tests/ Directory:

Contains comprehensive test suites:

  • Integration tests

  • Property-based tests

  • Mock implementations

  • Test utilities and helpers

docs/ Directory:

Project documentation:

  • User guides

  • API documentation

  • Configuration examples

  • Architecture diagrams

scripts/ Directory:

Utility scripts for:

  • Development workflows

  • Documentation generation

  • Build processes

  • Deployment helpers

Development Tools:

Pre-commit Hooks:

Located in the project root:

  • Code formatting checks

  • Linting rules

  • Commit message validation

Build Configuration:

Core build files:

  • Cargo.toml: Project dependencies and metadata

  • rustfmt.toml: Code formatting rules

  • rust-toolchain.toml: Rust version and components

Docker Support:

The project includes Docker configurations for different environments:

  • Dockerfile.development: Development container setup.

  • Dockerfile.production: Production-ready container.

  • Before running the docker compose set your env variables in .env according to your needs.

For detailed information about running the monitor in containers, see the Docker deployment section in the main documentation.