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

Score yourself

3 min read+10 XP

Score yourself

Give yourself 0, 1 or 2 points per row.

Area0 points1 point2 points
RequirementsStarted drawingCart and orderOversell, double charge, lost orders, sale peaks and COD agreed
EstimatesNoneNumbers, not used laterNumbers that separated relaxed carts from strict orders and hot stock
API and dataSkippedEndpoints onlyIdempotency key, expected total, holds, order states, price paid
High-level designOne service, one DBServices without flowPreview, reserve, pay, webhook, confirm/release walked
Deep diveHand-wavedOne topicConditional reservation, idempotency, payment states or saga done properly
Trade-offsNone namedNamed when askedRaised unprompted (cart availability vs checkout correctness, hold length, late payments)
CommunicationLong silencesMostly clearThought out loud, checked in, managed time

12 to 14: strong hire signal. 8 to 11: solid, polish the weak rows. Under 8: redo the round in a week, timer on.

The bar: fresher vs SDE-2

FresherSDE-2
CartTable of cart itemsKey-value by user, guest merge, prices as hints, always writable
StockCheck then decrementConditional update, holds with expiry, hot-row bucketing
OrdersInsert on clickIdempotency key, unique constraint, state machine
PaymentCall gateway, waitAsync with webhooks, reconciliation, late payments refunded
Cross-serviceOne transactionSaga with ordered, idempotent compensations and outbox events

Common mistakes

  • Reading stock, then decrementing it, so concurrent buyers oversell.
  • Reserving stock when items go into the cart.
  • No idempotency key, so a double tap creates two orders.
  • Treating payment as synchronous and having no state for "money arrived after we gave up".
  • Sending the confirmation email before the order is confirmed.

Quick check

Five questions on this chapter. Pick an answer, then check it.

quiz