Design a Food Delivery Service
🛵 What is a food delivery service? It is the app in the middle of a three-way deal. A customer orders from a restaurant, the restaurant accepts and cooks, and a courier carries the food from the restaurant to the customer's door. The system tracks where each order is, and decides which courier takes it.
You may hear this as "design DoorDash", "design Uber Eats", "design Zomato" or "design Swiggy". At the low-level design stage they are the same problem: an order that moves through a fixed set of steps, and a rule for matching orders with couriers. Zomato-style prompts lean more on finding restaurants and browsing menus, so we cover menus and restaurant search in Extensibility. If your interviewer wants the distributed version (millions of couriers, live GPS, sharded data), that is the system design problem at /system-design/food-delivery.
The two things interviewers watch here are the order life cycle (can you cancel after pickup? who is told when?) and the dispatch rule (which courier, and what if nobody is free?). Both are rules that change, so the interesting part is where you put them.
Requirements
"Design a food delivery app like DoorDash. Customers order from restaurants, and couriers deliver the food."
A real delivery app has menus, carts, payments, ratings, live maps and ETAs. Most of that is out of scope for 45 minutes. The questions below narrow it to the part with real design decisions.
Clarifying Questions
You: Should we focus on the menu and checkout, or on what happens after the order is placed?
Interviewer: After. Assume the customer has already picked their food. I care about the order flow and how couriers get assigned.
You: What steps does an order go through?
Interviewer: The customer places it. The restaurant accepts it. A courier picks it up at the restaurant and then delivers it. An order can be cancelled until the courier has picked it up, not after.
You: When do we assign a courier: when the order is placed, or when the restaurant accepts?
Interviewer: When the restaurant accepts. We don't want to send a courier to a restaurant that might turn the order down.
You: Which courier gets the order?
Interviewer: The free courier closest to the restaurant. Locations are points on a grid, and distance is in city blocks, so |dx| + |dy|. If two couriers are equally close, the smaller courier id. Product keeps changing this rule, though.
You: What if no courier is free?
Interviewer: The order waits. As soon as any courier becomes free, they take the order that has been waiting the longest.
You: Can a courier carry several orders at once?
Interviewer: One at a time for now. We might talk about batching later.
You: How do we know where couriers are? Do we get live GPS updates?
Interviewer: Keep it simple. A courier stays where they are while idle. After a delivery, they are at the customer's location.
Two answers shape the whole design. "Product keeps changing this rule" tells us where a strategy belongs. "The order waits, and the first free courier takes the oldest one" tells us we need a queue and one single place where a courier becomes free.
💡 Interview tip: Ask "what if no one is available?" for every matching problem: couriers, drivers, rooms, agents. Turning a request away, retrying later and queueing it are three very different designs, and interviewers expect you to choose one on purpose.
Final Requirements
- Restaurants and couriers are added with an id and a location. Ids are unique.
- A customer places an order from a restaurant with a dropoff location. The order gets an id and starts as
PLACED. - An order moves
PLACED → ACCEPTED → PICKED_UP → DELIVERED. It can be cancelled whilePLACEDorACCEPTED. No other move is allowed. - When the restaurant accepts an order, the free courier closest to the restaurant is assigned; ties go to the smallest courier id.
- If no courier is free, the accepted order waits. Whenever a courier becomes free (new, delivered, or their order was cancelled), they take the order that has waited longest.
- A courier carries one order at a time. After a delivery, the courier is at the dropoff location.
- Anyone can ask for an order's status and its courier.
- The dispatch rule changes often, so changing it must not touch the order flow.
Out of scope
- Menus, carts, prices and payment (menus come back in Extensibility).
- Live GPS tracking, routes and ETAs.
- Ratings, tips and courier pay.
- Batching several orders per courier (Extensibility).