Projects › Advanced
Microservices E-commerce Backend
Split an online store into product, order, inventory, payment and notification services that talk over REST and Kafka.
Level: Advanced · Time: 3–4 weeks · Tech stack: Spring Boot, Spring Cloud Gateway, Kafka, Docker, PostgreSQL
Features to build
- API gateway with JWT auth
- Product, order, inventory, payment and notification services
- Order saga with Kafka events and compensation
- Circuit breakers and retries
- Docker Compose for the whole system
What you will learn
- Microservice boundaries
- Event-driven design and sagas
- Kafka
- Resilience patterns
- Containerisation
Step-by-step guide
1. Draw the boundaries
Each service owns its own database. Order doesn't read the inventory table — it asks Inventory.
2. Gateway
Spring Cloud Gateway routes /api/products/** → product-service, etc., and validates the JWT once.
3. The order saga (choreography)
- Order service saves the order as PENDING and publishes
OrderCreated. - Inventory reserves stock →
StockReserved(orStockFailed). - Payment charges →
PaymentDone(orPaymentFailed→ Inventory releases stock). - Order becomes CONFIRMED or CANCELLED; Notification emails the user.
@KafkaListener(topics = "order-created")
public void reserve(OrderCreated e) { /* idempotent: ignore if this orderId was already handled */ }
4. Reliable events
Use the transactional outbox: write the event to an outbox table in the same DB transaction, and publish it from there.
5. Resilience
Resilience4j circuit breaker + timeout on every REST call between services.
6. Run it all
One docker-compose.yml with Kafka, PostgreSQL per service and all apps. Add distributed tracing (Zipkin) to follow one order across services.
Level it up
- Deploy to Kubernetes with Helm
- Centralised config server
- Contract tests between services
On your resume
- Designed a microservices e-commerce backend (Spring Boot, Spring Cloud Gateway, Kafka) with an event-driven order saga, transactional outbox, Resilience4j and Docker Compose.