code.davidloor.com

Open prompt · 30 min recommended

Design a URL Shortener

00:00

Target 30:00

Design a URL Shortener

You have 30 minutes. Sketch the system in this notes pane.

Scope

Functional requirements

Non-functional requirements

Out of scope

Suggested approach

  1. Clarify requirements — ask about expiry, custom slugs, analytics, acceptable alias length (6-8 characters is common)
  2. High-level design — two endpoints: POST /shorten and GET /:code; a persistent store for code → url; a cache layer in front of reads
  3. API + data modelPOST /shorten { url, ttl? } → { short_url }; DB table: (code PK, long_url, created_at, expires_at)
  4. Storage + caching — any KV or relational DB works; put a read-through cache (Redis/Memcached) in front since the same popular codes get hit repeatedly
  5. Bottlenecks + mitigations — code generation at scale, hot-key caching, geographic distribution

Reference talking points

Your notes

Saved locally · 0 chars