What a checkout request touches What happens between a shopper pressing Pay and a courier being booked?
The API prices the cart from Redis (falling back to Postgres), charges Stripe, records the order and puts it on a RabbitMQ queue; a separate worker books the courier and marks the order booked. The shopper's response returns before the courier is booked.
22 of 22 file citations checked against the repository · 2 items drawn dashed as assumptions
The diagram as text Parts Shopper's browser assumption Checkout API — FastAPI · POST /checkout in docker-compose stack (api/checkout.py:29-41 ✓, docker-compose.yml:2-8 ✓) Price cache — Redis, 5 min TTL in Data (api/checkout.py:20-24 ✓, docker-compose.yml:17-18 ✓) Orders database — Postgres 16 in Data (api/checkout.py:22 ✓, api/checkout.py:36 ✓, docker-compose.yml:15-16 ✓) fulfilment queue — RabbitMQ in docker-compose stack (api/checkout.py:39-40 ✓, docker-compose.yml:19-20 ✓) Fulfilment worker in docker-compose stack (worker/fulfil.py:13-19 ✓, docker-compose.yml:9-14 ✓) Stripe — PaymentIntent (api/checkout.py:32-35 ✓) Courier API — courier.example (worker/fulfil.py:16 ✓) Connections Shopper's browser → Checkout API: POST /checkout assumption Checkout API → Price cache: get price:<sku> (api/checkout.py:20 ✓) Checkout API → Orders database: price on cache miss, insert order (api/checkout.py:22 ✓, api/checkout.py:36-38 ✓) Checkout API → Stripe: create + confirm payment (api/checkout.py:32-35 ✓) Checkout API → fulfilment queue: publish order_id (api/checkout.py:39-40 ✓) fulfilment queue → Fulfilment worker: consume (worker/fulfil.py:22 ✓) Fulfilment worker → Courier API: book courier (worker/fulfil.py:16 ✓) Fulfilment worker → Orders database: read address, mark booked (worker/fulfil.py:15 ✓, worker/fulfil.py:17 ✓) Walkthrough The shopper's browser posts the cart to the Checkout API (the client itself is not in this repo). Each line is priced from Redis; a miss reads Postgres and caches the price for five minutes. Stripe is charged and confirmed in the same call; anything but 'succeeded' returns 402. The order is inserted, then its id is published to the fulfilment queue, and the API answers the shopper. Later, the worker takes the id, reads the address, books the courier and marks the order booked. Notes The worker reads orders.address, but the API's insert does not write an address. Where it comes from is not in this repo. Left out: the products table's other readers, and anything after the courier booking.
+ − Fit
Walk through ← →
SVG PNG Mermaid
◐
Click a part for detail and evidence · shift-click a second part for the path · drag to pan · scroll to zoom
connection async / optional assumption (not shown by the evidence)
docker-compose stack Data POST /checkout POST /checkout get price:<sku> get price:<sku> price on cache miss, insert order price on cache miss, insert order create + confirm payment create + confirm payment publish order_id publish order_id consume consume book courier book courier read address, mark booked read address, mark booked Shopper's browser Shopper's browser assumed Checkout API — FastAPI · POST /checkout Checkout API FastAPI · POST /checkout ✓ src Price cache — Redis, 5 min TTL Price cache Redis, 5 min TTL ✓ src Orders database — Postgres 16 Orders database Postgres 16 ✓ src fulfilment queue — RabbitMQ fulfilment queue RabbitMQ ✓ src Fulfilment worker Fulfilment worker ✓ src Stripe — PaymentIntent Stripe PaymentIntent ✓ src Courier API — courier.example Courier API courier.example ✓ src