0% found this document useful (0 votes)
6 views12 pages

Introduction

Low-Level Design (LLD) is the process of structuring an application's internal components, focusing on classes, relationships, responsibilities, and data flow to ensure scalability, maintainability, and reusability. It differs from Data Structures and Algorithms (DSA), which solve computational problems, by emphasizing how these algorithms are integrated within the system. LLD is essential for creating a well-organized codebase that supports future growth and feature additions.

Uploaded by

johnytensa
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views12 pages

Introduction

Low-Level Design (LLD) is the process of structuring an application's internal components, focusing on classes, relationships, responsibilities, and data flow to ensure scalability, maintainability, and reusability. It differs from Data Structures and Algorithms (DSA), which solve computational problems, by emphasizing how these algorithms are integrated within the system. LLD is essential for creating a well-organized codebase that supports future growth and feature additions.

Uploaded by

johnytensa
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

​Introduction to Low Level Design (LLD)​

​1. What is Low-Level Design (LLD)?​


​Definition​

​ ow-Level​​Design​​(LLD)​​is​​the​​process​​of​​designing​​the​​internal​​structure​​of​​an​​application​​by​
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​


​ nderstanding​​the​​relationship​​between​​Data​​Structures​​&​​Algorithms​​(DSA)​​and​​Low​​Level​
U
​Design (LLD)​​is crucial.​

​DSA​

​DSA focuses on​​solving 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 the​​algorithmic solution​​.​

​LLD​

​LLD focuses on​​where 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 implementing​​Dijkstra’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 called​​FastRide​​(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.​

​ ​ I​ntersections → 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 solves​​algorithmic 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 on​​object 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 applied​​within 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 handle​​growth 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 be​​reusable across systems​​.​

​Example:​

​A​​NotificationService​​can be reused in:​

​​
● ​ ber​
U
​●​ ​Zomato​
​●​ ​Swiggy​
​●​ ​Amazon delivery​

​Reusable components reduce development time.​

​4. Loose Coupling​


​Components should​​not 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 have​​one 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 with​​High Level Design​​.​

​High Level Design (HLD)​

​HLD focuses on​​system 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 between​​algorithms and real software systems​​.​

​Key ideas:​
​​ D
● ​ SA​​solves algorithmic problems.​
​●​ ​LLD​​organizes code using classes and objects.​
​●​ ​HLD​​designs system architecture.​

​A strong engineer must understand​​all 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."​

You might also like