Event-Driven Microservices
Order processing system using event-driven architecture with Kafka, CQRS pattern, and Go microservices.
Event-driven communication via Apache Kafka
CQRS (Command Query Responsibility Segregation)
Saga pattern for distributed transactions
Multiple microservices: Order, Payment, Inventory, Notification
Event sourcing with replay capability
Health checks and graceful shutdown
Component
Technology
Services
Go
Messaging
Apache Kafka
Databases
PostgreSQL (per service)
Containerization
Docker, Docker Compose
API Gateway
NGINX
┌───────────┐ ┌───────────────────────────────────┐
│ Client │──▶│ API Gateway │
└───────────┘ └──────┬────────────┬────────────────┘
│ │
┌────────▼──┐ ┌─────▼────────┐
│ Order │ │ Query │
│ Service │ │ Service │
└─────┬─────┘ └──────────────┘
│ publish
┌─────▼─────┐
│ Kafka │
└──┬──┬──┬──┘
consume │ │ │
┌───────────┘ │ └───────────┐
│ │ │
┌────▼─────┐ ┌─────▼────┐ ┌──────▼────────┐
│ Payment │ │Inventory │ │ Notification │
│ Service │ │ Service │ │ Service │
└──────────┘ └──────────┘ └───────────────┘
Service
Port
Responsibility
Order
8081
Create/manage orders
Payment
8082
Process payments
Inventory
8083
Stock management
Notification
8084
Email/SMS alerts
Query
8085
Read-optimized queries (CQRS)
Topic
Producer
Consumers
order.created
Order
Payment, Inventory
payment.processed
Payment
Order, Notification
inventory.reserved
Inventory
Order
order.completed
Order
Notification, Query
docker-compose up
# Order API at http://localhost:8081
MIT