KatInterview

Unified Shipping Platform Across Several Courier Services

System DesignModel answer
MediumModel answerSystem Designsystem-designapi-designidempotency

Last updated

Design a backend that lets a retailer rate, buy labels, and track parcels across multiple couriers behind a single internal API, with safe retries and fault isolation.

Problem

An online retailer ships millions of parcels a day from many warehouses and wants one internal shipping platform that sits in front of several external couriers (think national postal services and large private express companies). Each courier has its own API style, authentication, address rules, service names, and tracking codes.

Design the platform so that order-management systems and warehouse tooling interact with a single, consistent interface.

Capabilities required

  • Register a shipment for an order, including origin and destination addresses and one or more packages (weight, dimensions, declared value).
  • Pick a courier and service level, either explicitly or automatically based on a rule such as "cheapest option that still meets the promised delivery date".
  • Buy postage and produce a printable label with a tracking number.
  • Follow the parcel from creation to final delivery, including failure and exception outcomes.
  • Cancel a label before the parcel is picked up.
  • Hide courier-specific differences behind a uniform API and a normalized status model.

What to cover in your answer

  1. Assumptions, scope clarifications, and a rough capacity estimate.
  2. The main internal APIs.
  3. The data model and your storage choices.
  4. The main components and how courier integrations are structured.
  5. Reliability and scalability: retries, duplicate prevention, courier outages, rate limits, and high-volume tracking updates.
  6. Key trade-offs and what you would do differently as the system grows.

Assume peak load of several hundred label purchases per second and thousands of tracking updates per second.

Hints

Hint 1

Label purchase costs real money, so think about what happens when a courier call times out after charging you. How do you avoid buying twice?

Hint 2

Define a common adapter interface per courier (rate, purchase, void, track, parse webhook) and a canonical status enum so the rest of the system never sees courier-specific codes.

Hint 3

Separate the write path that must stay available (label purchase) from the high-volume ingest path (tracking events), and decide where queues, caches, and circuit breakers belong.