Microservices Architecture Implementation
This project implements all 22 microservice patterns described in MICROSERVICE-PATTERNS.MD using Rust and modern cloud-native technologies.
Project Structure
MICROSERVICES-ARCH/
├── gateway/ # API Gateway service
├── bff/ # Backend-for-Frontend services
│ └── web-bff/ # Web-specific BFF
├── services/ # Core domain services
│ ├── user-service/ # User management service
│ └── order-service/ # Order processing service
├── shared/ # Shared libraries and models
├── messaging/ # Messaging infrastructure
├── observability/ # Tracing and metrics
├── security/ # Security utilities
├── config/ # Configuration management
└── docs/ # Documentation
└── architecture/ # Architecture documentation
Implemented Patterns
- Service-per-Bounded-Context - Separate services for User and Order domains
- API Style & Versioning - RESTful APIs with versioning
- Service Discovery & Naming - Configuration-based service discovery
- API Gateway (Edge) - Centralized API gateway
- Backends-for-Frontends (BFF) - Web BFF for frontend integration
- Async Messaging Basics - NATS-based messaging system
- Idempotent Endpoints & Dedup - Idempotency patterns
- Data Ownership (Private Schema) - Database per service
- Outbox Pattern (Transactional Events) - Consistent event publishing
- Change Data Capture (CDC) for Integration - Event-driven integration
- Event Schema Governance - Versioned event schemas
- Consumer-Driven Contracts (CDCt) Testing - Contract testing
- Anti-Corruption Layer (ACL) - Data transformation layers
- Read Models & CQRS-Lite - Read/write model separation
- Caching Tiers (Service & Shared) - Multi-level caching
- Rate Limits, Quotas, and Shaping - Rate limiting middleware
- Security: mTLS + AuthN/Z Between Services - JWT-based security
- Secrets & Config Management (Per Service) - Environment-based config
- Health, Readiness, and Graceful Shutdown - Health check endpoints
- Observability: Tracing, Metrics, Correlation - OpenTelemetry integration
- CI/CD Per Service (Pipelines & Templates) - Workspace-based builds
- Deployment Topology (Single Region, Many Services) - Kubernetes-ready
Technologies Used
- Rust - Core language
- Axum - Web framework
- SQLx - Database toolkit
- NATS - Messaging system
- OpenTelemetry - Observability
- Tower/Tokio - Async runtime and middleware
- Serde - Serialization
- Moka - Caching
Getting Started
- Install Rust toolchain
- Navigate to the project root
- Run services individually or use workspace commands:
# Build all services
cargo build
# Run a specific service
cargo run -p user-service
# Run the gateway
cargo run -p gateway
Services
- Gateway - Runs on port 3000
- User Service - Runs on port 3001
- Order Service - Runs on port 3002
- Web BFF - Runs on port 3003
Documentation
See docs/architecture/l2-patterns.md for detailed implementation of each pattern.