DEV Community

Cover image for Design an e-commerce order management system: the system design interview walkthrough
Gowtham Potureddi
Gowtham Potureddi

Posted on

Design an e-commerce order management system: the system design interview walkthrough

Design an e-commerce order management system: the system design interview walkthrough

The request to design an e-commerce order management system sounds like a form that writes a row to a database — cart, checkout, pay, done. For a single service with one database that is exactly what it is. But the interview asks you to place an order across separate services — take the payment in one, reserve the stock in another, create the shipment in a third — so that an order is never lost, never duplicated, and never left half-done when one of those services fails mid-checkout. That is a distributed-consistency problem, not a form handler, and it is why e-commerce order management system design is one of the hardest 60-minute prompts on the board.

The round turns on two decisions. First, how you represent the life of an order — the order state machine that moves CREATED → PAID → FULFILLED → SHIPPED → DELIVERED, or branches to CANCELLED — so every service agrees on what an order is right now. Second, how you keep that state consistent when the steps live in different databases: order processing system design at this scale is really about distributed transactions, and the answer is a saga, not a lock. This walkthrough follows the path a strong candidate draws when asked to design an order management system — requirements, estimate, API and data model, high-level design, then the deep dives — and at each step it names the follow-up the interviewer uses to tell a memorised answer from an engineer who has actually shipped a checkout. The frame is the same whether the prompt is phrased as "design an Amazon order system" or a generic marketplace.

Title card for a system design interview walkthrough on designing an e-commerce order management system, showing an order moving through states from CREATED to DELIVERED across payment, inventory and shipping services on a dark citrus-and-lavender background.

How the e-commerce order management round is actually run

An order management round runs about 60 minutes on a shared canvas — you draw the services and arrows while you talk, and the interviewer interrupts. It is marked Hard because the one-line problem opens onto deep water fast: the moment you split checkout into payment, inventory and shipping, the question becomes what happens when one of them fails after another has already succeeded — and every answer after that (state, consistency, reliability) compounds. Get the state machine, the saga and the outbox clean and you have shown you can coordinate services without losing a customer's money or their order.

The interviewer rarely lets "write the order to the database and call payment" stand. "Payment went through, but the shipment never got created — walk me through how that happens, what the customer sees, and how your design prevents it." That question — a partial failure across services under a design that looks fine on the happy path — is the one a copied answer can never rehearse, and the one this round is really testing.

The rounds here are modelled on how the loop runs, not scraped from any candidate's recall. What matters for prep is the shape: a blank canvas, a clock, and a follow-up after every decision you make.

The five-step framework for any HLD round

Every high-level design answer fits the same spine. Say it out loud at the start so the interviewer knows you have a plan, then walk it:

  1. Clarify requirements — functional and non-functional, and what you are explicitly not building.
  2. Estimate — orders, reads and the fan-out across services, to justify every later choice.
  3. High-level design — the boxes and arrows: client, order service, inventory, payment, shipping, the queue.
  4. Deep dive — the two or three decisions that actually decide this system.
  5. Follow-ups — failure modes, consistency holes, and what you would change at ten times the scale.

What the debrief measures

The score is not "right or wrong design." A good HLD debrief reads on four dimensions, and every move below maps to one: problem solving (did you model the order as a state machine and coordinate services with a saga), communication (did you say why orchestration over two-phase commit in a sentence), technical execution (make transitions idempotent, publish events with an outbox, key checkout with an idempotency token), and time management (did you spend your 60 minutes on consistency and reliability, not on the cart UI). Reading a walkthrough teaches the design; it does not teach you to deliver it on the clock while someone pushes back.

Step 1 — Requirements: what an order management system must do

Spend the first few minutes here. Jumping to boxes before you have scoped the problem is the fastest way to design the wrong system.

Type Requirement
Functional Place an order (cart → checkout); reserve inventory; take payment; create a fulfilment/shipment; let the customer track order status; handle cancellations and refunds.
Functional (optional) Partial shipments, split payments, promotions and tax, multi-warehouse routing — call these out, then scope most of them for later.
Non-functional Consistency across services (no order left half-done); no lost or duplicate orders; full auditability of every state change; high availability for checkout and for the read-heavy status path.

The sentence that earns points: "Writing the order row is the easy part — the system is really a coordinator that drives one order through payment, inventory and shipping so it never ends up paid-but-unshipped or charged-twice." Say that and you have framed the entire design before drawing a box.

Step 2 — Capacity estimation (back of the envelope)

Estimation here is about proving one thing: the hard axis is coordinating services reliably, not raw QPS.

Quantity Assumption Result
Orders ~10M orders/day ~120 orders/sec average, ~1,000/sec at peak (flash sales, holidays)
Status reads ~20 reads per order (customer refreshes + internal systems) read-heavy — status lookups dominate traffic, served from replicas/cache
State changes every transition persisted and audited an append-only event log / outbox row per transition
Cross-service calls 3+ services per checkout (payment, inventory, shipping) the real challenge is reliable coordination, not the write rate

Two conclusions fall out, and you should say both out loud. First, the numbers are modest — a few thousand writes a second is not the problem; the problem is that each order touches three independent services and any one can fail, so correctness under partial failure is the deep dive. Second, the read path is easy to scale — order status is read far more than it is written, so you serve it from read replicas and a cache and keep it off the write path. You have now pointed the interview at consistency and reliability before anyone asked.

Step 3 — API and data model

The order service has a small public API; most of the complexity is the internal contract between services and the tables that hold order state.

Call Operation
POST /checkout {cart_id, idempotency_key} → order_id create an order from the cart — exactly once, even if retried
GET /orders/{id} → status read the current order state (the read-heavy path)
POST /orders/{id}/cancel request cancellation; triggers compensations if already paid
POST /orders/{id}/refund refund a paid order

The internal saga steps each have a forward call and an inverse, which is what makes rollback possible:

Forward step Compensating step
reserveInventory(order) releaseInventory(order)
capturePayment(order) refundPayment(order)
createShipment(order) cancelShipment(order)

The data model keeps each service's state local, with the order as the coordinator:

Entity Notes
order order_id, customer_id, state (CREATED/PAID/FULFILLED/SHIPPED/DELIVERED/CANCELLED), total, idempotency_key (unique), created_at, updated_at.
order_item order_id, sku, qty, unit_price — the lines on the order.
payment order_id, amount, status (AUTHORIZED/CAPTURED/REFUNDED), psp_ref, idempotency_key.
inventory_reservation order_id, sku, qty, status (RESERVED/COMMITTED/RELEASED), expires_at for time-boxed holds.
outbox event_id, aggregate_id, type, payload, published, created_at — events written in the same transaction as the state change.

Step 4 — High-level design: the order flow

Now the boxes. The whole system is one order being driven through a sequence of service calls, with a message queue carrying the events that let shipping and notifications react without blocking checkout:

  • Client → Order service (orchestrator): the order service owns the order record and drives the sequence; it is the source of truth for order state and nothing else writes that state.
  • Inventory service: reserves stock at checkout (a time-boxed hold), commits the reservation once payment is captured, releases it on cancel or expiry.
  • Payment service: authorises then captures the charge via a payment service provider (PSP), and exposes refund for compensations.
  • Shipping / fulfilment service: creates a shipment once the order reaches PAID/FULFILLED, and emits tracking updates back as the parcel moves.
  • Message queue + outbox: every state change is written to the order DB and an outbox row in the same transaction; a relay publishes those events to the queue, where shipping, notifications and analytics consume them asynchronously.
  • Status store + read replicas/cache: the read-heavy GET /orders/{id} path is served from replicas and a cache, kept off the checkout write path.

Say explicitly that this is an orchestration across services, not a single ACID transaction — each service commits to its own database, so there is no one transaction you can wrap around the whole checkout. That single fact is exactly why the state machine, the saga and the outbox below all exist. Naming it unprompted is a signal the interviewer is listening for.

An e-commerce order management architecture diagram showing a client calling an order service orchestrator that coordinates an inventory service, a payment service and a shipping service, with state changes written to a database and an outbox, a relay publishing events to a message queue, and a read-replica path serving order status lookups.

Deep dive: the order state machine

This is the first decision that actually decides the round. An order is not a row with a pile of boolean flags — is_paid, is_shipped, is_cancelled — because those flags admit impossible combinations (paid and cancelled and shipped at once) and give you no single answer to "what is this order right now?" The senior answer is an explicit state machine: a fixed set of states and the only legal transitions between them.

From Event To
CREATED payment captured PAID
PAID inventory committed FULFILLED
FULFILLED shipment created SHIPPED
SHIPPED delivery confirmed DELIVERED
CREATED / PAID cancel or step failure CANCELLED (run compensations)

Three properties make this hold up under follow-ups. One source of truth: only the order service writes state, so there is never a disagreement about where the order is. Guarded, idempotent transitions: a transition is only applied if the order is in the expected from state, and re-applying the same event is a no-op — so a retried or duplicated message cannot push the order forward twice. A clean read path: the status every customer and system reads is just the current state, which is why status lookups are cheap and cache-friendly. An illegal transition (cancel an order that already shipped) is rejected by the machine, not silently applied — it becomes a return/refund flow instead.

"A cancel request arrives for an order that has already shipped — what happens?" The state machine has no SHIPPED → CANCELLED edge, so the transition is rejected; the request is routed into a returns/refund flow instead. Say that the machine refuses illegal moves rather than trusting the caller — that refusal is the whole point of modelling state explicitly.

System Design
HLD · Payments & marketplaces · 60 min
Design an order management system out loud, with follow-ups

Practise on Zynter →

Deep dive: distributed transactions and the saga pattern

This is the decision most candidates under-think. Checkout spans three services with three databases, and the follow-up is always "what if payment succeeds but inventory fails?" The naive instinct is a single distributed transaction — a two-phase commit (2PC) across all three — and you should be ready to say why that is the wrong tool here.

Why 2PC does not scale. Two-phase commit holds locks across every participant for the whole duration, across the network, which kills throughput and availability; the coordinator is a single point of failure; and your PSP — a third party behind an HTTP API — cannot enlist in your distributed transaction at all. You cannot XA-wrap a Stripe call. So you give up the illusion of one atomic transaction and coordinate with a saga: a sequence of local transactions, each with a compensating transaction that undoes it.

Orchestration vs choreography. In a choreography saga, services react to each other's events with no central brain — flexible, but the overall flow is implicit and hard to debug. In an orchestration saga, the order service is the central coordinator: it issues reserveInventory, then capturePayment, then createShipment, and on any failure it runs the compensations in reverse. For order management you want orchestration — the flow is explicit, auditable, and the state machine already lives in the order service, so put the coordinator there too.

Compensating transactions. Each forward step has an inverse (releaseInventory, refundPayment, cancelShipment). If step N fails, you run the compensations for steps N-1 … 1 in reverse order, then move the order to CANCELLED. If capturePayment succeeds but reserveInventory then fails, you refundPayment and cancel the order; if shipping fails after payment and inventory both succeeded, you refundPayment and releaseInventory. The order is never left paid-but-unshipped — it either completes forward or compensates all the way back.

"Payment succeeded but inventory reservation failed — what state is the order in, and what do you do?" The saga runs the compensation for the step that did succeed: refundPayment, then transition the order to CANCELLED. The order never rests in a paid-but-unfulfilled state — the compensating transaction is what guarantees it unwinds cleanly. Name the inverse step and the final state.

An e-commerce order saga diagram showing an order service orchestrating forward steps reserve inventory, capture payment and create shipment, with compensating steps release inventory, refund payment and cancel shipment running in reverse when a later step fails, ending in a cancelled order state.

System Design
HLD · Payments & marketplaces · 60 min
Defend a saga with compensating transactions out loud

Practise on Zynter →

Deep dive: reliability — exactly-once, outbox and idempotency

Groups of services talking over a network change the shape of the problem. Messages get retried, brokers go down, and a request that times out may already have succeeded. Three pieces close those holes.

The dual-write problem. When an order is placed you want to do two things atomically: commit the order to the DB and publish an "order placed" event to the broker. But they are two different systems — if the DB commits and the broker is then down, the event is lost and shipping never hears about the order; if you publish first and the DB write fails, you have announced an order that does not exist. You cannot atomically write to both.

The transactional outbox. Solve it by writing the event into an outbox table in the same DB transaction as the state change. The commit is now a single atomic write to one database. A separate relay — a poller, or change-data-capture (CDC) reading the DB log — reads unpublished outbox rows and pushes them to the broker, marking them published. The event is guaranteed to reach the queue eventually (at-least-once), because it is durably stored the instant the order commits.

Idempotency and dedup. At-least-once delivery and client retries both mean the same action can arrive twice, so both ends must be idempotent. The client sends an idempotency key with checkout; the order service upserts on that unique key, so a retried request returns the same order_id instead of creating a second order — and the payment capture is keyed too, so a retried capture never double-charges. On the consumer side, shipping dedups on event_id/order_id, so processing the same "order placed" event twice still creates exactly one shipment.

"The checkout request is retried after a timeout — how do you avoid two orders?" The client sends an idempotency key; the order service makes it a unique constraint and upserts, so the retry resolves to the existing order_id rather than inserting a new one. The key turns "create an order" into a safely repeatable operation.

"The DB commit succeeds but the broker is down — how does the 'order placed' event still reach the shipping service?" The event was written to the outbox table inside the same transaction, so it is already durable. The relay/CDC process retries publishing until the broker is back, then marks the row published — at-least-once delivery, with the shipping consumer deduping on event_id.

An e-commerce order reliability diagram showing the dual-write problem solved by a transactional outbox: an order and an event row committed in one database transaction, a relay or change-data-capture process publishing events to a message queue, idempotency keys on checkout preventing duplicate orders, and a shipping consumer deduplicating on event id.

The follow-ups that decide the order management round

Scan the probes from each deep dive and they rhyme. Master these five and you are ready for a version of the question that is not drawn exactly like this one.

  • "Payment succeeded but inventory failed — what state, and what do you do?" → The saga compensates: refundPayment, then CANCELLED. The order never rests paid-but-unfulfilled. (problem solving)
  • "Checkout is retried after a timeout — how do you avoid two orders?" → An idempotency key with a unique constraint; the order service upserts and returns the existing order_id. (technical execution)
  • "The DB commits but the broker is down — how does shipping hear about the order?" → A transactional outbox: the event is written in the same transaction, and a relay/CDC publishes at-least-once to a deduping consumer. (technical execution)
  • "A cancel arrives for an already-shipped order — what happens?" → The state machine has no such edge; it rejects the transition and routes to a returns/refund flow. (communication)
  • "Isn't this just a QPS problem?" → No — the orders/sec are modest; the challenge is coordinating three services with no lost or duplicate orders, which the state machine, saga and outbox solve. (problem solving)

Each maps to a debrief dimension. Reading this list teaches you the answers; it does not teach you to deliver them while someone interrupts — that only comes from saying them out loud.

How to prepare: a one-week plan

You do not need fifty systems. You need this one cold and the framework automatic, so the next "design X" is just new nouns in the same five steps.

  • Days 1–2: Learn the five-step framework until it is reflex. Do the order system end to end on paper — requirements, estimate, data model, the checkout → reserve → pay → fulfil → ship flow.
  • Days 3–4: Drill the state machine and the saga: the legal transitions, forward steps and their compensations, and orchestration over 2PC. Say each tradeoff in one sentence.
  • Days 5–6: Own reliability — the dual-write problem, the transactional outbox, idempotency keys on checkout, and idempotent consumers. Answer each of the five follow-ups out loud.
  • Day 7: A full timed 60-minute round, narrating the whole way, with someone (or something) interrupting. This is the rep that counts.

This post is the deep walkthrough behind one row of the broader Top 25 system design interview questions — once the order system is automatic, the same spine carries the rest of the list.

Frequently asked questions

How do I design an e-commerce order management system step by step?

Follow the five-step HLD framework. Clarify requirements (place an order, reserve inventory, take payment, fulfil and ship, track status, cancel and refund — with consistency, no lost or duplicate orders, and full auditability); estimate to show the hard axis is coordinating services reliably, not raw QPS; define the checkout API plus the order, payment, inventory_reservation and outbox tables; draw the order flow (client → order service orchestrating inventory, payment and shipping, with a message queue and read replicas); then deep-dive the decisions that matter — the order state machine, the saga pattern, and reliability via the outbox and idempotency. Finish on the follow-ups about partial failure and duplicate orders.

What is the order state machine and why use one?

The order state machine is the explicit set of states an order can be in — CREATED, PAID, FULFILLED, SHIPPED, DELIVERED, or CANCELLED — plus the only legal transitions between them. It beats a bag of boolean flags (is_paid, is_shipped) because those admit impossible combinations and give no single answer to "what is this order now?" With a state machine, only the order service writes state, transitions are guarded by the current state and are idempotent so a duplicated message cannot advance the order twice, and illegal moves such as cancelling a shipped order are rejected rather than silently applied.

How do you keep data consistent across payment, inventory and shipping?

You cannot wrap one ACID transaction around three services with three databases, and two-phase commit does not scale (it holds cross-service locks, the coordinator is a single point of failure, and a third-party PSP cannot enlist). Instead you use a saga: a sequence of local transactions, each with a compensating transaction that undoes it. An orchestration saga puts the order service in charge — it calls reserve inventory, capture payment, create shipment in order, and on any failure runs the inverse steps (release inventory, refund payment, cancel shipment) in reverse, then moves the order to CANCELLED. The order either completes forward or unwinds cleanly.

How do you stop duplicate orders when checkout is retried?

With idempotency keys. The client sends a unique idempotency key on the checkout request, and the order service enforces it as a unique constraint and upserts on it, so a retried request after a timeout resolves to the same order_id instead of inserting a second order. The payment capture is keyed the same way so a retried capture never double-charges. Because event delivery is at-least-once, downstream consumers such as shipping also dedup on event_id or order_id, so processing the same "order placed" event twice still creates exactly one shipment.

What is the transactional outbox pattern?

It solves the dual-write problem — the fact that you cannot atomically write to your database and publish to a message broker, so a broker outage after a DB commit would lose the event. Instead you write the event into an outbox table inside the same database transaction as the state change, making the commit a single atomic write. A separate relay, or change-data-capture reading the DB log, then reads unpublished outbox rows and pushes them to the broker, marking them published. The event is guaranteed to reach the queue eventually, even if the broker was down at commit time.

How do I practise a system design interview out loud?

Reading a walkthrough is not the same as defending a design while someone interrupts. On Zynter, the HLD track runs live voice rounds modelled on how real system design loops run — you talk through a shared design on the canvas, and a voice interviewer pushes with the follow-ups above one at a time, then gives you a debrief on problem solving, communication, technical execution, and time management. The score is a practice signal, not a hiring decision.

Practise it on Zynter

You can read every state transition. The round is won on the partial-failure case.

Pick the E-commerce Order Management round, draw the order flow on the canvas, and defend it out loud to a voice interviewer that keeps asking "what if payment succeeds but inventory fails?" and "how do you avoid two orders on a retry?" — then read the debrief. Zynter.ai is on-demand mock interviews modelled on real company loops, with 150+ rounds across 20 companies including the HLD system design track (Sep 2026).

Practise the E-commerce round →
Browse all interview tracks

Top comments (0)