Loading LLD design...
Design an object-oriented coffee vending machine that manages a catalogue of beverage recipes (espresso, latte, cappuccino, etc.), tracks ingredient inventory, and brews drinks on demand.
The system should support drink customisation (extra sugar, less milk), dynamically display only available beverages based on current stock levels, and handle the full workflow from selection through payment to dispensing.
Select a beverage
User chooses from a menu of available coffee drinks (espresso, latte, cappuccino, etc.)
Customise a drink
User adjusts ingredient quantities — extra sugar, less milk, add cream
Brew and dispense
Machine prepares the drink by consuming ingredients per the recipe and dispensing it
Check ingredient availability
Before brewing, verify all ingredients are sufficiently stocked
Display available menu
Dynamically show only beverages that can be made with current stock
Refill ingredients
Admin restocks ingredients when they run low
Payment handling
Accept payment and return change before dispensing
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.