A production-style event-driven microservices system built with Kafka, Outbox Pattern, and resilient retry mechanisms-designed for scalability, consistency, and fault tolerance.
- ⚡ Fully event-driven architecture
- 🔁 Reliable delivery using Outbox Pattern
- 🧠 Idempotent consumers (no duplicate side effects)
- 📉 Exponential retry with jitter
- 🔒 JWT-based authentication
- ⚡ Event-driven JWT token invalidation using Redis
- 🧩 Clean service boundaries (no shared DB)
- 🐳 Dockerized setup
flowchart LR
C[Client] --> O[Order Service]
O -->|write| DB[(Order DB)]
O -->|write event| OB[(Outbox)]
OB -->|publish| K[(Kafka)]
K -->|consume| I[Product Service]
K -->|consume| P[Payment Service]
I -->|STOCK_*| K
P -->|PAYMENT_*| K
K -->|update state| O
Order Service uses the Outbox Pattern to reliably publish events to Kafka.
Product and Payment services consume events and emit results back to Kafka, which drives the order lifecycle.
Note: Product Service also manages inventory (stock reservation).
sequenceDiagram
participant C as Client
participant O as Order
participant K as Kafka
participant I as Product
participant P as Payment
C->>O: Create Order
O-->>K: RESERVE_STOCK
K->>I: Check stock
I-->>K: ✅ STOCK_RESERVED
K->>O: Stock reserved
O-->>K: INITIATE_PAYMENT
K->>P: Process Payment
P-->>K: ✅ PAYMENT_SUCCESS
K->>O: Payment success
O->>O: Mark COMPLETED
👉 See details: Failure handling
- RESERVE_STOCK
- STOCK_RESERVED / RESERVATION_FAILED
- INITIATE_PAYMENT
- PAYMENT_SUCCESS / FAILED
- RELEASE_STOCK
👉 See details: Event Design
Order Service uses the Outbox pattern to ensure reliable event publishing.
👉 See details: Outbox Design
Events are retried with exponential backoff and jitter.
👉 See details: Retry Strategy
e-commerce-microservices/
├── api-gateway/
├── auth-service/
├── user-service/
├── product-service/
├── order-service/
├── payment-service/
├── eureka-server/
├── security/
├── dependency-platform/
└── docs/
| Service | Responsibility |
|---|---|
| auth-service | Authentication & token management |
| user-service | User management |
| product-service | Product & Inventory management |
| order-service | Order lifecycle |
| payment-service | Payment processing |
Each module contains a dedicated README with responsibilities and design details.
- All client requests go through API Gateway
- Internal services are not exposed externally
- Schema managed via Flyway migrations
- Backend: Java + Spring Boot
- Messaging: Kafka
- Cache: Redis
- Database: PostgreSQL
- Build: Gradle (KTS)
- Infra: Docker
./gradlew build
docker compose -f docker-compose.yml up -d
Run a service in local for debugging:
docker compose up - For DB, Kafka (runs with override exposing ports)
stop required services.
cd order-service
./gradlew bootRun
See system behavior and failure handling:
Note: System behavior is validated through end-to-end flows and failure simulations instead of formal unit tests.