rust-backend
The Intuition Rust Monorepoβ
The intuition-rs repository is organized as a Rust workspace, which provides several key benefits:
Monorepo Architectureβ
A monorepo (monolithic repository) consolidates all backend services and shared code in a single repository, offering:
- Code sharing: Common utilities and models shared across all services
- Unified versioning: All services stay in sync with compatible versions
- Atomic changes: Update multiple services in a single commit
- Simplified dependencies: Internal dependencies managed through workspace
- Consistent tooling: Shared build, test, and lint configurations
Workspace Organizationβ
The workspace is structured into logical layers:
Applications Layer (apps/)β
Independent services that can be deployed separately:
- Each app has its own binary
- Shared dependencies managed at workspace level
- Services communicate through well-defined interfaces
Infrastructure Layerβ
Supporting services for data storage and APIs:
- Database migrations and schema management
- GraphQL API configuration
- Monitoring and observability tools
Shared Librariesβ
Common code used across multiple services:
- Domain models
- Utility functions
- Shared business logic
Development Benefitsβ
- Faster builds: Cargo caches dependencies and only rebuilds what changed
- Type safety across services: Shared types ensure compatibility
- Easier refactoring: Changes to shared code immediately show impact
- Consistent testing: Run all tests with a single command
Project Structureβ
intuition-rs/
βββ apps/ # Custom Rust applications
β βββ cli/ # Terminal UI client
β βββ consumer/ # Event processing pipeline (Redis Streams)
β βββ histocrawler/ # Historical data crawler
β βββ image-guard/ # Image processing service
β βββ models/ # Domain models & data structures
β βββ rpc-proxy/ # RPC proxy with caching
β βββ shared-utils/ # Common utilities
βββ infrastructure/ # Infrastructure components
β βββ hasura/ # GraphQL API & migrations
β βββ blockscout/ # Blockchain explorer
β βββ drizzle/ # Database schema management
β βββ geth/ # Local Ethereum node config
β βββ indexer-and-cache-migrations/ # Database migrations
β βββ migration-scripts/ # Migration utilities
β βββ prometheus/ # Monitoring configuration
βββ docker/ # Docker configuration
β βββ docker-compose-apps.yml # Application services
β βββ docker-compose-shared.yml # Shared infrastructure
β βββ Dockerfile # Multi-stage build
βββ scripts/ # Shell scripts
β βββ start.sh # System startup
β βββ stop.sh # System shutdown
β βββ cli.sh # CLI runner
β βββ init-dbs.sh # Database initialization
βββ integration-tests/ # End-to-end tests
βββ README.md # Project documentation
Core Applicationsβ
CLI
Terminal UI client for interacting with the Intuition system
- Interactive command-line interface
- Real-time data verification
- Development and debugging tool
Consumer
Event processing pipeline using Redis Streams
- RAW Consumer: Ingests raw blockchain events
- DECODED Consumer: Decodes and parses events
- RESOLVER Consumer: Resolves and enriches data
- IPFS-UPLOAD Consumer: Manages IPFS content uploads
Histocrawler
Historical data crawler for blockchain indexing
- Fetches historical blockchain data
- Processes past events
- Builds complete data history
Image Guard
Image processing and validation service
- Image validation and security scanning
- Format conversion and optimization
- Content moderation
RPC Proxy
RPC call proxy with intelligent caching
- Caches eth_call method results
- Reduces load on upstream RPC providers
- Improves query performance
Models
Domain models and data structures
- Shared data types
- Business logic models
- Database entity definitions
Shared Utils
Common utilities used across services
- Helper functions
- Shared configurations
- Reusable components
Infrastructure Componentsβ
The infrastructure layer provides essential services:
- Hasura: GraphQL API engine with database migrations
- Blockscout: Blockchain explorer for network transparency
- Drizzle: Type-safe database schema management
- Geth: Local Ethereum node for development
- Prometheus: Metrics collection and monitoring
Development Toolsβ
The repository includes comprehensive tooling:
- Docker Compose: Orchestrates all services for local development
- Cargo Make: Task automation and build scripts
- Integration Tests: End-to-end testing with pnpm
- Shell Scripts: Quick commands for common operations
Why Rust?β
The Intuition backend is built with Rust, a systems programming language that offers unique advantages for blockchain infrastructure:
Performance and Efficiency
Zero-cost abstractions: Write high-level code without runtime overhead
Memory efficiency: Minimal memory footprint compared to garbage-collected languages
Concurrent processing: Built-in support for safe concurrent operations
Native performance: Compiles to machine code for maximum speed
Safety and Reliability
Memory safety: Eliminates entire classes of bugs (null pointer dereferences, buffer overflows, data races)
Type safety: Strong static typing catches errors at compile time
Error handling: Explicit error handling through Result types
No runtime crashes: Memory safety guarantees prevent unexpected crashes
Developer Experience
Modern tooling: Cargo package manager and build system
Rich ecosystem: Growing library ecosystem for blockchain and web services
Documentation: Built-in documentation tools and testing framework
Community: Active and supportive open-source community
Blockchain-Specific Benefits
Predictable performance: No garbage collection pauses during critical operations
Resource optimization: Efficient resource usage for indexing large amounts of blockchain data
WebAssembly support: Can compile to WASM for cross-platform compatibility
Security: Memory safety is crucial when handling financial transactions and user data