Whole systems · Intermediate · 11 min

Design a URL Shortener

Separate creating a unique mapping from serving fast, policy-aware redirects.

STEP 1 / 12
State the short-link contract — isometric concept diagramThe API contract determines the design problem. Components: 1. Link user. Representative clients, not a literal user count; 2. Short-link service. Logical component or processing boundary. Connections: 1. Link user to Short-link service: State the short-link contract; 2. Short-link service to Link user: Reply: Short-link service. Illustrations are conceptual, not deployed capacity or user counts.Link user → Short-link service: State the short-link contract1Short-link service → Link user: Reply: Short-link service2Link user: representative traffic illustration; figure count is not a workload measurement.1Link userRepresentative clients, not aliteral user countShort-link service: Logical component or processing boundary2Short-link serviceLogical component or processingboundary
1Link user2Short-link service
  1. 1Link user → Short-link serviceRequestState the short-link contract
  2. 2Short-link service → Link userReplyReply: Short-link service

Conceptual illustration · figures do not imply user counts, deployed capacity or replica counts.

2 components visible · Link user + Short-link service highlighted

Orange: request / query · Blue: reply · Purple: event / control · Arrows show direction; speed is illustrative.

You’ll learn

  • Enforce code uniqueness at the mapping boundary.
  • Redirect caching has a product freshness contract.
  • A mapping needs ownership and a lifecycle.

PUT THE IDEA TO WORK

From learning to practice

RELATED PATTERNS

Cache-aside ↗

Further reading

MDN · Redirections in HTTP ↗