Skip to main content

Capstone: E-Commerce Platform

Congratulations! You’ve learned the individual pieces. Now, let’s build the puzzle.

The Architecture

We will build a simplified Amazon clone.

Microservices

  1. Product Service: Catalog management (PostgreSQL).
  2. Order Service: Order placement (PostgreSQL).
  3. Inventory Service: Stock checks (MySQL).
  4. Notification Service: Sends emails (Simulated).

Infrastructure

  • Discovery: Netflix Eureka.
  • Gateway: Spring Cloud Gateway.
  • Messaging: Kafka / RabbitMQ.
  • Tracing: Zipkin.

The Flow

  1. User places an order (POST /api/orders).
  2. Order Service receives request.
  3. Synchronous call (WebClient) to Inventory Service to check stock.
    • If out of stock -> Return 400.
  4. Order Service saves order to DB (Status: PLACED).
  5. Order Service publishes OrderPlacedEvent to Kafka.
  6. Notification Service listens to OrderPlacedEvent and sends email.
  7. Inventory Service listens to OrderPlacedEvent and reduces stock.

Requirements

  1. Service Discovery: All services must register with Eureka.
  2. Gateway: All external calls must go through port 8080 (Gateway).
  3. Circuit Breaker: If Inventory is down, Order Service should return a fallback (“System busy, try later”) instead of hanging.
  4. Distributed Tracing: I should be able to see the trace from Gateway -> Order -> Inventory.

Setup Instructions

  1. Create a parent maven project (pom type).
  2. Create modules for each service.
  3. Use docker-compose to spin up the databases and brokers.
  4. Implement one service at a time.
  5. Test using Postman.

Bonus Challenges

  • Security: Add Keycloak (OAuth2) to the Gateway.
  • Config: Move all application.yml to a Config Server.
  • Resilience: Add Rate Limiting to the Order API.