Design Uber Eats (Online Food Delivery Platform)

Difficulty: MEDIUMCategory: HLDFrequency: 1Asked On 2024-09-19

Problem Statement

Design a scalable online food delivery system like Uber Eats, which enables users to:


•Discover nearby restaurants
•Browse menus and place food orders
•Track live order status (preparation to delivery)
•Communicate with restaurants/delivery partners
•Pay online or with cash
•Receive real-time notifications


The system should handle millions of users, restaurants, and delivery partners with high availability, low latency, and strong fault tolerance.

🎯 Functional Requirements:

1.User Module
•Search and discover restaurants
•Browse menus and add to cart
•Place and cancel orders
•Track orders in real time
•Rate/review restaurants and delivery
2.Restaurant Module
•Accept/reject/prepare orders
•Manage menu and availability
•Real-time order updates
3.Delivery Partner Module
•Accept delivery tasks
•Live route tracking and ETAs
•Communicate with users and restaurants
4.Order Lifecycle
•Order placed → confirmed → prepared → picked up → delivered
5.Payment System
•Online payments (UPI, cards), wallet integration
•Refunds and reconciliation
6.Notification System
•SMS, email, push notifications for order events


⚙️ Non-Functional Requirements:

•High availability (99.99%)
•Low latency (<300ms for major operations)
•Scalable to millions of users
•Real-time tracking support
•Secure payments and sensitive data handling
•Fault tolerance and retry mechanisms


🧱 Core Components:

ServiceResponsibility

API Gateway

Routes user/partner requests

User Service

User auth, profile, preferences

Restaurant Service

Menus, hours, availability

Search & Discovery

Nearby restaurants, filters

Cart & Order Service

Order placement, status, cart mgmt

Delivery Service

Delivery assignment, route tracking

Payment Service

Payments, refunds, reconciliation

Notification Service

Real-time updates (SMS/email/push)

Rating & Review Service

Post-delivery feedback

Tracking & Location Service

Geolocation of user, restaurant, and driver


📍 Key Flows:

1. Order Placement Flow:

User → Browse menu → Add to cart → Checkout

→ Payment → Order created → Restaurant notified → Delivery assigned

→ Track order (WebSocket/polling)

2. Delivery Assignment Flow:

•Find nearest available delivery partner
•Optimize assignment based on ETA, rating, traffic

3. Real-Time Tracking Flow:

•Delivery app continuously pushes GPS location
•User receives updates via WebSocket or polling

🛒 Database Design (Simplified)

Users

1pgsql 2CopyEdit 3user_id | name | location | preferences | contact_info

Restaurants

1pgsql 2CopyEdit 3restaurant_id | name | location | is_open | cuisine | rating

Menu_Items

1nginx 2CopyEdit 3item_id | restaurant_id | name | price | availability | category

Orders

1lua 2CopyEdit 3order_id | user_id | restaurant_id | status | total_amount | payment_status | timestamp

Delivery

1nginx 2CopyEdit 3delivery_id | order_id | driver_id | pickup_eta | delivery_eta | current_location


🧠 Scalability Considerations:

•Use geo-partitioning for user and restaurant data
•Redis cache for hot menus and top restaurants
•Kafka queue for order event processing (decouples services)
•Use CDNs and image optimizers for menu thumbnails
•Replicate services across regions for availability
•Use consistent hashing for real-time location tracking


🧰 Tech Stack (Suggested):

LayerTools & Tech

Backend Services

Node.js / Go / Java

Data Storage

PostgreSQL + Redis + Cassandra

Real-Time Tracking

WebSockets + MQTT

Queue

Kafka / RabbitMQ

Search

Elasticsearch for restaurant discovery

Payments

Razorpay / Stripe / PayPal

Location Services

Google Maps API / Mapbox

CDN/Image Delivery

CloudFront, Imgix


🧠 Optional Features to Extend:

•Loyalty program and discounts engine
•ETA prediction with ML
•Smart delivery zone resizing during high load
•Restaurant-side analytics dashboard
•AI-powered dish recommendations


Solution

Comments