Monday, February 2, 2026

🏗️ High-Level Design (HLD) for Url Shortener

 Goal: Convert long URLs into short unique codes, and redirect users when they visit the short link.

Key Requirements

  • Functional:

    • Shorten a long URL → return a short URL.

    • Redirect short URL → original long URL.

    • Handle high read/write traffic.

  • Non-functional:

    • High availability.

    • Scalability (millions of URLs).

    • Low latency.

Architecture Components

  • API Gateway → handles requests (POST /shorten, GET /{shortCode}).

  • Application Service → generates short codes, stores mappings.

  • Database → stores mapping of shortCode → longURL.

  • Cache (Redis) → fast lookups for popular URLs.

  • Load Balancer → distributes traffic across servers.

Flow

  1. User sends long URL → API Gateway.

  2. Service generates short code (e.g., base62 encoding).

  3. Store mapping in DB + cache.

  4. Return short URL (tinyurl.com/abc123).

  5. On access, lookup short code → redirect to original URL.

👉 This is the big picture: what modules exist, how they interact.

Difference between HLD (High Level Design) and LLD (Low Level Design)

 

🏗️ High Level Design (HLD)

এটা হলো পুরো সিস্টেমের নকশা

এখানে দেখা হয় কোন কোন বড় বড় অংশ থাকবে, তারা কিভাবে একে অপরের সাথে কথা বলবে।

উদাহরণ:
i. একটা ই-কমার্স সাইটে থাকবে User Module, Product Module, Payment Module

ii. কোন ডাটাবেস ব্যবহার হবে, কোন টেকনোলজি স্ট্যাক (Java, Spring Boot, PostgreSQL ইত্যাদি)।

মানে, বাড়ির ব্লুপ্রিন্ট এর মতো — বাইরে থেকে কেমন দেখাবে, কোন ঘর কোথায় থাকবে।

🔧 Low Level Design (LLD)

এটা হলো প্রতিটি অংশের ভেতরের খুঁটিনাটি ডিজাইন

এখানে দেখা হয় কোন ক্লাস থাকবে, কোন ফাংশন কী করবে, কোন ডেটা স্ট্রাকচার ব্যবহার হবে

উদাহরণ:

i. Controller ক্লাসে কোন কোন API থাকবে (login, register)।

ii. ডাটাবেসে কোন টেবিল, কোন কলাম, কোন primary key।

iii. Error handling কিভাবে হবে।

মানে, ঘরের ভেতরের আসবাবপত্র সাজানো — কোন টেবিল কোথায়, কোন লাইট কোথায় লাগানো হবে।

👉 সহজ করে বললে:

  • HLD = কী বানাতে হবে
  • LLD = কিভাবে বানাতে হবে

=============================================================
🏗️ High Level Design (HLD)

  • It’s like the blueprint of the whole system.
  • Focuses on the big picture: what modules exist, how they interact, what technologies are used.

Example:

  • In an e‑commerce app, HLD will say: there is a User Module, Product Module, Payment Module.
  • Database will be PostgreSQL, backend in Spring Boot, frontend in React.
  • Think of it as house architecture — showing rooms, layout, and structure.

🔧 Low Level Design (LLD)

  • It’s the detailed design of each module.
  • Focuses on internal logic, classes, functions, database tables.

Example:

  • UserController will have APIs like login() and register().
  • Database table users will have columns: id, name, email, password.
  • Error handling and edge cases are defined here.

Think of it as interior design — deciding where furniture, lights, and wiring go inside each room.

📊 Quick Comparison

Aspect | HLD (High Level Design) vs LLD (Low Level Design)
Scope 

Whole | system architecture | Individual modules/components 

Detail Level| Abstract, conceptual | Detailed, implementation-ready
Audience | Architects, senior devs | Developers, testers
Purpose| Defines what to build | Defines how to build

👉 In short:

  • HLD = What to build
  • LLD = How to build
Url Shortener (HLD)

The 11-Year Time Warp: Why AI is Transforming Engineering, But Tech Interviews are Stuck in 2010

  One fine morning recently, I found myself heading to the office of a well-reputed investment bank. I’ll admit, I was reluctant. It was my ...