Scope
Functional
- Browse and search a catalogue of products with variants (size, colour), prices and stock status.
- Cart that persists across devices.
- Checkout: address, delivery slot or estimate, payment (UPI, cards, wallets, COD), order confirmation.
- Order tracking, cancellation and returns.
- Sellers (marketplace) can list products and manage stock.
Non-functional
- Product and search pages p99 < 300 ms; checkout must never double-charge or oversell.
- 99.95% availability for browse and checkout; graceful degradation for recommendations and reviews.
- Sale-day peaks of ~40× normal traffic.
Out of scope: seller payouts and accounting detail, ads, warehouse robotics.
Size
- 50M monthly active users; 5M daily orders on a normal day, 20M on a sale day.
- Normal: 5M orders/day ≈ 60 orders/s, peaks ~300/s. Sale day: bursts of 5,000 orders/s in the first minutes.
- Browse:order ratio ≈ 100:1 → 6,000 page views/s normal, 300,000/s at the sale peak.
- Catalogue: 200M SKUs × ~5 KB of attributes ≈ 1 TB; images ~50 TB in object storage behind a CDN.
- Orders: 5M/day × 2 KB ≈ 10 GB/day ≈ 3.6 TB/year.
Decision: browse is massively read-heavy and cacheable; checkout is low-volume but correctness-critical. Design them as different worlds.
Services
| Service | Owns | Store |
|---|---|---|
| Catalogue | Products, variants, attributes, seller listings | Document DB / Postgres (source of truth) |
| Search | Search index, facets, ranking | Elasticsearch / OpenSearch |
| Pricing | Prices, discounts, coupons | Postgres + cache |
| Inventory | Stock per SKU per warehouse, reservations | Postgres (sharded by SKU) |
| Cart | Carts per user | Redis + durable KV (DynamoDB / Cassandra) |
| Checkout | The checkout workflow | Workflow engine + Postgres |
| Orders | Orders, items, status history | Postgres sharded by customer_id |
| Payments | Payment attempts, gateway integration, ledger | Postgres (Case Study C12 of the book) |
| Fulfilment | Shipments, tracking | Postgres + events |
APIs
GET /v1/products/{id} → product page model
GET /v1/search?q=&filters=&cursor= → results + facets
PUT /v1/cart/items/{sku} {qty} → cart
POST /v1/checkout {cart_version, address_id, payment_method} (Idempotency-Key)
GET /v1/orders?cursor= → my orders
GET /v1/orders/{id} → order + trackingThe 30-second summary
"Browse and checkout are different worlds. Browse is served from denormalised product models in CDN and Redis, with search fed by CDC events, and degrades by dropping non-essential widgets. Checkout is a saga: reserve stock with a TTL using a conditional decrement, charge with an idempotency key, create the order, then confirm the reservation, with compensations on failure. Orders are sharded by customer and every status change is an event. For the festival sale we pre-scale, bucket hot-SKU stock, put a waiting room in front of marquee deals, and spread payments across gateways."
Follow-up questions the interviewer may ask
- How do you show "only 3 left" without hammering inventory?
- What if payment succeeds but order creation fails?
- How would you support multiple warehouses?
Model answers to each of these are in the book.