Project Structure
This document describes the project structure and organization of the OpenZeppelin Monitor codebase, including the source code layout, configuration files, and development resources.
Project Layout
The project follows a standard Rust project layout with additional directories for configuration, documentation, and operational resources:
openzeppelin-monitor/
├── src/ # Source code
│ ├── bootstrap/ # Bootstrap functions for the application
│ ├── models/ # Data structures and types
│ ├── repositories/ # Configuration storage
│ ├── services/ # Core business logic
│ ├── utils/ # Helper functions
│
├── config/ # Configuration files
├── tests/ # Integration and property-based tests
├── data/ # Runtime data storage
├── docs/ # Documentation
├── scripts/ # Utility scripts
├── cmd/ # Metrics and monitoring
├── examples/ # Example configuration files
└── ... other root files (Cargo.toml, README.md, etc.)
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
- Manages the startup sequence and service lifecycle
models/
Core data structures and types:
blockchain/
: Platform-specific implementationsevm/
: Ethereum Virtual Machine specific typesstellar/
: Stellar blockchain specific types
config/
: Configuration loading and validationcore/
: Core domain modelssecurity/
: Security and secret management
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 interfacestransports/
: Transport clientsevm/
: Ethereum Virtual Machine transport clientstellar/
: Stellar transport client
clients/
: Client implementationsevm/
: Ethereum Virtual Machine clientstellar/
: Stellar client
blockwatcher/
: Block monitoring and processingfilter/
: Transaction and event filteringfilters/
: Filter implementationsevm/
: Ethereum Virtual Machine filterstellar/
: Stellar filter
notification/
: Alert handlingtrigger/
: Trigger evaluation and executionscript/
: Script execution utilities
utils/
Helper functions:
cron_utils
: Cron schedule utilitiesexpression
: Expression evaluationlogging/
: Logging utilitiesmacros/
: Macros for common functionalitymetrics/
: Metrics utilitiesmonitor/
: Monitor configuration test utilitiestests/
: Contains test utilities and helper functionsbuilders/
: Test builder patterns implementing fluent interfaces for creating test fixturesevm/
: Builder implementations specific to Ethereum Virtual Machine (EVM) testingstellar/
: Builder implementations specific to Stellar blockchain testing
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
The examples/config/
directory contains example JSON configuration files for each (network, monitor, trigger and filters).
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 are mounted to persist the configs and runtime data.
Examples and Resources
examples/
Directory
Provides practical examples and sample configurations to help users get started:
- Demonstrates typical service configurations for various networks
- Acts as a quick-start guide for customizing the monitor
- Serves as a reference for best practices in configuration
Metrics and Monitoring
cmd/prometheus/
Directory
Prometheus exporters and monitoring infrastructure:
dashboards/
: Grafana dashboardsdatasources/
: Prometheus datasourcesprometheus.yml
: Prometheus configurationgrafana.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 metadatarustfmt.toml
: Code formatting rulesrust-toolchain.toml
: Rust version and components
Docker Support
The project includes Docker configurations for different environments:
Dockerfile.development
: Development container setupDockerfile.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 user documentation.