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.

No comments:

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 ...