2dbi

Design a Logistics / Order Delivery System

viaLeetCode

Problem Design an end-to-end logistics/order-delivery system: an order placed online is picked, shipped through warehouses/hubs, carried by carriers, and tracked to the customer's door.

Functional requirements

  • Order intake → shipment creation (possibly split shipments), warehouse assignment and pick/pack, carrier selection and handoff, multi-leg routing through hubs, customer-facing tracking with status events and ETA, exception handling (lost/delayed/returned).

Non-functional requirements

  • Scale to discuss: millions of shipments/day, tracking-event ingest bursts from carrier feeds; tracking reads dwarf writes; status must be durable and auditable.

Key components

  • Order service → shipment service (shipment = state machine: created → picked → in-transit(leg n) → out-for-delivery → delivered), warehouse/inventory service (assignment by stock + proximity), routing service (legs through hubs; cost/ETA optimization), carrier integration layer (normalize heterogeneous carrier APIs/webhooks — adapter per carrier), tracking service (event store, per-shipment timeline, customer API + notifications).

Deep dives / trade-offs

  • Tracking-event pipeline: queue-based ingest, idempotent handlers (carriers redeliver), out-of-order events resolved by event-time versioning.
  • Data model: Shipment 1—N Legs, 1—N TrackingEvents; separating operational store from the read-optimized tracking timeline (CQRS-lite).
  • Warehouse assignment trade-offs (distance vs stock vs load) and re-planning when a leg fails; ETA computation and when to recompute.
Add a follow-up question they asked
No follow-ups yet. Be the first to add one.
asked …
LeaderboardSalary
Language
Account