TweakCode
Design Method lessons

Requirements

How Requirements work

Why it matters

A shortener begins with two small user actions, but one extra sentence can change the busiest request. If “show click counts” is accepted casually, every redirect gains work that was never budgeted; custom domains and abuse detection widen the design again. The team needs a firm boundary: create and redirect are in scope, redirects stay under 50 ms, mappings are durable, and click counts must not add a write to the redirect path.

Example

Scope a URL shortener

Design a service that turns a long URL into a short link and sends visitors to the original address.

Mental model

The idea

Keep one example in view

Scope a URL shortener

Design a service that turns a long URL into a short link and sends visitors to the original address.

Keep this exact scenario and its constraint in view while you build the model.

For this shortener, scope create and redirect, require redirects under 50 ms and durable mappings, and defer click counts, custom domains, and abuse detection; click counts are the request that threatens a write on every redirect.

Treat each user action as a functional requirement: an owner creates a short link and a visitor opens it. State observable results and failures, not components. The redirect target is under 50 ms, mappings are never lost, and availability gets a number such as 99.9%.

Pressure-test extras against the request path. Click counts require work on every open, while custom domains and abuse detection introduce separate concerns. Record those as non-goals so the finished design answers the agreed problem and each boundary can be revisited explicitly.

Run the same example

Walkthrough

  1. 1.Write four to six functional requirements as user-visible verbs.
  2. 2.Give each quality a number or a failure rule.
  3. 3.For each tempting extra, name the box or write it would add.
  4. 4.Put the extras you decline on an explicit out-of-scope list.

Step through

Scope a URL shortener

create · openUserAPIMappings

Two verbs are the product: create a short link, and open it. Each is one call to the API and touches one stored mapping.

1 / 5

What you leave with

Functionalcreate, redirect

Non-functional< 50 ms, durable

A list this short fits a 45-minute design. Each number should be one a reviewer could argue with, such as 50 ms or 99.9%, because those are the numbers that later decide caches, replicas, and queues.

Where this breaks

Listing verbs scopes one request path. It does not size the system, and a cheap verb can still dominate storage.

Your turn

Scope a URL shortener

Same idea, your diagram. The next screen is the design drill.

Design: Scope a URL shortener

Finished this lesson?

Mark it complete when you are ready to move on.