Capstone: microservices mall

The capstone project. Build a small e-commerce backend as four independent services: Products, Cart, Orders, and Payments. They talk to each other through a mix of synchronous HTTP and asynchronous Redis events. An API gateway sits in front and routes external traffic. One docker compose file runs the whole thing.

The mall

API gateway at the top, four services underneath, shared Redis for events, each service with its own Postgres.

Every service owns its own database. Products does not read the cart database. Orders does not read the payments database. They communicate through events on the Redis bus. When an order is placed, Orders publishes OrderPlaced. Payments subscribes and charges. Inventory subscribes and decrements stock. Neither of them has to call Orders directly.

The interesting part is failure injection. Kill the Payments service mid-capstone and watch what happens. An order can still be placed because Orders only publishes an event. Payments catches up when it comes back online. If you had made the services call each other synchronously over HTTP, the whole chain would have broken. This is the real reason to pay the distributed systems tax.

AI prompt: Try it: design the event contract

Loading practice…

Quiz: Quiz

Loading practice…

Checkpoint: Distributed systems checkpoint

Loading practice…