Design Restaurant Ordering (LLD)
1. Requirements
-
Functional
- Menu with categories, items, modifiers, and optional combos.
- Orders aggregate line items; kitchen receives tickets by station (grill, cold).
- Table or counter service flows; bill splitting optional extension.
-
Non-Functional
- Order state machine consistent when POS and kitchen display both update.
- Extensible pricing for happy hour and coupons without dirty flags everywhere.
-
Assumptions / Out of Scope
- Delivery marketplace routing omitted; dine-in and takeaway only.
2. Core Entities
| Entity | Responsibility | Key Attributes |
|---|---|---|
| Menu | Catalog root | categories |
| Category | Menu section | name, items |
| MenuItem | Sellable dish | name, basePrice, station |
| Modifier | Add-on | name, priceDelta |
| Order | Customer ticket | lines, status, table |
| OrderLine | Quantity line | item, modifiers, note |
| KitchenTicket | Fulfillment view | station, lines subset |
| PricingPolicy | Adjust totals | rules |
3. Class Diagram
Loading diagram…
4. State / Sequence Diagram (where relevant)
Loading diagram…
5. Design Patterns Applied
- Composite — Combo meals containing child items. Composite pattern.
- Strategy —
PricingPolicyfor discounts. Strategy pattern. - Observer — Order status pushes to waiter tablets. Observer pattern.
6. Implementation
Go
package restaurant
type MenuItem struct {
Identifier string
Name string
BasePrice int
Station string
}
type OrderLine struct {
Item MenuItem
Quantity int
Modifiers []string
}
type Order struct {
Identifier string
Lines []OrderLine
Status string
}
type OrderService struct {
Menu *Menu
}
func (service *OrderService) SubmitOrder(order Order) error { /* validate + emit tickets */ }JavaScript
class Order {
constructor({ identifier, tableId }) {
this.identifier = identifier;
this.tableId = tableId;
this.lines = [];
this.status = 'draft';
}
addLine({ menuItem, quantity, modifiers }) { /* ... */ }
}
class KitchenBoard {
constructor({ stations }) {
this.stations = stations;
}
receiveTickets(order) { /* partition lines by station */ }
}7. Concurrency / Thread Safety
- Collisions: Kitchen marks ready while cashier applies void line.
- Granularity: Optimistic locking on
Orderversion; event log for kitchen screen replay. - Go: Mutex per order id during payment capture.
8. Extensibility & Followups
- Inventory decrement hooks when order submitted per ingredient BOM.
- Reservation system linking table turn rotation.
- Edge cases: 86 item mid-order, allergy overrides, split checks across parties.
Last updated on
Spotted something unclear or wrong on this page?