Preparing your design workspace

Loading the problem and your latest saved attempt…

Design an Online Ordering Platform

Design restaurant ordering and payment, nearby available-courier discovery, exclusive dispatch, delivery tracking, and recoverable notifications.

Problem statement

Design an online platform for ordering from restaurants and delivering the orders. Customers sign in, find nearby restaurants, browse menus, order and pay, track the delivery, and get status notifications. Your team's stack is fixed: React for the web app, Node.js with Express for the server, and MongoDB as the main database. You may add supporting pieces where they help, such as object storage for files, background workers, location indexes and live updates.

Restaurants. Authorized managers each look after one or more restaurants. They keep the menus, menu photos and availability (open or closed) up to date.

Couriers. The platform finds available couriers near the order's pickup point and offers them the delivery. A courier can have at most one active delivery, and an order can have at most one active courier. A search result or an offer is only a suggestion; it does not reserve the courier. When several couriers accept at the same time, or one courier accepts two offers, the system must detect stale versions and return a conflict, so a courier is never assigned to two different orders. Couriers send their location and move each order through pickup and delivery.

Retries and closures. A client may retry order creation or payment after a timeout. Each retried order or payment must end in one lasting outcome, with no duplicate order and no second successful charge. A restaurant may close before or after the payment is confirmed. If that makes an order impossible to fill, the customer sees one cancellation, and the payment is voided or refunded exactly once.

Source of truth. Payment, order, courier assignment, pickup and delivery state are the source of truth, and each carries a version. Notifications can arrive late or more than once; clients catch up by reading the order. Derived location data, such as an index for nearby search, and event delivery, such as an event stream, must never decide who is assigned or what was paid.

Out of scope: reviews, recommendations, promotions, refunds not caused by a closure, payouts, settlement accounting, route optimization and batching several deliveries together.

What to build

  1. Customers and restaurant managers sign in before using protected features.
  2. Customers can find restaurants near a location they give.
  3. Customers can view a restaurant's menu and pick available items.
  4. Customers can place an order with the items they picked.
  5. A manager can be allowed to manage several restaurants, and a restaurant can have several managers.
  6. Authorized managers can add or change menu items for their restaurants.
  7. Authorized managers can upload large photos for menu items.
  8. Customers can pay for an order, see whether payment is pending, succeeded or failed, and safely retry the same payment without being charged twice.
  9. When a restaurant closes after an order is placed, the customer can see whether the order will be filled or cancelled, and sees one final payment result with no double charge or double refund.
  10. The platform finds fresh, available couriers near the pickup, sends offers that expire, and commits each assignment atomically. Conflicts, expiry and reassignment each have a clear result.
  11. Customers, the restaurant and the assigned courier can see the authoritative pickup and delivery state, plus the courier's location while it is fresh.
  12. The people involved get notifications about the order, payment, courier assignment, pickup and delivery. Notifications never become the source of truth.

At scale

  • No traffic numbers are given. State your own assumptions and show how the design scales.
  • Nearby search uses map coordinates or another clear location the customer gives.
  • Restaurant search covers a limited radius and pages through results in a stable order. Courier search returns a limited snapshot of the nearest candidates, which must be checked again before assigning.
  • A courier location older than 15 seconds can't be used for a new offer and shows as stale in tracking.
  • Menu photos can be large. They should not make ordinary JSON requests impractical.