Introduction to Low Level Design (LLD)
1. What is Low-Level Design (LLD)?
Definition
ow-LevelDesign(LLD)istheprocessofdesigningtheinternalstructureofanapplicationby
L
identifying:
● lasses and objects
C
● Relationships between them
● Responsibilities of each component
● Data flow between components
● How algorithms and data structures integrate into the system
LD focuses on how the code of a system should be structured so that it is scalable,
L
maintainable, and reusable.
In simple terms:
LLD defines the skeleton of your application.
2. Relationship Between DSA and LLD
nderstandingtherelationshipbetweenDataStructures&Algorithms(DSA)andLowLevel
U
Design (LLD)is crucial.
DSA
DSA focuses onsolving isolated computational problems.
Examples:
● inary Search
B
● Quicksort
● Dijkstra’s Algorithm
● BFS / DFS
● Heaps / Priority Queues
● Hash Tables
Example Problem:
Find the shortest path between two nodes in a graph.
DSA gives thealgorithmic solution.
LLD
LLD focuses onwhere and how these algorithms are used inside a system.
It answers questions like:
● hat classes should exist?
W
● Which object will execute the algorithm?
● How do objects communicate?
● How does the system remain maintainable when new features are added?
xample:
E
Instead of just implementingDijkstra’s algorithm, LLD asks:
W
● hich class owns the routing logic?
● How do Rider and Driver interact?
● Which component calls the algorithm?
Key Insight
Concept Focus
DSA Solving algorithmic problems
LLD Structuring application code
HLD Designing system architecture
If DSA is the brain, LLD is the skeleton of your application.
. Illustrative Story: Two Approaches to
3
Building “FastRide”
Consider building a ride-booking application calledFastRide(similar to Uber/Ola).
Two engineers approach the problem differently.
Approach 1: DSA-First Approach (A)
A directly focuses on algorithms.
Step 1: Problem Decomposition
He models the city as a graph.
Intersections → Nodes
●
● Roads → Edges
Then applies algorithms:
D
● ijkstra’s Algorithm→ Shortest path calculation
● Min Heap (Priority Queue)→ Find closest driver
Example:
None
City Graph
A ---- B
|
|
C ---- D
Use Dijkstra to compute:
None
Shortest Route:
Rider → Driver
Step 2: Implementation
He builds:
G
● raph representation
● Path finding algorithm
● Driver matching using priority queue
Problems with this Approach
This approach solvesalgorithmic problems, but ignores system design.
Major gaps include:
1. No Entity Identification
Important system objects are missing:
● ser
U
● Rider
● Driver
● Location
● Trip
● Notification
● Payment
2. Missing System Responsibilities
Questions unanswered:
W
● ho creates a ride?
● Who assigns drivers?
● Who sends notifications?
3. Security Issues
Sensitive information not handled properly:
P
● hone number exposure
● Payment details
● User authentication
4. No Scalability Design
System cannot easily support:
M
● illions of users
● Thousands of drivers
● Multiple cities
5. No Integration Points
External services ignored:
P
● ayment Gateway
● Notification Service
● Maps Service
Approach 2: LLD-First Approach (B)
B focuses first onobject design.
Step 1: Identify Core Entities
He identifies the main components of the system.
Possible entities:
● ser
U
● Rider
● Driver
● Location
● Ride
● Payment
● NotificationService
● MatchingService
Example:
None
User
├── Rider
└── Driver
Step 2: Define Relationships
How objects interact with each other.
Example:
None
Rider → requests → Ride
Ride → assigned to → Driver
Ride → contains → Location
Ride → triggers → Payment
Ride → triggers → Notification
Step 3: Define Responsibilities
Each class has a clear role.
Example:
Class Responsibility
Rider Request ride
Driver Accept ride
RideService Manage ride lifecycle
MatchingService Find nearest driver
NotificationService Send updates
PaymentGateway Process payments
Step 4: Consider Non-Functional Requirements
Security
Protect sensitive data.
Examples:
M
● ask phone numbers
● Encrypt payment data
● Secure authentication
Scalability
Design code so that the system can scale easily.
Examples:
M
● odular services
● Stateless components
● Efficient algorithms
Extensibility
New features should be easy to add.
Example:
Future features may include:
R
● ide scheduling
● Surge pricing
● Multi-stop rides
Proper LLD makes this easy.
Step 5: Apply DSA Inside the Design
Now algorithms are appliedwithin the system structure.
Examples:
Feature Algorithm / Data Structure
Driver matching Min Heap
Shortest route Dijkstra
Ride history lookup HashMap
Nearby drivers Spatial indexing
Now the system has both:
● Good algorithms
● Clean architecture
4. Core LLD Design Goals
Good Low Level Design focuses on the following principles.
1. Scalability
The system should handlegrowth in users and data.
Example:
None
10 users → 10 million users
Design should support scaling without major rewrites.
Strategies include:
M
● odular components
● Stateless services
● Efficient data structures
2. Maintainability
Code should be easy to:
U
● nderstand
● Debug
● Modify
Bad design example:
None
One giant class handling everything.
Good design:
None
Separate classes with clear responsibilities.
3. Reusability
Components should bereusable across systems.
Example:
ANotificationServicecan be reused in:
● ber
U
● Zomato
● Swiggy
● Amazon delivery
Reusable components reduce development time.
4. Loose Coupling
Components shouldnot depend heavily on each other.
Example:
Bad design:
None
RideService directly depends on SMS provider
Better design:
None
RideService → NotificationService → SMS Provider
This allows changing providers easily.
5. High Cohesion
Each class should haveone clear responsibility.
Example:
Bad design:
None
UserService handles login + payment + rides
Good design:
None
AuthService
PaymentService
RideService
5. What LLD Is NOT (Difference from HLD)
Low Level Design should not be confused withHigh Level Design.
High Level Design (HLD)
HLD focuses onsystem architecture and infrastructure.
Examples include:
● Technology stack
Java / NodeJS / Python
○
● Frameworks
○ Spring Boot / Django
● Database selection
○ SQL vs NoSQL
● Infrastructure
○ AWS / GCP / Azure
● Load balancing
● Microservices vs Monolith
● Cost optimization
LLD Focuses On
Inside the application:
● lass design
C
● Object interactions
● Method responsibilities
● Design patterns
● UML diagrams
● Code structure
Simple Comparison
Aspect LLD HLD
Focus Code structure System architecture
Level Class/Object level System level
Tools UML, Design Patterns Architecture diagrams
Concern Maintainable code Scalable infrastructure
6. Summary
Low Level Design bridges the gap betweenalgorithms and real software systems.
Key ideas:
D
● SAsolves algorithmic problems.
● LLDorganizes code using classes and objects.
● HLDdesigns system architecture.
A strong engineer must understandall three layers.
SA = Brain
D
LLD = Skeleton
HLD = Infrastructure
7. Key Line to Remember
"If DSA is the brain, LLD is the skeleton of your application."