42. Design E-commerce Cart and Checkout (Amazon / Flipkart)
1
The interview prompt2
42.1 What do you ask first?3
42.2 How big is this, really?4
42.3 What are the doors?5
42.4 What do we store?6
42.5 What does the whole system look like?7
42.6 How is the cart stored?8
42.7 How do you reserve inventory?9
42.8 How do you make order creation idempotent?10
42.9 How does the payment hand-off work?11
42.10 How does the checkout saga work?12
42.11 What would you say in the last five minutes?13
Score yourself14
Variations to practise15
Sources16
Code lab42. Design E-commerce Cart and Checkout (Amazon / Flipkart)
42.1 What do you ask first?
3 min read+10 XP
Step 1: Requirements (5 minutes)
| Letter | Candidate asks | Interviewer answers |
|---|---|---|
| Scope | "Cart for guests and signed-in users? Coupons? Multiple sellers and warehouses? Which payment methods? Cash on delivery?" | "Both. Coupons yes. Many warehouses. Cards, UPI, wallets; cash on delivery too. Skip shipping logistics." |
| Count | "How many orders?" | "A few million a day normally; on sale day, peaks of about 5,000 orders a second at opening." |
| Access pattern | "Cart activity vs orders?" | "Carts change far more often than orders are placed; about 50 million active carts." |
| Latency | "How fast should checkout feel?" | "A few seconds end to end, including payment." |
| Exactness | "Can we oversell? Charge twice? Lose an order?" | "None of those." |
Agreed requirements:
- Functional (verbs): add and update cart items (guest and signed in), merge carts at login; review prices and offers at checkout; reserve stock; take payment; create the order; notify warehouses.
- Non-functional (adjectives): cart fast and always available; checkout correct (no oversell, no double charge, no lost order), idempotent, resilient to payment delays and failures, scalable to sale-day peaks.
Interviewer pushback:
- "Should the cart be strongly consistent?" → No. A cart is a wish list: it should never fail to accept an item, and slight staleness is fine. Correctness starts at checkout, where we re-check prices and stock.
Memory code: "Relaxed cart, strict checkout."