High-Level Design (HLD) vs Low-Level Design (LLD) in System Design
In system design interviews and real-world projects, two important concepts are often discussed: High-Level Design (HLD) and Low-Level Design (LLD). Both are essential, but they serve different purposes.
This tutorial explains them in simple terms, compares them side by side, and walks through one complete example: the HLD of an online shopping application and the LLD of its Order Service, with a class diagram, a sequence diagram and a database schema.
1. What Is High-Level Design (HLD)?
High-Level Design focuses on the big picture of the system. It explains what components exist and how they interact, without going into coding or implementation details.
Key points of HLD
- Shows the overall system architecture.
- Identifies the major components and services.
- Explains the data flow between components.
- Records technology choices, such as databases, caches and message queues.
- Covers scalability, availability and reliability.
HLD answers the question: “How does the system work as a whole?”
2. What Is Low-Level Design (LLD)?
Low-Level Design focuses on detailed implementation. It explains how each component is built internally, and is much closer to actual coding.
Key points of LLD
- Class diagrams and object relationships.
- Method names and responsibilities.
- Database table structure.
- Design patterns used.
- Error handling and validations.
LLD answers the question: “How exactly will this be implemented?”
3. HLD vs LLD: Quick Comparison
| Aspect | High-Level Design (HLD) | Low-Level Design (LLD) |
|---|---|---|
| Focus | Overall system structure | Detailed implementation |
| Main question | What are we building? | How exactly do we build it? |
| Level | Abstract | Detailed |
| Scope | The whole system | One component or service at a time |
| Audience | Architects, stakeholders, team leads | Developers and testers |
| Includes code? | No | Yes, or very close to code |
| Design diagrams | Architecture and data flow diagrams | Class, sequence and entity-relationship diagrams |
| Decisions made | Services, databases, caches, queues, protocols | Classes, methods, tables, indexes, patterns |
| When it is done | First, right after requirements | After the HLD is agreed |
4. Where HLD and LLD Fit in the Design Process
Feedback flows back up as well: if writing the LLD shows that a component is doing too much, you may split it in the HLD. See System Design Process and Methodologies for the full process.
5. Non-Functional Requirements and Capacity Estimation
A good HLD is shaped as much by how well the system must work as by what it must do. These quality targets are called non-functional requirements:
- Scalability: how many users and requests the system must handle, now and in future.
- Availability: how much downtime is acceptable, for example 99.9% uptime, which allows about 8.8 hours of downtime per year.
- Latency: how fast responses must be, for example "product pages load in under 200 ms".
- Consistency: whether every user must always see the very latest data, or whether a short delay is acceptable.
- Security and compliance: how data is protected and which rules apply, such as storing card data safely.
The HLD then uses a quick capacity estimate to choose the right building blocks. A rough calculation for the shop is enough:
Daily active users : 1,000,000
Product page views / user : 10 per day -> 10,000,000 views per day
Average read traffic : 10,000,000 / 86,400 s = about 116 requests/second
Peak traffic (10x average): about 1,160 requests/second
Orders per day : 50,000 -> about 0.6 orders/second (peak ~6/s)
Storage per order : about 2 KB -> 100 MB per day, about 36 GB per year
These numbers lead straight to HLD decisions: reads far outnumber writes, so the Product Catalog gets a cache; peak traffic needs several servers behind a load balancer; and order storage grows slowly enough for a single relational database to cope for years. None of this needs class names; that detail comes later, in the LLD.
6. HLD Example: Online Shopping Application
For an online shopping application, the HLD shows these building blocks:
| Component | Responsibility |
|---|---|
| Load Balancer | Spreads traffic across servers |
| API Gateway | Single entry point; routing and authentication |
| User Service | Accounts, login and profiles |
| Product Catalog Service | Products and prices, with a cache for fast reads |
| Order Service | Creates and tracks orders |
| Payment Service | Talks to the external payment gateway |
| Message queue | Carries “order placed” events to other services, such as notifications |
The HLD also describes the main flows. Placing an order works like this:
- The app sends the order to the API Gateway, which checks the user is logged in.
- The Order Service reads current prices from the Product Catalog Service.
- The Payment Service charges the customer through the payment gateway.
- The Order Service saves the order and publishes an “order placed” event.
- The Notification Service receives the event and emails the customer.
Notice what is not here: no class names, no method signatures and no table columns. Those belong in the LLD.
7. LLD Example: Designing the Order Service
Now zoom into one box from the HLD: the Order Service. Its LLD defines the classes and how they work together:
8. Following One Request Through the LLD
A sequence diagram shows the order in which objects call each other for one use case. Here is “place an order” in the LLD:
9. Database Design in HLD and LLD
Database design is split between the two levels:
| HLD decides | LLD decides |
|---|---|
| SQL or NoSQL, and which product | Tables or collections and their fields |
| Which service owns which data | Primary keys, foreign keys and constraints |
| Replication and backups | Indexes for the most common queries |
| Sharding or partitioning strategy | Column types, lengths and default values |
| Caching strategy | Which queries hit the cache, and cache keys |
For the Order Service, the LLD turns the Order and OrderItem classes from the class diagram into this schema:
CREATE TABLE orders (
id BIGSERIAL PRIMARY KEY,
customer_id BIGINT NOT NULL,
status VARCHAR(20) NOT NULL,
created_at TIMESTAMP NOT NULL
);
CREATE INDEX idx_orders_customer ON orders (customer_id);
CREATE TABLE order_items (
id BIGSERIAL PRIMARY KEY,
order_id BIGINT NOT NULL REFERENCES orders (id),
product_id BIGINT NOT NULL,
quantity INT NOT NULL CHECK (quantity > 0),
unit_price NUMERIC(10, 2) NOT NULL
);
The index on customer_id exists because the LLD knows that “show my orders” is a common query, served by findByCustomerId().
10. Diagrams Used in HLD and LLD
| Level | Diagram | Shows |
|---|---|---|
| HLD | Architecture diagram | Services, databases, caches and how they connect |
| HLD | Data flow diagram | How data moves through the system for a use case |
| HLD | Deployment diagram | Servers, regions, containers and networks |
| LLD | Class diagram | Classes, fields, methods and relationships |
| LLD | Sequence diagram | The order of calls between objects for one use case |
| LLD | Entity-relationship (ER) diagram | Tables and how they relate |
| LLD | State diagram | The states of an object and the allowed changes, such as CREATED → PAID |
11. Common Mistakes to Avoid
| Mistake | Better approach |
|---|---|
| Starting with classes and tables before the architecture is clear | Agree on the HLD first, then write the LLD for each component |
| Putting class-level detail in the HLD | Keep the HLD at the level of components and data flow |
| Writing an LLD that is just the code | Explain responsibilities, relationships and decisions, not every line |
| Ignoring error handling and edge cases in the LLD | List what can go wrong and how each case is handled |
| Never updating the documents | Keep HLD and LLD in step with the real system |
| Over-designing for problems you do not have | Design for the known requirements and expected growth |
12. Summary
High-Level Design and Low-Level Design are both crucial parts of system design. HLD gives a clear architectural vision: the components, how they connect and which technologies they use. LLD ensures correct and efficient implementation: the classes, methods, tables, patterns and error handling inside each component.
- HLD decides the components, data ownership, technologies and non-functional targets, often guided by a quick capacity estimate.
- LLD designs each component's classes, methods, tables, patterns, states and error handling.
- Architecture and data-flow diagrams belong to HLD; class, sequence and entity-relationship diagrams belong to LLD.
Understanding both helps in building scalable systems and performing well in interviews. For best results, always start with HLD and then move to LLD.
Frequently Asked Questions (FAQ)
Q1. What is the difference between HLD and LLD?
High-Level Design (HLD) describes the whole system: which components exist, how they connect, which data each one owns and which technologies are used.
Low-Level Design (LLD) describes the inside of one component: its classes, methods, database tables, design patterns and error handling.
In short, HLD answers what we build and LLD answers how we build it.
Q2. Which should be done first, HLD or LLD?
HLD comes first. You need to know which components exist and what each is responsible for before designing their internals. Once the HLD is agreed, an LLD is written for each component.
The process is not strictly one-way: if the LLD shows that a component is doing too much, you go back and split it in the HLD.
Q3. Is database design part of HLD or LLD?
Both, at different levels:
- HLD: SQL or NoSQL, which product, which service owns which data, replication, sharding and caching.
- LLD: tables, columns, data types, primary and foreign keys, constraints and indexes.
Q4. Do system design interviews focus more on HLD or LLD?
Most system design rounds focus on HLD, such as "design a URL shortener" or "design a chat app". Many companies also hold a separate LLD or machine-coding round, such as "design a parking lot", where you write classes and code.
Experienced candidates are often asked to go deeper into both levels.
Q5. Who creates the HLD and the LLD?
- The HLD is usually created by architects, tech leads or senior engineers, together with product and operations teams.
- The LLD is usually written by the developers who will build the component, and reviewed by senior team members.
In smaller teams, the same engineers often do both.
Q6. Are design patterns part of HLD or LLD?
Most classic design patterns, such as Strategy, Factory, Builder, Observer and Repository, are part of LLD, because they shape classes and code.
Architectural patterns, such as microservices, API Gateway, event-driven architecture and CQRS, belong to HLD, because they shape the whole system.
Q7. Which diagrams are used in HLD?
- Architecture diagram: services, databases, caches and how they connect.
- Data flow diagram: how data moves through the system for a use case.
- Deployment diagram: servers, regions, containers and networks.
Q8. Which diagrams are used in LLD?
- Class diagram: classes, fields, methods and relationships.
- Sequence diagram: the order of calls between objects for one use case.
- Entity-relationship diagram: tables and how they relate.
- State diagram: the allowed states of an object, such as an order's status.
Q9. Is API design part of HLD or LLD?
Both. The HLD decides which services expose APIs, which protocols they use (such as REST, gRPC or messaging) and the main endpoints.
The LLD defines the exact request and response fields, validation rules, status codes and error formats.
Q10. Does an LLD include actual code?
An LLD is usually very close to code but not the full implementation. It contains class and method signatures, important rules and sometimes short code snippets for tricky parts.
In LLD interviews, however, you are often expected to write working code for the core classes.
Q11. How detailed should an HLD be?
Detailed enough that every team knows what to build and how the parts fit together, but without implementation details. A good HLD covers:
- All major components and their responsibilities.
- Data ownership and the main data flows.
- Technology choices and why they were made.
- How the system scales and handles failures.
If it mentions class names or table columns, it has drifted into LLD.
Q12. Can the HLD change after the LLD has started?
Yes, and that is normal. Detailed design often reveals problems the HLD missed, for example a service with too many responsibilities or an unexpected performance bottleneck.
When that happens, update the HLD and share the change, so that every team is still working from the same picture.
Q13. Do small projects need both HLD and LLD?
Yes, but they can be very light. For a small project, the HLD might be a single diagram and a few notes, and the LLD might be a class diagram plus the database schema.
The thinking matters more than the documents: deciding the structure before coding saves time and avoids messy rewrites.
Q14. What are non-functional requirements?
Non-functional requirements describe how well a system must work, rather than what it does. Common ones are:
- Scalability: how many users and requests it must handle.
- Availability: for example 99.9% uptime.
- Latency: how fast responses must be.
- Security, reliability and maintainability.
They strongly shape the HLD, for example deciding where caches, load balancers and replicas are needed.
Q15. What is capacity estimation in system design?
Capacity estimation is a quick, rough calculation of how much traffic and storage a system needs. For example:
- 1,000,000 users × 10 views each = 10,000,000 views per day.
- 10,000,000 ÷ 86,400 seconds ≈ 116 requests per second, with peaks perhaps ten times higher.
These numbers guide HLD choices, such as how many servers you need and whether a cache or sharding is required. Round numbers are fine; the goal is the right order of magnitude.
Q16. How do SOLID principles relate to LLD?
SOLID principles are guidelines for good class design, so they are applied mainly in LLD:
- Single Responsibility: each class has one job.
- Open/Closed: add behaviour without changing existing code.
- Liskov Substitution: subtypes work wherever their parent type does.
- Interface Segregation: prefer small, focused interfaces.
- Dependency Inversion: depend on interfaces, not concrete classes.
Q17. How should I approach an LLD interview question?
- Clarify the requirements and agree on the scope.
- Identify the main objects from the nouns in the problem, such as Vehicle, Spot and Ticket.
- Define responsibilities and relationships, and sketch a class diagram.
- Write the core classes and methods, keeping rules inside the right objects.
- Handle edge cases, errors and concurrency.
- Explain how to extend the design, for example with new types or pricing rules.
Q18. What are common LLD interview questions?
Popular LLD and machine-coding questions include:
- Parking lot
- Library management system
- Elevator system
- Movie ticket booking
- Snake and ladder or tic-tac-toe game
- Splitwise-style expense sharing
- Vending machine and ATM
- Rate limiter and LRU cache
Q19. How should I prepare for an HLD interview?
- Learn the building blocks: load balancers, caches, CDNs, databases, sharding, replication, message queues and API gateways.
- Practise a clear structure: requirements, capacity estimate, high-level diagram, deep dive into key parts, then trade-offs.
- Study common problems such as a URL shortener, news feed, chat app and ride-hailing service.
- Practise explaining trade-offs out loud, because interviewers value reasoning over a single "right" answer.
Q20. Is choosing microservices an HLD or an LLD decision?
It is an HLD decision. Choosing between a monolith and microservices shapes the whole system: how it is split, deployed, scaled and maintained.
Once the services are defined in the HLD, each one gets its own LLD describing its internal classes, tables and logic.