High-Level Design Tutorial 0/42 lessons ~6 min read Lesson 2

    HLD vs LLD

    High-Level Design (HLD) and Low-Level Design (LLD) are complementary lenses on the same product.

    Course progress0%
    Focus
    10 guided sections
    Practice signal
    Examples included
    Career prep
    Interview Q&A included

    Introduction

    High-Level Design (HLD) and Low-Level Design (LLD) are complementary lenses on the same product. HLD answers what runs where at scale — services, databases, queues, regions. LLD answers how code inside one service is structured — classes, methods, design patterns, thread safety.

    Interviewers use prompt wording to signal which lens they want. "Design Twitter" is HLD: feeds, fan-out, caches, sharding. "Design a parking lot in Java" is LLD: Vehicle, Spot, Ticket classes and state transitions. Mixing them — drawing Kubernetes for a parking lot or class diagrams for a global CDN — wastes time and signals inexperience.

    This lesson gives you a decision framework, handoff points between architects and developers, and language to switch altitude mid-conversation when the interviewer says "let's zoom into the notification service."

    Understanding the topic

    Key concepts

    • HLD scope: components, network boundaries, data replication, CAP, latency budgets, cost.
    • LLD scope: OOP models, SOLID, in-process concurrency, method contracts, unit-testable modules.
    • HLD artifacts: architecture diagrams, sequence flows across services, API specs, capacity models.
    • LLD artifacts: class diagrams, sequence diagrams within one process, interface definitions.
    • Handoff: HLD defines service boundaries and APIs; LLD implements business rules behind those APIs.
    • Staff-level rounds often start HLD and drill LLD for one critical component (matching engine, ledger).
    text
    flowchart TB
    HLD[High-Level Design] -->|services APIs scale| LLD[Low-Level Design]
    LLD -->|classes methods patterns| Code

    Internal architecture

    Architecture overview

    text
    flowchart TB
    HLD[High-Level Design] -->|services APIs scale| LLD[Low-Level Design]
    LLD -->|classes methods patterns| Code

    Step-by-step explanation

    1. Parse the prompt for scale signals (millions of users, multi-region) → default to HLD.
    2. Look for single-process domain cues (chess board, vending machine, rate limiter class) → default to LLD.
    3. For hybrid prompts, spend 70% on HLD, then pick one hot service for a 5-minute LLD sketch.
    4. Ensure every LLD class maps to a responsibility already implied by an HLD API or event.
    5. Keep HLD boxes at the service/store level; open an LLD box only when asked to go deeper.
    6. Validate consistency: LLD state machines should not violate HLD consistency guarantees.

    Informative example

    HLD defines the order API contract; LLD implements the service layer inside one Spring Boot application:

    java
    // HLD boundary — published OpenAPI / gRPC contract
    public record CreateOrderRequest(String userId, List<LineItem> items, String idempotencyKey) {}
    public interface OrderApi {
    OrderResponse createOrder(CreateOrderRequest request);
    }
    // LLD inside order-service JVM
    @Service
    public class OrderService implements OrderApi {
    private final InventoryClient inventory;
    private final PaymentClient payment;
    private final OrderRepository repository;
    public OrderService(InventoryClient inventory, PaymentClient payment, OrderRepository repository) {
    this.inventory = inventory;
    this.payment = payment;
    this.repository = repository;
    }
    @Override
    @Transactional
    public OrderResponse createOrder(CreateOrderRequest request) {
    inventory.reserve(request.items());
    payment.charge(request.userId(), total(request.items()));
    return repository.save(toEntity(request));
    }
    }

    In interviews, draw the HLD boxes first (Order Service, Inventory Service, Payment Service). Only expand OrderService class details when the interviewer asks how you would implement it.

    Real-world use

    Real-world use cases

    • Splitting architecture RFCs (HLD) from sprint-level design docs (LLD) in enterprise teams.
    • Backend interviews at companies that combine system design + OOD in one loop.
    • Refactoring when HLD boundaries no longer match LLD package structure.
    • Onboarding: new hires read HLD for context, LLD READMEs for module conventions.

    Best practices

    • Ask the interviewer which level they want if the prompt is ambiguous.
    • Use consistent names between HLD services and LLD packages (order-service → com.app.order).
    • Keep HLD diagrams free of class names; keep LLD diagrams free of Kafka topic names unless relevant.
    • Document API contracts at the HLD boundary so LLD teams can work in parallel.
    • When zooming into LLD, restate which HLD assumptions still hold (sync vs async payment).
    • Practice both modes — many candidates over-index on one.

    Common mistakes

    • Drawing microservices for a clearly single-machine LLD problem.
    • Listing design patterns during HLD without a service-level justification.
    • Skipping APIs at HLD and jumping straight to database schemas.
    • Implementing LLD with classes that span multiple HLD service boundaries.
    • Using the same diagram type for both levels — confuses reviewers.

    Advanced interview questions

    Q1BeginnerWhat is the main difference between HLD and LLD?
    HLD focuses on distributed system components and scale; LLD focuses on in-process class and object design.
    Q2BeginnerWhich comes first in a greenfield project?
    HLD typically comes first to set boundaries; LLD follows per service during implementation.
    Q3IntermediateCan one interview question require both?
    Yes — design Uber at HLD level, then deep-dive LLD for surge pricing or trip state machine.
    Q4IntermediateWhat artifacts differ between HLD and LLD?
    HLD uses deployment and data-flow diagrams; LLD uses class, sequence, and activity diagrams within one service.
    Q5AdvancedHow do you decide when to stop HLD and start LLD in a 45-min round?
    Stop HLD when components, APIs, and data stores are clear; go LLD only on the component the interviewer selects or the highest-risk module.

    Summary

    HLD is distributed architecture; LLD is in-service object design. Prompt wording and scale hints tell you which mode to lead with. Hybrid rounds: mostly HLD, selective LLD on one critical service. API contracts are the clean handoff between the two levels. Use the right diagram for the altitude — services vs classes. TechLearningPRO covers both tracks so you can switch lenses confidently.

    Ready to mark this lesson complete?Track your journey across the entire course.