sydepsystem design atlas

E-commerce Checkout

Cart, inventory reservation, payment and order fulfilment as a saga.

AdvancedCommerce
StorefrontClientAPI GatewayNetworkingCheckout SagaComputeInventory ServiceComputeInventory DBStoragePayment ServiceComputeOrder ServiceComputeOrders DBStorage

Checkout reserves inventory, charges payment, and creates the order as a coordinated multi-step transaction with compensation on failure -- reserving stock before charging so a failed payment never leaves inventory wrongly decremented.

When to use it

  • Purchases touch multiple independent services (inventory, payment, fulfilment) that must stay consistent
  • Inventory must be reserved before payment to avoid overselling limited stock

Trade-offs

  • Needs explicit compensation logic (release reservation, refund) for every failure path
  • Reservation holds add a time-limited lock on inventory that must be released if checkout abandons

Components used

Web AppAPI GatewayWorkflow OrchestratorManaged App ServiceRelational Database

How it works

  • Checkout is a distributed transaction across cart, inventory, payment and fulfilment, none of which share a database.
  • Inventory is reserved before payment is attempted, so a successful charge is never followed by an out-of-stock apology. The reservation carries a short expiry in case checkout is abandoned.
  • If payment fails, compensating actions release the reservation and mark the order cancelled — there is no rollback, only deliberate undo.

Used in the wild

  • Retail storefronts where oversell is a customer-service and refund cost.
  • Marketplaces coordinating stock held by multiple independent sellers.
  • Subscription signup flows combining provisioning and billing.

Good to know

  • The idempotency key on the payment call is the single most important detail. Without it, a user double-clicking Pay or a client retrying a timeout gets charged twice, and that is the error customers escalate hardest.
  • Reservation expiry is a genuine business decision, not a technical one. Too short and slow shoppers lose their cart; too long and limited stock sits unsellable during a launch.