Lesson 5 of 16
42. Design E-commerce Cart and Checkout (Amazon / Flipkart)

42.4 What do we store?

3 min read+10 XP
carts (key-value, by user_id or guest_id) items: {sku: qty, price_at_add}, updated_at inventory (SQL, by sku + warehouse) available, reserved reservations order_id, sku, warehouse, qty, expires_at orders (SQL, sharded) order_id, user_id, state, total, idempotency_key (unique) order_items order_id, sku, qty, price_paid payments payment_id, order_id, provider_ref, state, amount outbox order events to publish (Chapter 23)

Interviewer pushback:

  • "Why store price_paid on order items?" → Prices change; the order must record what the customer actually agreed to pay, for refunds, invoices and disputes.

Memory code: "Cart by user, stock by warehouse, orders with a key that can't repeat."