System design types, navigating high-level and low-level design
Learn the core differences between High-Level Design and Low-Level Design, and how to translate macro architectures into robust object-oriented code.
MonksBit Desk
November 18, 2026 · 7 min read · 79 views
Read
System design is the process of defining the architecture, interfaces, and data models of a software system to satisfy specified requirements. It splits primarily into High-Level Design (HLD), which plans macro components, network topologies, and storage strategies, and Low-Level Design (LLD), which details class structures, method signatures, algorithms, and local data schemas.
You will need. Basic knowledge of object-oriented programming concepts · Familiarity with client-server web architecture
The full lesson
Level 1 · Beginner: Understanding the separation of architectural layers
Software development requires different levels of zoom to manage complexity. When faced with an entire product like a URL shortener, an engineer cannot simultaneously decide network load balancer configurations and precise class inheritance hierarchies without becoming overwhelmed.
High-Level Design outlines the macro topology. It answers questions such as: which service receives user requests, what database stores records, and whether caching is required. HLD focuses on scalable communication between major modules without considering actual programming code.
Low-Level Design zooms into an individual module identified during HLD. It defines specific object classes, interfaces, method boundaries, and validation algorithms that an engineer implements in code.
For instance, consider a toy URL shortener. At the HLD stage, a request travels through a routing gateway down to an in-memory storage node. At the LLD stage, we implement an interface defining how the key-value dictionary stores and retrieves keys.
Minimal Low-Level Design implementation of an in-memory key-value service
class SimpleUrlRepository: def __init__(self): self._storage = {} def save(self, short_code: str, target_url: str) -> None: self._storage[short_code] = target_url def find_by_code(self, short_code: str) -> str | None: return self._storage.get(short_code)repo = SimpleUrlRepository()repo.save("gh", "https://github.com")assert repo.find_by_code("gh") == "https://github.com"assert repo.find_by_code("missing") is None
Key takeaways
- HLD specifies major architectural boundaries, data storage types, and system protocols.
- LLD specifies concrete class designs, interface contracts, and implementation logic.
- Separating HLD from LLD prevents premature optimization and cognitive overload.
Level 2 · Intermediate: Designing concrete components with clean abstractions
A complete system design requires connecting HLD modular requirements directly to concrete LLD class contracts. In an HLD document, we might establish that our service needs pluggable encoding strategies, thread-safe storage, and collision resolution.
To translate this into LLD, we employ behavioral design patterns such as Strategy to separate encoding algorithms from the orchestration logic, and Repository to abstract data access. This decoupling enables swapping underlying components without rewriting client-facing endpoints.
The following implementation demonstrates a production-style LLD for a shortener module. It defines an abstract base class for code generation strategies and an abstract persistence layer, allowing the domain service to remain agnostic of both physical storage and encoding schemes.
Testing this design becomes straightforward. By isolating each layer behind an interface, unit tests verify business logic using fast in-memory mocks without needing network connections or live databases.
Clean object-oriented design for URL shortening with pluggable strategies
from abc import ABC, abstractmethodimport hashlibclass CodeGenerator(ABC): @abstractmethod def generate(self, input_text: str) -> str: passclass Md5CodeGenerator(CodeGenerator): def __init__(self, code_length: int = 7): self.code_length = code_length def generate(self, input_text: str) -> str: digest = hashlib.md5(input_text.encode("utf-8")).hexdigest() return digest[: self.code_length]class UrlStorage(ABC): @abstractmethod def put(self, code: str, url: str) -> bool: pass @abstractmethod def get(self, code: str) -> str | None: passclass InMemoryUrlStorage(UrlStorage): def __init__(self): self._records: dict[str, str] = {} def put(self, code: str, url: str) -> bool: if code in self._records: return False self._records[code] = url return True def get(self, code: str) -> str | None: return self._records.get(code)class UrlShortenerService: def __init__(self, generator: CodeGenerator, storage: UrlStorage): self._generator = generator self._storage = storage def shorten(self, url: str) -> str: if not url: raise ValueError("URL cannot be empty") code = self._generator.generate(url) self._storage.put(code, url) return code def resolve(self, code: str) -> str | None: return self._storage.get(code)service = UrlShortenerService(Md5CodeGenerator(6), InMemoryUrlStorage())code = service.shorten("https://monksbit.com")assert service.resolve(code) == "https://monksbit.com"
Key takeaways
- Use interfaces and abstract base classes to decouple domain services from external dependencies.
- Strategy patterns allow varying generation algorithms independently from storage layers.
- Thorough validation and defensive checks belong inside domain entities and services.
Level 3 · Advanced: Bridging distributed topologies and local memory concurrency
In enterprise environments, High-Level Design dictates distributed properties such as horizontal scale, replication lag, and network partitioning tolerances, while Low-Level Design implements thread-safe data structures and local concurrency controls.
An HLD decision to use multi-threaded application servers requires an LLD decision on thread synchronisation. If multiple worker threads access a shared in-process cache without coordination, race conditions cause data corruption or duplicate primary keys.
Similarly, HLD decisions around eventual consistency influence the LLD exception handling model. When an external database read replica returns stale data, the low-level client code must handle cache misses or retry with backoff strategies rather than failing outright.
The choice between monolithic and microservice architectures fundamentally shapes both design tiers: monolithic systems rely heavily on LLD class boundaries to prevent spaghetti code, whereas distributed systems rely on HLD network API schemas and circuit breakers to maintain boundary isolation.
Thread-safe concurrent storage implementation using reader-writer locking primitives
import threadingclass ThreadSafeCache: def __init__(self): self._lock = threading.Lock() self._data: dict[str, str] = {} def set_value(self, key: str, value: str) -> None: with self._lock: self._data[key] = value def get_value(self, key: str) -> str | None: with self._lock: return self._data.get(key)cache = ThreadSafeCache()threads = [ threading.Thread(target=cache.set_value, args=(f"key_{i}", f"val_{i}")) for i in range(10)]for t in threads: t.start()for t in threads: t.join()assert cache.get_value("key_0") == "val_0"
Key takeaways
- HLD network distribution requirements directly dictate LLD concurrency mechanisms.
- Local locking protects thread safety in memory but does not resolve distributed multi-host state conflicts.
- Strong API contracts and loose coupling protect system integrity across evolving architectural patterns.
Complexity
- Time: O(1) for in-memory operations; O(log N) to O(N) when database indexes or sequential network calls are traversed.
- Space: O(N) where N is the total number of records maintained in storage or cache.
In-memory dictionary operations run in average O(1) time via hashing algorithms. Storage overhead scales linearly O(N) with the count of stored mapping keys and target payloads.
Common mistakes
- Writing code before finalizing HLD, leading to discarded work when architecture or scale requirements change.
- Focusing entirely on database engines and message queues during LLD interviews while ignoring class structures and object interactions.
- Mixing business logic directly into storage adapters instead of separating concerns through interfaces.
- Assuming local thread-safety mechanisms like threading.Lock solve multi-instance distributed concurrency problems.
Practice problems
- Design a basic rate limiter class (easy). Hint: Model an in-memory dictionary tracking request counts per user IP within a sliding or fixed time window.
- Design a pluggable notification dispatch service (medium). Hint: Use the Strategy pattern to separate Email, SMS, and Push providers behind a common sender interface.
- Design a distributed key-value cache with eviction (hard). Hint: Combine an HLD data partitioning topology with an LLD Least Recently Used doubly linked list and hash map.
Summary
High-Level Design specifies system architecture, components, and communication protocols across a macro view, while Low-Level Design implements concrete object relationships, class interfaces, and algorithmic flows. Mastering both levels enables engineers to conceptualize scalable distributed systems and execute them with maintainable code.
Was this helpful?
Comments (0)
Sign in or create an account to join the conversation.
- No comments yet. Be the first!