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

Connections

Walkthrough

  1. The shopper's browser posts the cart to the Checkout API (the client itself is not in this repo).
  2. Each line is priced from Redis; a miss reads Postgres and caches the price for five minutes.
  3. Stripe is charged and confirmed in the same call; anything but 'succeeded' returns 402.
  4. The order is inserted, then its id is published to the fulfilment queue, and the API answers the shopper.
  5. Later, the worker takes the id, reads the address, books the courier and marks the order booked.

Notes

connectionasync / optionalassumption (not shown by the evidence)
docker-compose stackDataPOST /checkoutPOST /checkoutget price:<sku>get price:<sku>price on cache miss, insert orderprice on cache miss,insert ordercreate + confirm paymentcreate + confirm paymentpublish order_idpublish order_idconsumeconsumebook courierbook courierread address, mark bookedread address, markbookedShopper's browserShopper's browserassumedCheckout API — FastAPI · POST /checkoutCheckout APIFastAPI · POST /checkout✓ srcPrice cache — Redis, 5 min TTLPrice cacheRedis, 5 min TTL✓ srcOrders database — Postgres 16Orders databasePostgres 16✓ srcfulfilment queue — RabbitMQfulfilment queueRabbitMQ✓ srcFulfilment workerFulfilment worker✓ srcStripe — PaymentIntentStripePaymentIntent✓ srcCourier API — courier.exampleCourier APIcourier.example✓ src