# Part 12 — Case Studies

> 36 full system designs, each run through the [framework](../11-interview-framework/01-the-framework.md)
> from Part 11. This is where all the theory becomes muscle memory. Every case study follows the same
> structure — requirements, estimation, API, data model, high-level design, deep dives, bottlenecks,
> trade-offs, follow-ups, and what junior/mid/senior answers look like — so you learn the *shape* of a good
> answer, not just the facts of one system.

**Time for this part:** Weeks 3–8, in parallel with Part 11. Don't read these passively — for each one, try
to design it yourself first (set a 45-minute timer), *then* read. The gap between your answer and the
write-up is your study list.

**How to use them:** The studies are ordered easy → hard and grouped by the pattern they teach. Patterns
recur — fan-out, reserve-then-confirm, candidate-gen→rank, event-log-as-source-of-truth — and the studies
cross-reference each other so you build a web, not a list. When a study reuses a pattern, it says so and
moves on; learn to do the same in interviews.

---

## The 36 designs

### Warm-ups — the shape of an answer (Tier 1)

| # | Design | Teaches |
| --- | --- | --- |
| 1 | [URL Shortener](./01-url-shortener.md) ⭐ | The template; read-heavy; cache; ID generation |
| 2 | [Pastebin](./02-pastebin.md) | Metadata/blob split; object storage; CDN |
| 3 | [Rate Limiter](./03-rate-limiter.md) | Algorithms; atomic ops; distributed counting |
| 4 | [Key-Value Store](./04-key-value-store.md) | Consistent hashing, quorums, conflict resolution (deep) |
| 5 | [Web Crawler](./05-web-crawler.md) | Frontier; Bloom filters; politeness; producer/consumer |
| 6 | [Notification System](./06-notification-system.md) | Fan-out; queues; idempotency; flaky providers |
| 7 | [Parking Lot (LLD)](./07-parking-lot.md) | Object-oriented design; SOLID; extensibility |

### Social & media — fan-out and feeds (Tier 2)

| # | Design | Teaches |
| --- | --- | --- |
| 8 | [Twitter / X](./08-twitter.md) ⭐ | Fan-out write vs read; the celebrity problem; hybrid |
| 9 | [Instagram](./09-instagram.md) | The media pipeline; async processing; CDN |
| 10 | [News Feed](./10-news-feed.md) | Ranked feeds; candidate-gen → ranking |
| 11 | [Chat System](./11-chat-system.md) ⭐ | WebSockets; presence; delivery guarantees; offline sync |
| 12 | [Video Streaming](./12-video-streaming.md) | Transcoding; adaptive bitrate; CDN at planetary scale |
| 13 | [File Storage / Dropbox](./13-file-storage.md) | Chunking; dedup; delta sync; conflict resolution |

### Location & marketplaces (Tier 2–3)

| # | Design | Teaches |
| --- | --- | --- |
| 14 | [Ride-Hailing / Uber](./14-ride-hailing.md) ⭐ | Geospatial indexing; matching; real-time location |
| 15 | [Food Delivery](./15-food-delivery.md) | Three-sided marketplace; sagas; predictive dispatch |
| 16 | [Typeahead / Autocomplete](./16-typeahead.md) | Trie; precompute; batch+stream freshness |

### Infrastructure — build the building blocks (Tier 2–3)

| # | Design | Teaches |
| --- | --- | --- |
| 17 | [Distributed Cache](./17-distributed-cache.md) | Consistent hashing; eviction; replication internals |
| 18 | [Job Scheduler](./18-job-scheduler.md) | Exactly-once; leader election; lease-based recovery |

### Commerce, money & inventory — correctness first (Tier 3)

| # | Design | Teaches |
| --- | --- | --- |
| 19 | [E-Commerce / Amazon](./19-e-commerce.md) | Scoping a huge domain; inventory; strong-vs-eventual |
| 20 | [Payment System](./20-payment-system.md) ⭐ | Double-entry ledger; idempotency; reconciliation; CP |
| 21 | [Ticketing / BookMyShow](./21-ticketing-system.md) | Seat reservation with expiry; on-sale spikes |
| 22 | [Hotel Booking](./22-hotel-booking.md) | Availability over date ranges; overlap-free reservation |

### Search, maps & big data (Tier 3)

| # | Design | Teaches |
| --- | --- | --- |
| 23 | [Google Search](./23-google-search.md) | Inverted index; sharding; staged ranking |
| 24 | [Google Maps](./24-google-maps.md) | Graph routing; precomputation; live traffic |
| 25 | [Metrics System](./25-metrics-system.md) | Time-series; cardinality; downsampling |
| 26 | [Message Queue](./26-message-queue-design.md) | Commit log; offsets; delivery semantics |
| 27 | [Log Aggregation](./27-log-aggregation.md) | Text search; hot/warm/cold tiering; correlation IDs |
| 28 | [Ad Click Aggregator](./28-ad-click-aggregator.md) | Stream processing; Lambda/Kappa; event-time windows |

### Real-time, correctness & ML (Tier 2–3)

| # | Design | Teaches |
| --- | --- | --- |
| 29 | [Leaderboard](./29-leaderboard.md) | Sorted sets; rank queries; exact-top / approx-tail |
| 30 | [Collaborative Editing / Google Docs](./30-collaborative-editing.md) | OT vs CRDT; convergence; real-time sync |
| 31 | [Stock Exchange](./31-stock-exchange.md) | Matching engine; determinism; scale-up not out |
| 32 | [Fraud Detection](./32-fraud-detection.md) | Real-time scoring; feature store; precision vs recall |
| 33 | [Recommendation System](./33-recommendation-system.md) | Candidate-gen → ranking; embeddings; cold start |

### Platform & systems (Tier 2–3)

| # | Design | Teaches |
| --- | --- | --- |
| 34 | [Feature Flag Service](./34-feature-flag-service.md) | Local evaluation; config push; consistent rollouts |
| 35 | [CI/CD Platform](./35-ci-cd-platform.md) | Job DAGs; isolation of untrusted code; autoscaling |
| 36 | [Multiplayer Game Server](./36-multiplayer-game.md) ⭐ | Authoritative state; UDP; prediction; anti-cheat |

---

## The recurring patterns

Once you've done a dozen, you'll notice the *same handful of ideas* solve most problems. This is the payoff —
recognizing the pattern is half the battle:

1. **Read-heavy → cache + precompute.** URL shortener, feeds, typeahead, search. Reads scale by copying.
2. **Fan-out (write vs read) + the celebrity/hot-key hybrid.** Twitter, Instagram, news feed, notifications,
   chat groups.
3. **Metadata in the DB, big blobs in object storage + CDN.** Pastebin, Instagram, video, file storage.
4. **Reserve-then-confirm with a TTL (don't oversell).** E-commerce, ticketing, hotel booking.
5. **Candidate generation → ranking (two-stage).** News feed, recommendations, search, fraud.
6. **Precomputed feature store + fast online serving.** Feed ranking, recommendations, fraud detection.
7. **Event log as source of truth; derive views; replay.** Ad aggregator, stock exchange, payments,
   message queue.
8. **At-least-once + idempotency = exactly-once *effect*.** Notifications, job scheduler, payments, queues.
9. **Strong consistency only for money & stock; eventual everywhere else.** E-commerce, payments,
   ticketing.
10. **Geospatial index + partition by geography.** Ride-hailing, food delivery, maps.
11. **Stateful real-time connections (WebSocket/UDP) + presence + reconnect sync.** Chat, collaborative
    editing, multiplayer games.
12. **Batch (exact, slow) + stream (fresh, approximate) two-speed.** Ad aggregator, typeahead, search,
    metrics, recommendations.

---

## How to practice a case study

1. **Read the requirements only**, then close the page.
2. **Design it yourself in 45 minutes** — out loud, on a whiteboard, following the [framework](../11-interview-framework/01-the-framework.md).
3. **Compare** to the write-up. Note what you missed — a deep dive? the key trade-off? an edge case?
4. **Redo it** a week later. The goal is fluency, not memorization — you should be able to *derive* the
   design, not recall it.
5. **Explain it to someone** (or rubber-duck it). If you can teach it, you know it.

See [Part 13 — Practice](../13-practice/README.md) for structured drills and a problem bank.

---

**Next:** [Part 13 — Practice](../13-practice/) — drills, self-grading, and how to turn these case studies
into interview-ready fluency.
