Design a Cart-to-Order Inventory Platform
Move a cart through checkout and order stages while preventing concurrent inventory oversell.
Problem statement
For this exercise, assume shoppers create carts, change quantities, begin checkout, reserve inventory, authorize payment, and receive an order that progresses through confirmed, allocated, shipped, delivered, cancelled, or refunded states. Prices and inventory may change after items enter a cart.
Concurrent checkouts must not oversell stock, payment callbacks may be duplicated or outcome-ambiguous, and expired reservations must release inventory exactly once. Design cart, pricing snapshot, inventory reservation, checkout orchestration, order state, payment reconciliation, cancellation, and recovery.
Exclude product discovery and warehouse route optimization.
What to build
- Shoppers create a cart and change item quantities without reserving stock indefinitely.
- Checkout obtains bounded inventory reservations without overselling concurrent buyers.
- Payment and inventory outcomes produce one durable confirmed order or an explicit compensation.
- Orders follow legal stages, and cancellation releases resources exactly once.
At scale
- Assume five million active carts and 25,000 checkout attempts per second at peak.
- Cart reads target p95 below 200 milliseconds and checkout commands below two seconds excluding payment-provider latency.
- Inventory reservations expire after ten minutes.
- Committed reservations and confirmed orders must never exceed available stock.