Design Coffee Vending Machine
| Difficulty: Easy | Source: awesome-low-level-design |
Requirements
- Support espresso, cappuccino, latte
- Each type has price and recipe
- Display menu with prices
- Choose coffee and submit payment
- Dispense coffee and return change
- Track ingredient inventory
- Handle concurrent requests
Class Diagram

Classes, Interfaces and Enumerations
| Class/Interface | Description |
|---|---|
| Coffee | name, price, recipe (ingredient-to-quantity map) |
| Ingredient | name, quantity; synchronized update method |
| Payment | amount paid |
| CoffeeMachine | Singleton; menu, ingredients, dispensing |
Design Patterns Used
| Pattern | Application |
|---|---|
| Singleton | CoffeeMachine has a single instance managing all operations |
Code Implementations
| Language | Source Code |
|---|---|
| Java | View on GitHub |
| Python | View on GitHub |
| C++ | View on GitHub |
| C# | View on GitHub |
| Go | View on GitHub |