BEGINNER · 12 MIN · FREE LESSON
URL shortener
Explore url shortener through a visual, step-by-step model.
Loading interactive lesson…
BEGINNER · 12 MIN · FREE LESSON
Explore url shortener through a visual, step-by-step model.
Loading interactive lesson…
POST /linksCreate using Idempotency-Key and a validated target URL.
GET /r/{code}Resolve an active short code.
DELETE /links/{code}Revoke an owned link and invalidate its cache entry.
Break the design: Lose delete invalidation, resolve 001 after deletion, and compare the stale redirect with a correct invalidation. Reduce token length and compare sequential and collision-probed allocation.
These API paths describe the exercise system; they are not AlgoVerse endpoints.
Create requests have an HTTP(S) URL and an idempotency key. Sequential code 001 is the first default token. Resolve/delete use code strings. hash-probe uses a tiny illustrative hash and explicit collision checks; tokens are examples, not access secrets.
Loading architecture diagram…
Introduce Create / redirect client: Start from unique, persistent code ownership before adding a cache.
A durable unique-code constraint and an atomic allocation/idempotency boundary protect creation. Reads can use a TTL cache, but deletion needs a revocation policy. This serial model exposes collisions and invalidation loss; it does not supply production abuse controls, atomic distributed counters or unguessable access tokens.
Durable redirect lookups, seed 42. Plotted sample sizes respect each lesson’s explicit input limits.
Keyboard: Space play/pause · ←/→ step · R restart · 1–5 speed. Reduced motion disables transitions.
Create unique short codes with repeat-safe writes. A useful design makes ownership, trade-offs and failure outcomes explicit.
Build the architecture one component at a time. Read the requirements and estimates above the player, then inspect the modeled state transitions.
Start from unique, persistent code ownership before adding a cache.
Keep API authorization and abuse protection separate from code allocation.
A counter plus base62 is compact; a hash candidate still needs a uniqueness check.
Cache reads save store round trips but invalidation affects revocation freshness.
Retain a durable link record and never reuse a revoked code without an explicit policy.
The interactive overview includes editable daily actors, request frequency, peak factor, payload and retention assumptions. RPS is daily requests divided by 86,400. Storage estimates exclude replication, metadata and indexes. These are planning assumptions, not measured provider capacity.
The overview lists example service API contracts and durable entity keys. These paths describe the hypothetical service; they are not callable AlgoVerse endpoints. Define authentication, pagination and error semantics before implementing a real service.
Predict an input-dependent state transition before advancing. Change one assumption at a time and account for committed, rejected, stale or pending outcomes.
Lose delete invalidation, resolve 001 after deletion, and compare the stale redirect with a correct invalidation. Reduce token length and compare sequential and collision-probed allocation.
Use the displayed operation counters and complexity assumptions. Capacity estimates, simulator running time and real end-to-end latency are different measurements.
The references implement sequential base62 allocation, idempotency and revocation. Hash probing and redirect-cache invalidation are additional player experiments.
The four language references implement the stated core mechanism. They are bounded teaching implementations, not complete deployable service backends. The visualizer adds architecture, validated controls and outcome narration around that mechanism.
Use the exercise to explain requirements, ownership, scaling pressure and failure policy in a design interview. Validate a production design with actual workload measurements and the complete selected provider protocol.
Do not turn an illustrative throughput parameter into a universal benchmark. Distinguish retry safety from exactly-once external effects, a cache from durable ownership, and a timeout from a known failure. Name the model limits before claiming a guarantee.
MAKE IT STICK
Progress saves on this device and merges with your account after sign-in.
0 / 5000 · Saved on this device; synced when signed in.
Explain one state transition, one failure invariant and one concern outside the bounded simulation.