Design a Food Delivery App
viaLeetCode
Problem Design a food delivery platform (DoorDash/Uber Eats style): browse restaurants and menus, place orders, match drivers, and track delivery in real time.
Functional requirements
- Restaurant/menu browsing with search and geo-filtering; cart and order placement with payment.
- Order lifecycle: placed → accepted by restaurant → prepared → picked up → delivered (with cancellations/refunds).
- Driver matching and live location tracking for the customer.
Non-functional requirements
- Scale to discuss: ~10M DAU, ~500 orders/sec peak (meal-time spikes), 100K concurrent drivers streaming location every few seconds.
- Order placement must be reliable/consistent; tracking can be eventually consistent but fresh (~2–5 s).
Key components
- Catalog service (restaurants/menus, search index, cache), order service (state machine, transactional store), payment service, dispatch service (driver matching), location service (driver GPS ingest — write-heavy time-series/redis geo), notification service (push/SMS), real-time tracking channel (WebSocket/SSE).
Deep dives / trade-offs
- Driver matching: nearest-driver via geo-index (geohash/H3 buckets); batching vs immediate assignment; handling rejections with timeout-and-reassign.
- Order state machine consistency across services — outbox/event-driven updates vs synchronous calls; exactly-once payment capture.
- Location ingest at 100K writes/sec: partitioning, in-memory geo store with periodic snapshot, fan-out to interested watchers only.
asked …