How jayy-lmao/loosely-coupled-monolith-rust works
Top Level (Entry Point)
• It accepting HTTP requests (POST /sales)
Service Layer (Middle)
• Sales Service (sales crate)
• Shipping Service (shipping crate)
• Billing Service (implied by billing_contracts)
• Each service should have its own database context (shown as smaller attached databases)
Event Communication Layer
• PlacedOrder events (sales_contracts)
• OrderBilled events (billing_contracts)
• CreateShippingLabel events (shipping_contracts)
• Bidirectional communication between services and the event registry
Specific Elements to Include:
Components
• [API Gateway] → [Event Registry]
• ↓
• [Sales Service] ⇢ [Event: OrderPlaced] ⇢ [Shipping Service]
• ↓ ↓
• [Sales DB Context] [Shipping DB Context]
Event Flow
• How OrderPlaced events trigger shipping label creation
• Loose coupling through the event registry pattern
Important Details
• A note about the registry pattern implementation
• Contract boundaries between services
• Test boundaries (sales_test crate)
• Blue: API Gateway
• Green: Sales Service
• Orange: Shipping Service
• Purple: Billing Service
• Red: Event Registry
• Gray: Databases
• Yellow: Events/Contracts
Symbols:
→ Direct API Call
⇢ Event Publication
⇠ Event Subscription
□ Service
○ Database
◇ Event
Level of Detail:
• Main service boundaries
• Event contracts but not individual message structures
• Database contexts without internal schema details
• Main endpoints but not individual functions
Additional Notes: