Welcome to the most comprehensive Low-Level Design resource for Java developers and interview candidates!
This repository contains 15 design patterns, 30 real-world system designs, and detailed explanations of OOP principles, SOLID, and software architecture best practices.
Perfect for:
- π― SDE Interview Preparation (Amazon, Google, Microsoft, etc.)
- πΌ Software Engineers learning system design
- π Computer Science Students mastering OOP and design patterns
- π¨βπ» Developers building scalable, maintainable systems
Low-Level Design is the detailed design phase where you convert high-level architecture into:
- β Class diagrams and object relationships
- β Detailed code structures with proper abstractions
- β Design patterns for common problems
- β SOLID principles for maintainability
Why LLD matters in interviews:
- 60% of system design interviews include LLD rounds
- Tests your ability to write clean, extensible code
- Demonstrates understanding of OOP and design patterns
- Shows real-world problem-solving skills
- β Real interview questions from FAANG companies
- β Naive vs Improved solutions showing evolution
- β Pattern identification - learn when to use which pattern
- β Common pitfalls and how to avoid them
- π Comprehensive documentation for every concept
- πΉ 15 Design Patterns with real-world use cases
- π 30 Complete Systems from simple to complex
- π§© Progressive difficulty - start simple, master complex
- π UML diagrams for visual understanding
low-level-design-in-java/
βββ pom.xml
βββ README.md
β
βββ src/
β βββ main/
β β βββ java/
β β β βββ org/lld/
β β β βββ basic/
β β β βββ patterns/
β β β βββ practice/
β β β
β β βββ resources/
β β βββ docs/
β β βββ basic/
β β βββ solid.md
β β
β βββ test/java/
- π OOP Concepts - Four pillars explained
- π― SOLID Principles - With examples
- π UML Basics - Class diagrams
- π― INTERVIEW_GUIDE.md - Complete interview strategy β Must Read
- π INTERVIEW_CHEATSHEET.md - Quick reference before interview
- π¨ PATTERNS_GUIDE.md - All design patterns explained
- β‘ BEST_PRACTICES.md - Code quality guidelines
| # | Pattern Name | Description |
|---|---|---|
| 1 | Singleton | Ensure a class has only one instance and provide a global point of access to it. |
| 2 | Builder | Separates complex object construction from its representation. |
| 3 | Factory | Creates objects without exposing the instantiation logic. |
| 4 | Prototype | Create new objects by copying existing ones, reducing the cost of creation. |
| 5 | Abstract Factory | Provides an interface for creating families of related or dependent objects without specifying their concrete classes. |
| # | Pattern Name | Description |
|---|---|---|
| 1 | Decorator | Dynamically adds new behavior to objects at runtime. |
| 2 | Flyweight | Reduces memory usage by sharing common parts of object state among objects. |
| 3 | Adapter | Converts one interface into another expected by the client. |
| 4 | Proxy | Provides a surrogate or placeholder to control access to another object. |
| 5 | Facade | Provides a simplified interface to a complex subsystem. |
| # | Pattern Name | Description |
|---|---|---|
| 1 | Chain Of Responsibility | Passes a request along a chain of handlers until one of them handles it. |
| 2 | Observer | Defines a one-to-many dependency so that when one object changes state, all its dependents are notified and updated automatically. |
| 3 | Strategy | Enables selecting an algorithm's behavior at runtime by encapsulating it within a class and making it interchangeable. |
| 4 | Command | Encapsulates a request as an object, thereby allowing users to parameterize clients, delay execution, or queue and log operations. |
| 5 | State | Allows an object to change its behavior when its internal state changes, appearing as if it changed its class. |
| 6 | Template Method | Defines the skeleton of an algorithm, letting subclasses override specific steps. |
Each problem includes:
- β Naive Solution: Simple implementation showing common pitfalls
- β Improved Solution: Well-designed implementation using SOLID principles and design patterns
- β Comprehensive README: Problem statement, requirements, design considerations, and patterns used
| # | System Design Problem | Key Patterns Used |
|---|---|---|
| 1 | Car Rental System | Strategy, State, Factory |
| 2 | Parking Lot System | Singleton, Strategy |
| 3 | Vending Machine | State, Strategy |
| 4 | Snake And Ladder | Factory, Strategy |
| 5 | Online Movie Booking System | Singleton, Factory, Strategy |
| 6 | Online Hotel Booking System | Strategy, Observer, Factory |
| 7 | ATM System | State, Strategy, Command, Singleton |
| 8 | Library Management System | Strategy, Observer, Repository, Facade |
| 9 | Elevator System | State, Strategy, Observer, Command |
| 10 | Food Delivery System | Strategy, State, Observer, Factory |
| 11 | Ride-Sharing System | Strategy, State, Observer, Factory, Singleton |
| 12 | Queue Management System | Singleton, Strategy, Observer, State |
| 13 | Cache Management System | Strategy, Factory, Decorator, Builder |
| 14 | Rate Limiter | Strategy, Factory, Builder |
| 15 | Matching Engine | Strategy, Observer |
| 16 | Wallet / Ledger System | Command, Observer, Builder |
| 17 | Pub/Sub System (Mini-Kafka) | Observer, Strategy, Singleton |
| 18 | Task Scheduler | Strategy, Command, Observer, Singleton |
| 19 | E-commerce Cart System | Strategy, Decorator, Factory, Builder |
| 20 | Logger System | Strategy, Observer, Factory, Chain of Responsibility |
| 21 | Notification System | Strategy, Factory, Observer, Command |
| 22 | URL Shortener (TinyURL) | Strategy, Factory, Repository |
| 23 | Chat Application | Observer, Strategy, State, Repository |
| 24 | Leaderboard System | Strategy, Factory, Observer |
| 25 | Calendar/Event Booking System | Strategy, Factory, Observer, State, Repository |
| 26 | Expense Sharing System (Splitwise-like) | Strategy, Factory, Graph Algorithm |
| 27 | Tic-Tac-Toe Game | Strategy, State, Factory, Observer |
| 28 | Stock Trading System | Strategy, State, Observer, Singleton, Factory |
| 29 | Social Media Feed System | Strategy, Observer, Factory, Singleton |
| 30 | Online Auction System | State, Observer, Strategy, Singleton |
- Java 17 or higher
- Maven (for building)
- IDE (IntelliJ IDEA, Eclipse, or VS Code recommended)
- Clone the repository
git clone https://github.com/your-username/low-level-design-in-java.git
cd low-level-design-in-java- Build the project
mvn clean install- Run examples
# Run a specific pattern example
mvn exec:java -Dexec.mainClass="org.lld.patterns.creational.singleton.Main"
# Run a practice problem
mvn exec:java -Dexec.mainClass="org.lld.practice.design_parking_lot_system.improved_solution.Main"src/main/java/org/lld/
βββ patterns/ # Design pattern implementations
β βββ creational/ # Factory, Singleton, Builder, etc.
β βββ structural/ # Adapter, Decorator, Proxy, etc.
β βββ behavioural/ # Observer, Strategy, State, etc.
β
βββ practice/ # Real-world system designs
β βββ design_parking_lot_system/
β βββ design_atm_system/
β βββ ...
β
βββ resources/docs/ # Documentation
βββ basic/ # OOP, SOLID, UML guides
- Read OOP Concepts
- Understand SOLID Principles
- Start with simple patterns:
- Try simple problems:
- Study structural patterns (Decorator, Adapter, Flyweight)
- Master behavioral patterns (Observer, State, Command)
- Practice medium problems:
- Combine multiple patterns in complex systems
- Practice with real-world systems:
- Review INTERVIEW_GUIDE.md for tips
- Design a Parking Lot System β Most Common
- Design an Elevator System
- Design a Library Management System
- Design a Food Delivery App (Uber Eats)
- Design a Ride-Sharing App (Uber)
- Design a Hotel Booking System
- Design a Movie Ticket Booking System
- Design a Vending Machine
- Design an ATM
- Design a Car Rental System
- β Requirements gathering - Ask clarifying questions
- β Core entities identification - Find main objects
- β Relationships - Understand interactions
- β Design patterns usage - Apply appropriately
- β SOLID principles - Write clean code
- β Extensibility - Design for future changes
- β Trade-offs - Discuss pros/cons of your decisions
- First: Try solving the problem yourself (30 mins)
- Then: Look at the naive solution to see common mistakes
- Finally: Study the improved solution to learn best practices
- Practice: Implement it from scratch without looking
- Explain: Practice explaining your design out loud
See INTERVIEW_GUIDE.md for detailed tips and strategies.
| Pattern | Use When | Example From Problems |
|---|---|---|
| Singleton | Need exactly one instance | ParkingLot, BankingService |
| Factory | Object creation varies | Vehicle types, User types |
| Builder | Complex object construction | Building Car with options |
| Strategy | Algorithm varies at runtime | Pricing, Matching, Payment |
| State | Behavior changes with state | Order lifecycle, Ride status |
| Observer | One-to-many notifications | Order updates, Ride tracking |
| Decorator | Add responsibilities dynamically | Coffee with add-ons |
| Adapter | Interface compatibility | Legacy system integration |
| Command | Encapsulate requests | Transaction operations |
| Repository | Data access abstraction | BookCatalog, MemberRegistry |
- Design Patterns Book - Gang of Four
- Effective Java - Joshua Bloch
- Clean Code - Robert Martin
- SOLID Principles
- Refactoring Guru - Visual pattern guide
We welcome contributions! Here's how:
- Fork the repository
- Create a feature branch (
git checkout -b feature/new-pattern) - Commit your changes (
git commit -am 'Add new pattern') - Push to the branch (
git push origin feature/new-pattern) - Create a Pull Request
- π Add new design patterns (Proxy, Bridge, Composite)
- π Improve documentation and examples
- π Fix bugs or improve existing solutions
- π¨ Add UML diagrams
- β Add unit tests
- π Add translations
- Design Patterns: 15 implemented
- Practice Problems: 30 complete systems
- Code Examples: 350+ files
- Lines of Code: 15000+
- Documentation: Comprehensive READMEs for each topic
If this repository helped you:
- β Star the repository
- π Fork it for your own learning
- π’ Share with friends and colleagues
- π¬ Feedback - open an issue with suggestions
- Issues: GitHub Issues
- Discussions: GitHub Discussions
This project is licensed under the MIT License - see the LICENSE file for details.
Created with β€οΈ for the developer community.
Special thanks to:
- Gang of Four for Design Patterns
- Robert Martin for SOLID principles
- All contributors and supporters
Remember: Good design is not about following rules blindly, but understanding trade-offs and making informed decisions!
Happy Learning and Good Luck with your interviews! π