In this workshop, we analyze decomposition strategies for migrating from a monolith to microservices within a real-world context:
Food Delivery Project or Order Management System consisting of 5 services: Gateway, Kitchen, Order, Payment, Stock.

Core Principle: Decompose services by business capability rather than technical layers.
Identified business capabilities:
Reasons for choosing business capability split:
Database-per-Service Pattern:
Each service owns its own MongoDB instance:
Advantages of Database-per-Service:
Principle: Each service owns and manages its own data; no shared database tables.
Data Ownership Matrix:
| Service | Data Owned | Data Accessed (Read-only) |
|---|---|---|
| Order | orders, order_items, order_statuses | inventory (from Stock), payment_status (from Payment) |
| Kitchen | kitchen_jobs, staff_schedules | orders (from Order), inventory (from Stock) |
| Payment | transactions, payment_methods | orders (from Order) |
| Stock | inventory, suppliers, stock_movements | orders (from Order) |
| Gateway | auth_tokens, rate_limits | All services (for routing) |
Data Access Strategy:
Eventual Consistency with Event Sourcing:
1. Order Creation Flow:
Order Service → OrderCreated Event → RabbitMQ
↓
Stock Service ← Consume Event → Update Inventory
Payment Service ← Consume Event → Create Payment Record
Kitchen Service ← Consume Event → Create Kitchen Job
2. Payment Processing Flow:
Payment Service → PaymentCompleted Event → RabbitMQ
↓
Order Service ← Consume Event → Update Order Status
Kitchen Service ← Consume Event → Start Cooking Process
3. Inventory Update Flow:
Stock Service → StockUpdated Event → RabbitMQ
↓
Order Service ← Consume Event → Check Availability
Kitchen Service ← Consume Event → Update Cooking Plan
Compensation Pattern for Failure Scenarios:
Service Dependency Graph:
Gateway (Entry Point)
├── Order Service (Core Business)
│ ├── Stock Service (Inventory Check)
│ ├── Payment Service (Payment Processing)
│ └── Kitchen Service (Order Fulfillment)
├── Kitchen Service
│ ├── Stock Service (Ingredient Check)
│ └── Order Service (Order Details)
├── Payment Service
│ └── Order Service (Order Validation)
└── Stock Service
└── Order Service (Demand Forecasting)
Dependency-based Decomposition Strategy:
Level 1 - Independent Services (Decompose first):
Level 2 - Core Business Services:
Level 3 - Gateway Service:
Phase 1: Foundation Services
Phase 2: Business Services
Phase 3: Core Service
Phase 4: Gateway Service
Decomposition strategies for migrating the Food Delivery project from monolith to microservices:
Expected outcomes: