Loading LLD design...
Design an object-oriented food delivery platform (like Swiggy) with customer/restaurant/delivery partner registration, restaurant menu management with food type (Veg/Non-Veg/Vegan) and availability toggle, restaurant search by keyword/cuisine/distance, a cart enforcing a single-restaurant policy, order placement with full pricing breakdown (item total + distance-based delivery fee + ₹2 platform fee + 5% GST − coupon discount + tip), delivery partner assignment using the Strategy pattern (Nearest Partner / Highest-Rated Partner), and a 7-step order lifecycle.
The cart ensures all items come from a single restaurant. Orders compute delivery fee based on Haversine distance (₹15 for ≤2 km up to ₹60 for >10 km). Cancellation is allowed only before the delivery partner picks up the food. Delivery partners cycle through OFFLINE → AVAILABLE → ASSIGNED → PICKING_UP → EN_ROUTE → AVAILABLE. A coupon system supports flat and percentage discounts with min-order, max-cap, and usage-limit validation.
Customer / restaurant / delivery partner registration
Customers register with addresses; restaurants with location, cuisines, and menu; delivery partners with vehicle type
Restaurant menu management
Add/remove menu items with food type (Veg/Non-Veg/Vegan), price, cuisine; toggle item availability; set restaurant status (Open/Closed/Busy)
Search and browse restaurants
Search by keyword, cuisine, distance from user; filter by veg-only; sort by rating/distance
Cart (single-restaurant policy)
Add items to cart enforcing single-restaurant constraint; remove/update quantity; special instructions
Place order (checkout)
Validate restaurant open + can accept + items available; create order with pricing (item total + delivery fee + ₹2 platform fee + 5% GST − discount + tip)
Delivery partner assignment
Strategy pattern: assign nearest available partner or highest-rated partner within range
Order lifecycle
PLACED → CONFIRMED → PREPARING → READY_FOR_PICKUP → PICKED_UP → OUT_FOR_DELIVERY → DELIVERED
Order cancellation
Cancel only before PICKED_UP; restore restaurant capacity; release delivery partner
Rating and coupon system
Rate restaurant and delivery partner after delivery; promo coupons with flat/percentage discount, min order, max cap, usage limits
Before diving into code, clarify the use cases and edge cases. Understanding the problem deeply leads to better class design.
Identify the primary actions users will perform. For a parking lot: park vehicle, exit vehicle, check availability. Each becomes a method.
Who interacts with the system? Customers, admins, automated systems? Each actor type may need different interfaces.
What are the limits? Max vehicles, supported vehicle types, payment methods. Constraints drive your data structures.
What happens on overflow? Concurrent access? Payment failures? Thinking about edge cases reveals hidden complexity.