Online Food Delivery System

Difficulty: MEDIUMCategory: LLDFrequency: 1Asked On 2025-05-03

Problem Statement

Design the Low-Level Design (LLD) of an Online Food Delivery System — similar to platforms like Swiggy, Zomato, or Uber Eats.


The system should allow customers to browse restaurants, place orders, make payments, and track deliveries in real time.


Focus should be on class design, relationships, and object interactions, not scalability or distributed systems (which would be HLD).


🧠 Functional Requirements


User Management

•Register / login users (Customers, Delivery Partners, Restaurants).
•Maintain user profile, address, and contact details.

Restaurant Management

•Restaurants can:
•Add / update / remove food items.
•Set menu, price, and availability.
•Customers can view restaurant details and menus.

Menu & Search

•Customer can search restaurants or dishes by name, cuisine, or location.
•Should display price, ratings, and estimated delivery time.

Order Management

•Customers can:
•Add items to cart.
•Place an order.
•System generates an order with a unique ID and calculates total cost.
•Restaurant receives order request and confirms it.

Payment

•Support for online payments and COD (Cash on Delivery).
•Handle payment status (pending, successful, failed).

Delivery Assignment

•Once an order is ready, assign a delivery partner based on proximity and availability.
•Delivery partner accepts and picks up the order.

Order Tracking

•Customer can track the order status:
•Order Placed → Preparing → Out for Delivery → Delivered.

Notifications

•Send notifications to customers and delivery partners (e.g., order confirmed, out for delivery).


🚫 Non-Functional Requirements


•Low latency for order updates and delivery tracking.
•Reliable order status handling (no lost updates).
•Extensible to support coupons, reviews, and loyalty points later.
•Testable with modular and clean class separation.


🧱 Suggested Classes


ClassResponsibility


User


Base class for all users (Customer, RestaurantOwner, DeliveryPartner).


Customer


Manages profile, saved addresses, cart, and orders.


Restaurant


Maintains restaurant info, menu, and order queue.


MenuItem


Represents individual dishes with price, name, and availability.


Cart


Holds selected items before placing an order.


Order


Represents a food order with details, items, customer, restaurant, delivery partner, and status.


OrderStatus (Enum)


Tracks order state (PLACED, CONFIRMED, PREPARING, OUT_FOR_DELIVERY, DELIVERED).


Payment


Handles payment initiation and verification.


DeliveryPartner


Represents a delivery person with current location and assigned orders.


DeliveryService


Assigns delivery partners to orders.


NotificationService


Sends notifications to users.


SearchService


Handles search for restaurants and menu items.


🔄 Example Flow


1.Customer browses restaurants
1 2Customer → SearchService.search("Pizza") 3→ Returns list of restaurants offering pizza
1.Customer adds items to cart
1 2Customer.addToCart(MenuItem: "Veg Pizza", qty=2)
1.Order Placement
1 2Customer.placeOrder() 3→ Order created with status = PLACED 4→ Restaurant notified
1.Restaurant confirms order
1 2Restaurant.confirmOrder(orderId) 3→ Order status = CONFIRMED → PREPARING
1.Delivery assigned
1 2DeliveryService.assignPartner(orderId) 3→ DeliveryPartner assigned based on proximity
1.Tracking
1 2Customer views order tracking: 3→ PREPARING → OUT_FOR_DELIVERY → DELIVERED


⚙️ Example Entities

1 2Customer 3 ├── id 4 ├── name 5 ├── address 6 ├── cart 7 └── orderHistory 8 9Restaurant 10 ├── id 11 ├── name 12 ├── menu: List<MenuItem> 13 └── activeOrders: List<Order> 14 15Order 16 ├── id 17 ├── customer 18 ├── restaurant 19 ├── deliveryPartner 20 ├── orderItems 21 ├── totalAmount 22 └── status


🧪 Example Input / Output


Input:

1 2Customer: Sahil 3Order: 2x Paneer Pizza from Pizza Hut 4Payment: Online

Output:

1 2Order #10234 created 3Order Status: PREPARING 4Delivery Partner: Rahul (ETA 20 mins)


🎯 Goals


Your design should:


•Use OOP principles (abstraction, encapsulation, inheritance, polymorphism).
•Ensure clear class relationships (composition, association).
•Support extensibility — new features like coupons, reviews, or scheduled orders can be added easily.
•Handle state transitions cleanly for the order lifecycle.


✅ In short:

Design an Online Food Delivery System (like Zomato/Swiggy) focusing on classes, relationships, and methods for users, orders, restaurants, and delivery tracking.

Solution

Comments