Prod Squad

Worked case: design the backend for a food delivery app

A three-sided marketplace system design covering customers, restaurants and riders, with ordering, payments, dispatch and live tracking.

7 min readPM#worked case#system design#food delivery#marketplace
Ask about this lesson
On this page

Food delivery backends are a great system design case: three user groups (customers, restaurants, delivery partners), money, real-time tracking, huge dinner-time spikes, and plenty of failure modes. It's also a question where product judgement clearly matters, because every technical decision shows up in the customer experience.

Why interviewers ask this

Interviewers check whether you can break a complex product into services, design the critical order flow carefully (payments, idempotency, state changes), handle real-time location, and plan for peaks and failures. Strong candidates keep returning to user impact: accurate delivery times, no double charges, and graceful handling when things go wrong.

The framework

Requirements → users and scale → components → data flow → tradeoffs → metrics.

Worked example

Question: "Design the backend for a food delivery app."

1. Clarify requirements

"I'll focus on the core loop: browse → order → pay → restaurant accepts → rider assigned → live tracking → delivered.

  • Customers: browse restaurants and menus, place orders, pay, track in real time.
  • Restaurants: receive and accept orders, update prep status and menu availability.
  • Riders: receive delivery offers, navigate, update status, share location.
  • Non-functional: ordering and payment must be reliable and never double-charge; tracking within a few seconds; browsing fast; handle a dinner peak of about 5x the average.
  • Out of scope: promotions engine, ratings, rider payouts."

2. Users and scale

"Assume 2 million orders a day in one country, with 30% in a two-hour dinner window: about 80 orders per second at peak. Browsing is far heavier, maybe 50 menu views per order. 100,000 active riders sending location every few seconds is around 25,000 location updates per second at peak."

3. Core components

flowchart TB
    CA["Customer app"] --> GW["API gateway"]
    RA["Restaurant app"] --> GW
    DA["Rider app"] --> GW
    GW --> CAT["Catalogue service<br/>restaurants and menus"]
    GW --> ORD["Order service"]
    GW --> LOC["Location service"]
    ORD --> PAY["Payment service"]
    PAY --> PG["Payment gateway"]
    ORD -->|order events| BUS[["Event bus"]]
    BUS --> DSP["Dispatch service<br/>assign riders"]
    BUS --> NOT["Notification service"]
    BUS --> ETA["ETA service"]
    DSP --> LOC
    CAT --> CC[("Cache")]
    ORD --> ODB[("Orders database")]
  • Catalogue: restaurants, menus and availability, heavily cached because browsing dominates.
  • Order service: the order's lifecycle and state: placed, paid, accepted, preparing, picked up, delivered or cancelled. A relational database with transactions.
  • Payment service: talks to the payment gateway; idempotent so retries never double-charge; handles refunds.
  • Dispatch: matches orders to nearby available riders, considering distance, prep time and load.
  • Location service: stores riders' latest positions in memory; streams them to customers during active orders.
  • ETA service: predicts prep and delivery times, a big driver of trust.
  • Event bus and notifications: order events fan out to dispatch, notifications and analytics.

4. Data flow: placing an order

"Customer taps Place Order → the order service validates items and prices against the catalogue (not the app's cached copy) → creates the order with an idempotency key → the payment service charges via the gateway → on success, the order is marked paid and an 'order placed' event is published → the restaurant app gets the order; on acceptance, dispatch starts finding a rider timed to the prep estimate → the rider accepts; the customer sees live location until delivery."

5. Tradeoffs and failures

  • Payment succeeded but the order failed to save: reconcile automatically (a job that matches payments to orders) and refund or complete; never leave the customer charged without an order.
  • Restaurant doesn't accept within a few minutes: auto-cancel with an instant refund and suggest similar restaurants.
  • No rider available: show honest delays early, offer pickup, or limit orders from areas without riders (a product choice over a technical one).
  • Peak load: cache menus aggressively, queue non-critical work, scale order and dispatch services horizontally, and degrade non-essential features (recommendations) first.
  • Consistency: menu availability can be a minute stale for browsing, but must be checked at order time.
  • Build vs buy: buy payments and maps; build dispatch and ETAs, which are competitive advantages.

6. Metrics

"Order success rate, payment error rate, p95 time to confirm an order, ETA accuracy (predicted vs actual), rider assignment time, and customer-facing outcomes: on-time delivery rate, cancellations and refunds."

Common mistakes

  • One giant 'backend' box without the key services.
  • Hand-waving payments, the riskiest part.
  • Ignoring the restaurant and rider sides of the marketplace.
  • No plan for dinner peaks.
  • Treating ETAs as an afterthought, when they drive trust.

Interviewer tips

What "great" sounds like:

  • "I'll design the core order loop and treat promotions and ratings as out of scope."
  • "Prices are re-validated on the server at order time, never trusted from the app."
  • "Payments are idempotent, with a reconciliation job for the in-between failures."
  • "We build dispatch and ETAs because they're our edge; we buy payments and maps."
  • "Under peak load, recommendations degrade first; ordering never does."

Practice questions

Answer one in a mock interview and get graded instantly.

  1. 1.Design the backend for a food delivery app.

    Practice this →
  2. 2.Explain what happens when a user taps "Place Order" in a food delivery app.

    Practice this →
  3. 3.How would you design the system that predicts delivery times, and how would you measure it?

    Practice this →

Finished reading?