Design a Dominos delivery system

Difficulty: MEDIUMCategory: HLDFrequency: 1Asked On 2019-12-17

Problem Statement

Design a pizza ordering and delivery system similar to Domino’s that allows customers to place orders online or in-store, tracks order preparation and delivery, and manages kitchen and delivery staff operations.


The focus should be on object-oriented design, classes, services, and interactions rather than UI or physical hardware.


Functional Requirements (FR)


1.User Management
•Customers can register/login.
•Maintain customer profile (name, address, saved payment methods, order history).
2.Menu Management
•Display available pizzas, sides, drinks, and customizations (size, crust, toppings).
•Allow dynamic pricing (offers, discounts, combos).
3.Order Management
•Place new orders (pickup or delivery).
•Customize pizzas (size, crust, toppings).
•Track order status → Placed → In Kitchen → Out for Delivery → Delivered.
•Cancel or modify order (before preparation starts).
4.Kitchen Management
•Queue orders for preparation.
•Assign to chefs/cooks for preparation.
•Update order readiness.
5.Delivery Management
•Assign delivery agents based on location & availability.
•Track delivery in real time.
•Mark order as delivered.
6.Payment Management
•Support cash, card, wallets, and UPI.
•Handle refunds for canceled or failed orders.
7.Notifications
•Notify customers about order updates (SMS, push notifications, email).
•Notify delivery agents of new assignments.


Non-Functional Requirements (NFR)


•Scalability – Handle thousands of orders per second across multiple cities.
•Low Latency – Real-time updates for order tracking.
•Reliability – No order should get lost between kitchen and delivery.
•Extensibility – Support new items (burgers, desserts) or delivery models (dine-in, takeaway).
•Security – Secure payments and personal data storage.


Core Entities & Attributes


Class Key Attributes / Methods

User (Customer) userId, name, address, contactInfo, orderHistory

MenuItem itemId, name, category (pizza/drink/side), price, availableToppings

Order orderId, customerId, items[], totalAmount, status, paymentId, deliveryType

OrderItem itemId, size, crust, toppings[], quantity

Payment paymentId, amount, method, status, timestamp

Kitchen orderQueue[], assignOrder(orderId), markReady(orderId)

DeliveryAgent agentId, name, currentLocation, availability, assignedOrders[]

DeliveryService assignAgent(orderId), updateDeliveryStatus(orderId, status)

NotificationService sendUpdate(userId, message)


APIs / Operations


Customer APIs


•viewMenu()
•placeOrder(customerId, items[], payment)
•trackOrder(orderId)
•cancelOrder(orderId)


Kitchen APIs


•getPendingOrders()
•updateOrderStatus(orderId, status)


Delivery APIs


•assignDelivery(orderId, agentId)
•updateDeliveryLocation(orderId, location)
•markDelivered(orderId)


Admin APIs


•addMenuItem(item)
•updatePrice(itemId, price)
•getSalesReport(timePeriod)


Design Considerations


1.Order Workflow
•Order → Payment Validation → Kitchen Queue → Preparation → Delivery Assignment → Delivery.
2.Concurrency Handling
•Multiple users placing orders simultaneously.
•Multiple delivery agents being assigned dynamically.
3.Design Patterns
•Observer → Notify users about order updates.
•Factory → Create pizza objects with different customizations.
•Strategy → Payment methods (cash, card, wallet, UPI).
4.Scalability
•Shard orders by region.
•Separate services: OrderService, KitchenService, DeliveryService, PaymentService.


✅ This LLD problem tests:


•End-to-end modeling of real-world systems (orders, kitchen, delivery)
•Class design, service design, and API structure
•Concurrency and extensibility considerations


Solution

Comments