CloudSketch AI Logo
FeaturesTemplatesPricingEnterpriseAboutContactLog in
🌙☀️
Log inStart free
Home/Templates/System Design Interview Classics

📝 System Design Interview Classics · C4 Architecture · Pro

URL Shortener System Design

The classic interview design for a service like bit.ly: short code generation, fast redirects from a cache, and click analytics processed separately.

More System Design Interview Classics templates

C4 Architecture diagrams are part of Pro. Anyone can view this one; generating and editing it needs Pro.

Drawing diagram…

What this diagram shows

  • Short codes come from a pre-generated key range, so there are no collisions
  • Redirects are served from Redis for speed
  • Click analytics go through a queue so redirects stay fast

Prompt used

URL shortener design: users create short links through a web app and API. A key generation service hands out unused 7-character codes from pre-allocated ranges. Links are stored in Cassandra. The redirect service looks up codes in a Redis cache first, falls back to Cassandra, and returns an HTTP 301 redirect. Each click is sent to Kafka and an analytics service aggregates clicks per link into ClickHouse.

Mermaid code
C4Container
title URL Shortener
Person(user, "User", "Creates and shares links")
Person(visitor, "Visitor", "Clicks short links")
System_Boundary(us, "URL Shortener") {
  Container(api, "Link API", "Go", "Create and manage links")
  Container(kgs, "Key Generation Service", "Go", "Hands out unused codes")
  Container(redir, "Redirect Service", "Go", "Looks up code and redirects")
  Container(an, "Analytics Service", "Java", "Aggregates clicks")
  ContainerDb(cache, "Cache", "Redis", "Hot short codes")
  ContainerDb(db, "Link Store", "Cassandra", "Code to long URL")
  ContainerQueue(q, "Click Events", "Kafka", "One event per click")
  ContainerDb(ch, "Analytics DB", "ClickHouse", "Clicks per link")
}
Rel(user, api, "Creates link", "HTTPS")
Rel(api, kgs, "Gets a code")
Rel(api, db, "Saves link")
Rel(visitor, redir, "Opens short URL", "HTTPS")
Rel(redir, cache, "Reads")
Rel(redir, db, "Reads on cache miss")
Rel(redir, q, "Publishes click")
Rel(an, q, "Consumes")
Rel(an, ch, "Writes counts")

Related templates

SequenceSystem Design Interview Classics

Chat App Message Delivery (WhatsApp-style)

How a one-to-one chat message is delivered in a WhatsApp-style system, with sent, delivered and read ticks, and push notifications when the receiver is offline.

Data FlowSystem Design Interview Classics

Social News Feed (Twitter-style)

How posts reach followers' feeds: fan-out on write for normal users, fan-out on read for celebrities, and a ranked feed built from a cache.

C4 ArchitectureProSystem Design Interview Classics

Ride Matching System (Uber-style)

The core of a ride-hailing app: drivers stream their locations, a geo index finds nearby drivers, and a matching service offers the trip to the best one.

FlowchartSystem Design Interview Classics

API Rate Limiter (Token Bucket)

How a token bucket rate limiter decides whether to let an API request through, using Redis so all servers share the same counts.

DeploymentProSystem Design Interview Classics

Notification Service Design

A notification system that sends email, SMS and push messages at scale: one API, a queue per channel, user preferences, and retries.

Data FlowSystem Design Interview Classics

Search Autocomplete (Typeahead)

How search suggestions appear as you type: a prefix index built offline from past searches, served from memory, and refreshed regularly.