Design an E-commerce Order Fulfillment System
Design a reliable order-fulfillment workflow that reserves inventory, assigns fulfillment sites, coordinates shipments, and exposes trustworthy order status.
Problem statement
For this exercise, assume a confirmed order enters a fulfillment service after catalog selection and payment authorization.
The service must reserve inventory, assign one or more fulfillment sites, coordinate picking and packing, hand shipments to carriers, expose a timestamped status history, and support cancellation while work is still reversible. One order may split across sites and carriers.
Admission must be idempotent, retries must not duplicate work, inventory must not be promised twice, and fulfillment state must move monotonically even when events arrive late or more than once.
Assume one million orders per day, bursts of ten thousand fulfillment state transitions per second, and hundreds of fulfillment sites. Target 99.99% availability, return an accepted or rejected admission result within 500 milliseconds, and make accepted state changes visible within five seconds. Design recovery for site or carrier failure, ambiguous downstream outcomes, and reassignment of work that has not crossed an irreversible handoff.
Design the fulfillment data model, commands and events, site-selection and reservation workflow, split-shipment tracking, cancellation boundaries, status projection, observability, and recovery controls. Catalog and payment processing are upstream.
Recommendations, marketplace settlement, carrier-internal routing, detailed return processing, and warehouse robotics are outside scope.
What to build
- Accept or reject each confirmed order idempotently and expose the authoritative fulfillment identifier and current state.
- Reserve available inventory without double-promising units and assign one or more fulfillment sites to satisfy the order.
- Track picking, packing, carrier handoff, delivery, and reversible cancellation independently for every shipment in a split order.
- Expose an order-level status history derived from versioned shipment events, including degraded, failed, and recovery outcomes.
At scale
- For this exercise, assume one million orders per day and bursts of ten thousand fulfillment state transitions per second across hundreds of fulfillment sites.
- For this exercise, target 99.99% availability and return an accepted or rejected admission result within 500 milliseconds.
- For this exercise, make accepted state changes visible to status readers within five seconds while preserving monotonic lifecycle history.
- For this exercise, retain idempotency and reservation records long enough to cover client and worker retries, and keep recovery queues explicitly bounded.