how to design X/Y/Z

Difficulty: MEDIUMCategory: LLDFrequency: 1Asked On 2022-03-29

Problem Statement

Design a [system / module / class / service] called [X / Y / Z] that solves [describe the real-world or business problem], ensuring scalability, reliability, and maintainability.


📋 Problem Description


You are required to design [X], which will [main purpose — e.g., store, process, or serve data, or handle user actions].


The system should support [key features / functional requirements], and adhere to good design principles such as modularity, abstraction, and separation of concerns.


🧱 Core Requirements


Functional Requirements


1.List the main operations or behaviors the system should support.
•e.g., Create / Read / Update / Delete
•e.g., Send / Receive messages
•e.g., Store / Retrieve / Cache data
2.Include user actions and system responses.


Non-Functional Requirements


1.Performance (latency, throughput)
2.Scalability (handle growing load)
3.Fault tolerance
4.Security & authentication (if applicable)


⚙️ Design Expectations


•Identify key components or classes (for LLD) or services/modules (for HLD).
•Describe data flow / API flow between them.
•Follow SOLID principles and ensure separation of responsibilities.
•Mention storage or data models, if needed.


🧠 Discussion Points


•What are the major entities and relationships?
•How will data flow between layers?
•How will concurrency, scaling, or reliability be handled?
•What trade-offs might you consider (e.g., consistency vs. availability)?


✅ Deliverables


•Class diagram (for LLD) or Component diagram (for HLD)
•Sequence / API flow diagram
•Sample interactions or pseudo-code
•Future enhancements


🧩 Example Variants


1️⃣ How to Design a URL Shortener (HLD)


Problem Statement:

Design a system like Bitly that converts long URLs into short, unique links and redirects users when the short link is visited.



Key Features:


•Generate unique short codes for given URLs
•Redirect to original URL on request
•Handle large-scale traffic
•Track analytics (click count, source, etc.)


2️⃣ How to Design a Parking Lot (LLD)


Problem Statement:


Design the class structure for a Parking Lot system that supports multiple vehicle types, ticket generation, and payment handling.


Key Features:


•Manage entry/exit of vehicles
•Assign nearest available parking slot
•Generate and close parking tickets
•Calculate parking charges


3️⃣ How to Design a Notification Service (HLD + LLD Hybrid)


Problem Statement:


Design a Notification Service that can send alerts via email, SMS, and push notifications. The system should support scheduling, retry logic, and tracking delivery status.


Key Features:


•Multi-channel delivery (email, SMS, push)
•Retry on failure
•Store message history
•Scale to millions of notifications per day


4️⃣ How to Design a Cache System (LLD)


Problem Statement:


Design a class-based Cache System that supports storing key-value pairs, TTL expiration, and LRU eviction.


Key Features:


•put(key, value) and get(key) operations
•Support eviction when capacity is full
•Handle TTL expiration


5️⃣ How to Design a Payment Gateway (HLD)


Problem Statement:



Design a scalable Payment Gateway system that can process transactions across different banks, handle retries, ensure idempotency, and provide transaction tracking.


Key Features:


•Handle card/bank transactions
•Ensure security & data integrity
•Support multiple payment methods
•Generate audit logs


✨ Quick Formula to Create Your Own “Design X/Y/Z” Problem Statement

Design a [system/module/app] that [main goal]. The system should support [key functionalities] and ensure [non-functional goals like scalability, reliability, fault tolerance].


✅ Example:

Design a Real-Time Chat Application that supports one-to-one and group messaging, message persistence, and user presence tracking, while ensuring low latency and high availability.


Solution

Comments