A hands-on collection of Low-Level Design (LLD) / Object-Oriented Design problems implemented in Spring Boot and Lombok and structured for interview preparation.
The repository focuses on designing maintainable, extensible and testable systems using SOLID principles, design patterns, clean separation of responsibilities, concurrency concepts, and practical domain modeling.
urlGitHub Repositoryhttps://github.com/ShyrenMore/low-level-design-prep
Project Key Concepts
ATM Machine State pattern, cash dispensing, account operations, ATM states
Digital Wallet Strategy, Factory, concurrency, transactions, idempotency
Elevator System Scheduling, state management, request handling
Hotel Management Booking, room management, availability, reservations
Logging Chain of Responsibility, log Framework levels, appenders, formatting
Music Streaming Playback state, Strategy, caching, Platform streaming, playlists
Parking Lot Strategy, parking allocation, vehicle/spot modeling
Pub/Sub Observer-style messaging, publishers, subscribers, topics
Ride Booking State, Strategy, matching, notifications, concurrency
Task Management Task lifecycle, assignment, filtering, extensibility
Traffic Signal State pattern, signal transitions, System scheduling
Vending Machine State pattern, inventory, payments, change calculation
The implementations emphasize:
- Encapsulation
- Abstraction
- Inheritance where appropriate
- Polymorphism
- Composition over unnecessary inheritance
- Interface-driven design
The goal is to model behavior, not just create a collection of data classes.
Classes should have one clear reason to change.
Example:
Controller
↓
Service
↓
Repository
rather than putting all business logic into one class.
Systems should be open for extension but closed for modification.
Typical examples:
PaymentStrategy
PricingStrategy
RecommendationStrategy
MatchingStrategy
New behavior can be introduced by adding implementations instead of modifying existing logic.
Implementations of an abstraction should be usable wherever that abstraction is expected.
Prefer focused interfaces over large interfaces containing unrelated operations.
High-level business logic should depend on abstractions rather than concrete implementations.
The repository intentionally uses common interview patterns where they naturally fit.
Use when an algorithm or business rule can vary.
Service
↓
Strategy
├── Implementation A
├── Implementation B
└── Implementation C
Examples:
- Recommendation strategies
- Matching strategies
- Pricing/allocation strategies
Use when an object's behavior changes based on its current state.
Object
↓
Current State
├── State A
├── State B
└── State C
Examples:
- ATM
- Vending machine
- Traffic signal
- Ride lifecycle
- Playback lifecycle
Use when object creation involves choosing between different implementations/types.
Useful when:
Input
↓
Factory
↓
Correct implementation
Useful when one event needs to be delivered to multiple independent consumers.
Publisher
↓
Topic
↙ ↓ ↘
S1 S2 S3
Useful when a request should pass through a sequence of handlers.
A classic example is the logging framework:
DEBUG → INFO → WARN → ERROR
Most projects follow a layered structure similar to:
Client / Simulator
│
▼
Controller
│
▼
Service
│
┌──────────┴──────────┐
▼ ▼
Strategy / State Repository
│ │
▼ ▼
Business Logic Persistence
The exact structure varies by problem because LLD should be driven by requirements rather than forcing every problem into the same architecture.
For each LLD problem, the recommended design process is:
Separate:
Functional requirements
+
Non-functional requirements
Ask:
- What operations are required?
- Who are the actors?
- What are the important constraints?
- What can change independently?
- What concurrency is possible?
Start with nouns from the requirements.
Example:
Parking Lot
→ Vehicle
→ Parking Spot
→ Ticket
→ Floor
→ Payment
But do not blindly convert every noun into a class.
Ask:
"Who should own this behavior?"
Avoid an anemic domain model where all behavior ends up inside one giant service.
This is often the key to selecting a design pattern.
Ask:
"What part of this system is likely to change independently?"
If an algorithm changes:
Strategy
If behavior changes with state:
State
If object creation varies:
Factory
If events need multiple consumers:
Observer / Pub-Sub
Introduce interfaces around genuine variation points.
Avoid creating interfaces just for the sake of having interfaces.
Think about:
- Invalid input
- Missing entities
- Empty collections
- Duplicate operations
- Concurrent requests
- Resource exhaustion
- State transition failures
- Retry behavior
- Authorization
A good LLD interview answer should explain how the in-memory design would evolve.
In-memory repository
↓
Database
JVM-local cache
↓
Redis / distributed cache / CDN
Synchronous operation
↓
Event-driven asynchronous processing
Several projects involve concurrent operations.
Important concepts to understand:
ConcurrentHashMapcan protect individual collection operations.
But:
A thread-safe collection does not automatically make a multi-step business operation atomic.
For example:
read
→ modify
→ write
may still require synchronization or an atomic operation.
Possible tools:
synchronized
ReentrantLock
ReadWriteLock
Use explicit locks when the critical section and lock lifecycle need more control.
Always release explicit locks in a finally block.
A JVM-local lock only protects one application instance.
With:
Instance A
Instance B
Instance C
a lock in A does not automatically protect state accessed by B.
Production alternatives include:
- Optimistic locking
- Database row/version locking
- Distributed coordination
- Redis-based locking where appropriate
A recurring concept across several projects is modeling an entity as a state machine.
Example:
┌─────────┐
│ CREATED │
└────┬────┘
│
▼
┌─────────┐
│ ACTIVE │
└────┬────┘
│
▼
┌─────────┐
│ DONE │
└─────────┘
Before implementing a state-based system, explicitly identify:
- Valid states
- Valid transitions
- Events causing transitions
- Invalid transitions
- Behavior associated with each state
This is especially useful for:
- ATM
- Vending Machine
- Ride Booking
- Traffic Signals
- Music Playback
Repositories abstract persistence.
Instead of:
service → HashMapprefer:
service
↓
Repository interface
↓
In-memory implementation
This allows the implementation to evolve:
InMemoryRepository
↓
DatabaseRepository
↓
Distributed storage
without rewriting business logic.
When a system repeatedly accesses expensive data:
Request
↓
Cache
├── HIT → return
└── MISS
↓
Storage
↓
Cache
↓
Return
Always discuss:
- Cache key
- TTL
- Eviction
- Cache invalidation
- Consistency
- Maximum size
- What happens when cache is unavailable
For each project, be able to answer these questions without looking at the code.
What does the system need to do?
What are the important objects and relationships?
Why does each class exist?
Which design pattern did you use and why?
What other design could work?
How would you add a new requirement?
What happens if two requests modify the same object simultaneously?
How would you replace the in-memory repository with a database?
What changes when the application runs on multiple instances?
What happens when a dependency or operation fails?
Before an interview, revise these concepts across the repository:
- Composition vs inheritance
- Interface vs abstract class
- Encapsulation
- Polymorphism
- Immutability
- SRP
- OCP
- LSP
- ISP
- DIP
- Strategy
- State
- Factory
- Observer
- Chain of Responsibility
- Builder
- Singleton --- and when not to use it
- synchronized
- ReentrantLock
- ConcurrentHashMap
- Atomic operations
- Race conditions
- Deadlocks
- Optimistic locking
- Service layer
- Repository layer
- Dependency Injection
- Event-driven architecture
- Caching
- Database persistence
When given a new LLD problem, use this sequence:
1. Clarify requirements
↓
2. Identify actors
↓
3. Identify core entities
↓
4. Define relationships
↓
5. Define important behaviors
↓
6. Identify variation points
↓
7. Select design patterns
↓
8. Define interfaces
↓
9. Implement core flow
↓
10. Handle edge cases
↓
11. Discuss concurrency
↓
12. Discuss extensibility
↓
13. Discuss production scaling
This prevents jumping directly into writing classes.
A good design should be:
- Easy to understand
- Easy to extend
- Easy to test
- Loosely coupled
- Highly cohesive
- Explicit about responsibilities
- Safe under expected concurrency
- Reasonable to evolve into a production system
Avoid:
- God classes
- Huge
if/elseblocks for every future behavior - Excessive inheritance
- Unnecessary interfaces
- Global mutable state
- Business logic inside controllers
- Persistence logic inside domain/service classes
- Premature abstraction
Focus on:
- State transitions
- Cash withdrawal
- Authentication
- Cash denomination handling
- Account interaction
Key interview theme:
State-dependent behavior.
Focus on:
- Wallet/account modeling
- Transactions
- Transfer flow
- Idempotency
- Concurrency
- Strategy/Factory-style extensibility
Key interview theme:
Correctness of financial operations under concurrency and retries.
Focus on:
- Elevator state
- Floor requests
- Request scheduling
- Direction
- Multiple elevators
Key interview theme:
Scheduling and extensible allocation logic.
Focus on:
- Rooms
- Reservations
- Availability
- Guests
- Booking lifecycle
Key interview theme:
Resource allocation and reservation consistency.
Focus on:
- Log levels
- Handlers/appenders
- Formatting
- Multiple output destinations
- Chain of Responsibility
Key interview theme:
Extensible processing pipelines.
Focus on:
- Playback sessions
- Queues
- Shuffle/repeat
- Listening history
- Streaming
- Chunk cache
- Recommendations
- Playlists
Key interview theme:
Combining state management, Strategy Pattern, caching, streaming and concurrency.
Focus on:
- Vehicle types
- Spot allocation
- Tickets
- Pricing
- Availability
Key interview theme:
Allocation strategies and domain modeling.
Focus on:
- Topics
- Publishers
- Subscribers
- Message delivery
- Decoupling
Key interview theme:
Event-driven design and fan-out.
Focus on:
- Ride lifecycle
- Driver matching
- Acceptance/rejection
- Pricing
- Notifications
- Concurrency
Key interview theme:
State + Strategy + concurrent workflows.
Focus on:
- Tasks
- Users
- Assignment
- Status
- Priorities
- Filtering
Key interview theme:
Clean domain modeling and extensible business rules.
Focus on:
- Signal states
- Transitions
- Timing
- Intersections
Key interview theme:
State Machine design.
Focus on:
- Inventory
- Payment
- Change
- Product selection
- State transitions
Key interview theme:
Classic State Pattern problem.
This repository is intended as a practice ground, not a collection of production-ready distributed systems.
The implementations prioritize:
Clarity
+
Object-oriented design
+
Pattern usage
+
Interview discussion
over introducing unnecessary infrastructure.
For interviews, the important skill is being able to explain:
Why this design? What changes if the requirements change? What breaks under concurrency? How would you evolve it for production?
Before an LLD interview, make sure you can explain:
☐ Requirements
☐ Core entities
☐ Relationships
☐ Class responsibilities
☐ Interfaces
☐ SOLID principles
☐ Design patterns
☐ Main happy path
☐ Edge cases
☐ Error handling
☐ Concurrency
☐ Thread safety
☐ Persistence abstraction
☐ Caching
☐ Extensibility
☐ Scalability
☐ Production evolution
When you see an LLD problem, think:
Requirements
↓
Entities
↓
Responsibilities
↓
Relationships
↓
Behavior
↓
What changes?
↓
Design Pattern
↓
Interfaces
↓
Concurrency
↓
Persistence
↓
Scalability
Don't start with:
"Which design pattern should I use?"
Start with:
"What behavior is changing, and which object should own it?"
The pattern should emerge from the design.
Shyren More
This repository is a personal collection of LLD practice implementations focused on preparing for software engineering interviews.
Star/fork the repo if you find the content helpful