Lesson 17.9 · 40 min · video lesson
System Design: HLD, LLD and UML Diagrams with Interview Questions
Your code works perfectly on your laptop; what has to change when ten million people use it at the same time?
In short: System design is deciding how the parts of a software system (clients, servers, databases, caches, queues and the network between them) fit together so it meets its requirements for scale, speed, reliability and cost. We need it because one machine eventually runs out of capacity and fails, and every choice to fix that brings trade-offs. This lesson builds the core vocabulary: scaling, load balancing, caching, CDNs, databases, replication, sharding, consistent hashing, queues, CAP, and back-of-the-envelope estimation. It then shows what changes when one component is a language model: estimates in tokens and GPUs, new building blocks such as a model gateway, a nine-part process for AI design questions, a worked gateway design, and how a design answer is judged. The second half of the lesson is hands-on: UML class and sequence diagrams, a six-step method for high-level design (HLD) with a URL shortener built box by box, a five-step method for low-level design (LLD) with SOLID and design patterns, and six solved interview questions (rate limiter, chat, news feed, parking lot, LRU cache, Splitwise), each with interactive diagrams and running code.
What you will learn
- What is System Design?
- Why do we need it?
- What are the required concepts?
- UML class diagrams and sequence diagrams, step by step
- High-level design (HLD): the six-step method
- A worked HLD: URL shortener architecture
- Low-level design (LLD): SOLID and design patterns
- HLD interview questions solved: rate limiter, chat system, news feed
- LLD interview questions solved: parking lot, LRU cache, Splitwise
In this lesson
Fundamentals
- What is system design?
- Why do we need it?
- Required concepts, part 1: the path of a request
- Required concepts, part 2: storing data at scale
- Code: estimation and consistent hashing
- Required concepts, part 3: reliability and communication
- What changes when a model sits inside the system
- Back-of-the-envelope numbers for AI systems
- How to approach a design problem
- The process for an ML or GenAI design question
- Worked design: an LLM gateway
- How a design answer is judged
- Common mistakes
- Worked example, step by step
- Practice: try it yourself
UML diagrams
- What UML is and why interviews use it
- How to read a class box
- The six relationships and their arrows
- How to draw a class diagram, step by step
- How to draw a sequence diagram, step by step
- From diagram to code
- Class diagram or sequence diagram?
- Common UML mistakes
High-level design (HLD)
- What high-level design is
- HLD vs LLD
- The six-step HLD method
- Requirements and capacity estimation
- APIs and the data model
- Drawing the architecture diagram, step by step
- Finding bottlenecks and trade-offs
- Using the method in an interview
Low-level design (LLD)
- What low-level design is
- The five-step LLD method
- The SOLID principles
- Design patterns that interviews expect
- Building the class diagram, step by step
- Strategy and Observer in code
- Handling concurrency in a design
- Common LLD mistakes
HLD interview questions
- How an HLD interview round runs
- Design a rate limiter
- Design a chat system like WhatsApp
- Design a news feed
- More questions and the one idea behind each
- How the answer is judged
LLD interview questions
- How an LLD interview round runs
- Design a parking lot
- Design an LRU cache
- Design Splitwise
- More questions and the pattern behind each
- How the answer is judged
Key terms in this lesson
- Load balancer
- A component that spreads incoming requests across several servers and skips unhealthy ones.
- Horizontal scaling
- Adding more machines to share the load, instead of making one machine bigger.
- Cache
- Fast storage, usually in memory, holding copies of frequently used data.
- Replication
- Keeping copies of the same data on several machines for availability and read capacity.
- Sharding
- Splitting a dataset across machines so each stores only part of it.
- Consistent hashing
- Assigning keys to servers on a hash ring so adding or removing a server moves only about 1/N of keys.
- Model gateway
- One shared entry point for model calls that handles keys, limits, routing, retries, fallback and logging.
- CAP theorem
- During a network partition, a distributed store must choose between consistency and availability.
- UML
- Unified Modeling Language: a standard set of diagram shapes for describing software designs.
- Class diagram
- A diagram of classes, their attributes and methods, and the relationships between them.
- Sequence diagram
- A diagram of the messages objects send each other, in time order, for one use case.
- High-level design (HLD)
- The architecture of a system: its main components, how they communicate and where data is stored.
- Functional requirement
- Something the system must do, such as "return a short URL for a long one".
- Non-functional requirement
- How well the system must do it: speed, scale, availability, consistency.
- Low-level design (LLD)
- The design of classes, interfaces and their interactions inside one component.
- SOLID
- Five class-design principles: single responsibility, open/closed, Liskov substitution, interface segregation, dependency inversion.
- Design pattern
- A named, reusable solution to a design problem that occurs again and again.
- Rate limiter
- A component that caps how many requests a client may make in a period of time.
- Token bucket
- A rate-limiting algorithm where tokens refill at a steady rate and each request spends one.
- WebSocket
- A long-lived two-way connection that lets a server send data to a client at any time.
- Machine coding round
- An interview where we design the classes for a small system and write working code for it.
- Entity
- A thing in the problem, usually a noun in the requirements, that becomes a class.
- Enum
- A type with a fixed list of named values, such as BIKE, CAR and TRUCK.
This lesson is part of the Generative AI Engineering and Complete AI Engineer tracks. See plans and pricing to open the full lesson, its video, labs and quiz, or try the free lesson first (free account needed).
← 17.8 Building a Real-Time Voice AI Agent from Scratch · 17.10 Transport Protocols: HTTP, WebSockets, and SSE Compared →