Design a food delivery platform similar to DoorDash or Uber Eats that connects hungry customers with local restaurants and manages a fleet of delivery drivers. The system must handle the complete ordering flow: browsing menus, placing orders, routing them to restaurants for preparation, dispatching nearby drivers to pick up food, and delivering it to customers while providing real-time tracking throughout the journey.
The platform operates in dozens of cities with thousands of concurrent orders during peak meal times. Customers expect accurate ETAs, live location tracking, and seamless payments. Restaurants need reliable order notifications and kitchen display integration. Drivers require efficient routing, batch pickup opportunities, and fair work assignment. The interviewer wants to see how you balance low-latency matching, eventual consistency across services, handling failed deliveries, and maintaining accurate inventory as menu items sell out.
Based on real interview experiences, these are the areas interviewers probe most deeply:
The core challenge is efficiently pairing ready orders with nearby available drivers while respecting capacity constraints and optimizing for delivery time. Poor matching logic causes cold food, long wait times, and driver inefficiency.
Hints to consider:
Orders progress through multiple states (placed, confirmed, preparing, ready, picked up, delivered) with transitions triggered by different actors. State management must be idempotent and handle timeouts, cancellations, and no-shows without corrupting the workflow.
Hints to consider:
Drivers continuously stream GPS coordinates while customers demand smooth map updates and accurate time estimates. This creates a high-throughput ingest problem coupled with complex ETA modeling based on traffic and restaurant preparation time.
Hints to consider:
Restaurants update menus, mark items unavailable, and adjust prices throughout the day. The system must reflect these changes quickly while handling race conditions when customers order an item that just sold out, and support surge pricing during peak demand.
Hints to consider:
The platform must capture funds from customers, hold them during delivery, handle refunds for problems, and accurately split payouts among restaurants, drivers, and the platform while maintaining an audit trail for disputes.
Hints to consider:
Start by confirming scope and constraints with the interviewer. Ask about target scale (orders per hour, number of cities), whether the system should support restaurant chains with multiple locations, if driver batching (delivering multiple orders in one trip) is required, and what SLAs matter most. Clarify whether you need to design the restaurant kitchen integration or treat it as a black box. Confirm if surge pricing, scheduled orders, and group orders are in scope. Establish the consistency model for inventory and whether partial failures should cancel orders or allow partial fulfillment.
Sketch the major services: API Gateway for mobile apps, Order Service managing the state machine, Restaurant Service handling menus and fulfillment, Driver Service tracking availability and location, Dispatch Service for matching logic, Tracking Service for real-time updates, Payment Service coordinating financial flows, and Notification Service for push alerts. Identify key data stores: relational database for orders and users, document store for restaurant menus, geospatial cache (Redis with geo commands) for driver locations, message queue (Kafka) for location streams and order events, and time-series database for analytics. Show how mobile apps connect via WebSocket for live updates and REST for transactional operations.
Walk through the driver assignment algorithm in detail since it's the most critical and complex piece. When a restaurant marks an order ready for pickup, the Dispatch Service queries the geospatial cache for drivers within a radius (e.g., 2 miles), filters by availability and vehicle type, ranks by distance and acceptance rate, then attempts to reserve the top candidate using a distributed lock with TTL. If the driver accepts within 30 seconds, transition the order to "assigned"; if they decline or timeout, release the lock and try the next candidate. Discuss sharding the cache by geo-cell to avoid hotspots, handling edge cases like no available drivers (widen radius, increase incentives), and batching logic that groups nearby orders to the same driver. Explain how you'd prevent double-assignment races using Redis SETNX or conditional updates in your database.
Cover remaining non-functional requirements efficiently. For scalability, explain horizontal partitioning strategies (orders by city and time range, menus by restaurant ID) and read replica patterns for menu browsing. For reliability, discuss circuit breakers around payment gateways, graceful degradation when tracking is unavailable, and retry policies with exponential backoff. Address monitoring by tracking key metrics like assignment latency, order cancellation rate, ETA accuracy, and payment success rate. Touch on security concerns like authenticating driver location updates, validating menu prices at checkout, and PCI compliance for payment data. Mention how you'd use feature flags to roll out new dispatch algorithms and A/B test pricing strategies. Finally, briefly outline the data pipeline for analytics, fraud detection, and machine learning models that improve ETA prediction and restaurant prep time estimates.
Deepen your understanding of the patterns used in this problem: