E-commerce Microservices Backend
Build the backend of an online shop as separate Spring Boot microservices: a catalog service (products and prices), an inventory service (stock levels) and an order service. The services find each other through Eureka service discovery instead of hard-coded addresses, and all outside requests go through one entry point, a Spring Cloud Gateway. When a customer places an order, the order service asks inventory to reserve the stock, and if inventory is down, a circuit breaker stops the failure from spreading. Everything runs together with Docker Compose. You'll learn how to split a system into services, REST calls between services, service discovery, API gateways, resilience patterns, and running a multi-service system locally.
- Estimate
- ~14.5h
- Steps
- 7
- Completed by
- 0
- Proposed by
- codeseed.app
Spring Boot · Spring Cloud Gateway · Eureka · Docker
Project roadmap
- 01
Define the service boundaries
~2hWrite ARCHITECTURE.md: each service's responsibility, its own database (services never share tables), its REST endpoints, and the flow for placing an order, including what happens when reserving stock fails. Create a multi-module Maven or Gradle project with catalog-service, inventory-service, order-service, discovery-server and api-gateway. Done when: the document is complete, and every module builds.
- 02
Build the three services
~3hCatalog: CRUD for products (sku, name, price). Inventory: GET stock by sku and POST /reservations to reserve quantities for an order, refusing when there isn't enough stock, done in one transaction. Order: POST /orders with items, stored with a status. Give each service its own PostgreSQL database (or H2 during development) and validate the input. Done when: each service works on its own when called directly.
- 03
Add service discovery
~1.5hCreate the discovery-server with @EnableEurekaServer. Register the three services as Eureka clients using their spring.application.name. Done when: the Eureka dashboard lists all three services, and starting a second copy of a service shows two instances.
- 04
Call between services
~2.5hIn the order service, call the catalog to get current prices and the inventory to reserve stock, using a load-balanced WebClient or RestClient with service names (http://inventory-service) instead of addresses. Save the order as CONFIRMED when the reservation succeeds and REJECTED with the reason when there isn't enough stock. Set timeouts on every call. Done when: placing an order reduces the stock, and ordering too much is rejected.
- 05
Add the API gateway
~1.5hConfigure Spring Cloud Gateway routes /api/products/** to catalog, /api/inventory/** to inventory and /api/orders/** to orders, using lb:// service names. Add a filter that attaches a request id header, logged by every service so one request can be followed across services. Done when: every endpoint works through the gateway's port, and logs show the same request id in each service.
- 06
Add a circuit breaker
~2hWrap the order service's calls to inventory with a Resilience4j circuit breaker (through Spring Cloud CircuitBreaker) with a timeout and limited retries. When inventory is down or slow, fail quickly and return 503 with a clear message instead of making customers wait. Expose the breaker's state through Actuator. Done when: stopping inventory makes orders fail fast, and they work again automatically after it restarts.
- 07
Run everything with Docker
~2hWrite a Dockerfile for each service and a docker-compose.yml running all of them plus their databases, with health checks and start-up order. Write an end-to-end test script: create a product, add stock, place an order through the gateway and check the stock decreased. Done when: docker compose up starts the whole system, and the script passes.
Ready to build this?
Get a GitHub repo and start building. Your AI reviewer checks each step as you go.
Tech stack