Skip to content

System Design — From First Principles to Any Interview

A practical course that takes a full-stack AI engineer from beginner to advanced system design, anchored in a real production system (Roost) and finished with interview mocks.

Goal: after this course you can design any system on a whiteboard, defend every trade-off, and explain what you have built in simple technical terms.

Audience: engineers who ship product but have not been formally taught system design.


Every pattern exists because something broke. Each lesson starts from the failure, then derives the fix — so a problem you have never seen is still solvable from its constraints.

  1. What breaks — the failure that makes the concept necessary
  2. Mental model — one picture to hold in your head
  3. Diagram — Mermaid flow, sequence or architecture diagram
  4. Real case — where a production system (Roost) met it, and why it was built that way
  5. Trade-offs — what the choice costs, and when you would choose differently
  6. Drill — two interview questions (a cold one, then a follow-up or twist) and one hands-on exercise

Roost cases describe the problem, the design and the trade-off. They never include source code, hostnames, network topology, security controls, secrets or internal service names.

unlocks C1

unlocks C2–C8

Part 0
Orientation

Part 1
One server

Part 2
Many servers

Part 3
Distributed systems

Part 4
AI systems

Part 5
Capstones

Transfer exams

Part 6
Explain what you built


# Lesson
0.1 Baseline diagnostic — measure before teaching
0.2 How to answer any design question — requirements → estimates → API → data → high-level → deep dive → failure modes
0.3 Back-of-envelope estimation — QPS, storage, bandwidth, latency numbers every engineer knows
# Lesson Real case
1.1 How a request travels — DNS, IP, TCP vs UDP, TLS, HTTP/1.1 → 2 → 3 a booking page request, end to end
1.2 Proxies, reverse proxies and a first look at load balancing edge proxy in front of the apps
1.3 API design — REST vs RPC vs GraphQL, contracts, pagination, errors, versioning one contract shared by three clients
1.4 Data modelling — entities, relationships, normalisation jobs, appointments, offerings
1.5 Relational databases — indexes, ACID, transactions, isolation levels money as integer minor units
1.6 SQL vs NoSQL and database types — key-value, document, wide-column, graph, time-series, vector
1.7 Authentication and authorisation — sessions vs tokens, OAuth, RBAC, multi-tenancy owner-defined custom roles
1.8 Frontend architecture — SPA, SSR, SSG, bundle size, PWA, slow networks server-rendered storefront vs SPA dashboard on 3G
1.9 Files and object storage — uploads, presigned URLs, CDN business photos
1.10 Lab: build a URL shortener on one box
# Lesson Real case
2.1 Scaling — vertical vs horizontal, stateless vs stateful
2.2 Availability — single points of failure, redundancy, failover, heartbeats, the “nines” maths
2.3 Load-balancing algorithms + lab: implement round robin, least connections, IP hash
2.4 Caching — cache-aside, read/write-through, write-back, eviction, invalidation, stampedes, CDN
2.5 Asynchronous work — queues, pub/sub, retries, backoff, dead-letter queues, backpressure
2.6 Idempotency and the exactly-once myth payment webhooks delivered twice
2.7 Concurrency control — races, optimistic vs pessimistic locking, database constraints preventing double-booking
2.8 Money systems — ledgers, double entry, reconciliation, idempotency keys collecting deposits through a payment provider
2.9 Real-time — polling, long polling, server-sent events, WebSockets
2.10 Rate limiting + lab: token bucket, leaky bucket, sliding window
2.11 Architecture styles — monolith, modular monolith, microservices, serverless, event-driven, API gateway modular monolith with domain events
2.12 Third-party integrations — webhooks, timeouts, circuit breakers, provider failure a messaging-platform channel
2.13 Observability — logs, metrics, traces, SLIs and SLOs, alerting
2.14 Deploying and operating — containers, rolling deploys, rollback, safe migrations, backups, RPO/RTO pinned image tags, migrate-before-deploy
2.15 Security basics — OWASP Top 10, secrets, encryption in transit and at rest, least privilege
2.16 Search — inverted index, full-text search, autocomplete with a trie
# Lesson Real case
3.1 Replication — leader/follower, multi-leader, leaderless, replication lag, read-your-writes
3.2 Consistency models, CAP and PACELC
3.3 Partitioning and sharding — consistent hashing + lab, hot keys, rebalancing
3.4 Distributed transactions — two-phase commit, sagas, transactional outbox, change data capture events that must not be lost
3.5 Coordination — Raft intuition, leader election, distributed locks, fencing tokens, gossip
3.6 Batch vs stream processing — Kafka-style logs, windowing
3.7 Probabilistic data structures — Bloom filter, HyperLogLog, count-min sketch
3.8 Multi-region and edge
3.9 Multi-tenant SaaS at scale — noisy neighbours, tenant isolation many businesses on one platform
# Lesson Real case
4.1 LLM fundamentals for system designers — tokens, context windows, time to first token, throughput, cost
4.2 LLM serving and gateways — streaming, batching, model routing, fallbacks, semantic caching a model chosen per agent
4.3 Structured output and tool calling — the payload vs prose split one answer rendered per channel
4.4 Agent architecture — the agent loop, tools, session state, multi-agent routing, guardrails a booking agent
4.5 Retrieval-augmented generation — embeddings, chunking, vector stores, hybrid search, re-ranking
4.6 Evals — offline and online, LLM-as-judge, regression sets, AI observability transcript-based agent evals
4.7 AI security — prompt injection, data leakage, PII handling
4.8 AI cost and reliability engineering

Capstones are where the learner designs, not reads. Each one unlocks when its prerequisite lessons are done, so capstones run alongside the parts rather than only at the end.

The learner does the work at every step; the reference design is the last thing revealed.

  1. Cold attempt — 45 minutes, alone, on a whiteboard or Excalidraw, before reading anything.
  2. Spot the pattern — name the signals in the prompt and the principle they point to.
  3. Guided pass — one checkpoint question per framework step (requirements, estimates, API, data, high-level, deep dive, failure modes). Answer each before its hint opens.
  4. Reference design — revealed only after the guided pass.
  5. Diff — write down three things the reference has that the attempt missed, and why each matters.
  6. Twists — answer three follow-ups an interviewer would ask: “now 100×”, “a region fails”, “the product changes”.
  7. Build a slice — where marked, implement the core mechanism in code.
  8. Score and redo — scored on the rubric; redone cold seven days later. Mastered when it scores 80% or more on two cold attempts.

Rubric: requirements, estimation, API, data model, high-level design, deep dive, failure modes, trade-offs, communication.

# Problem Core principle Interview signals Unlocks after Slice
C1 URL shortener ID generation, read-heavy caching “short code”, “redirect”, reads far exceed writes 1.10 yes
C2 Rate limiter counting in time windows, shared counters “throttle”, “N per minute”, “abuse”, “protect the API” 2.10 yes
C3 Notification service queues, retries, fan-out to channels “send to millions”, “email/SMS/push”, “must not lose” 2.6
# Problem Core principle Interview signals Unlocks after Slice
C4 Booking system (Airbnb, flights, tickets) contention on limited inventory “last seat”, “no double booking”, “hold then pay” 2.7 yes
C5 Payment system and wallet idempotency, ledgers, reconciliation “charge”, “balance”, “refund”, “never twice” 2.8
C6 Chat app (WhatsApp) persistent connections, delivery state, ordering “real time”, “online status”, “read receipts” 2.9
C7 News feed (Twitter, Instagram) fan-out on write vs on read, hot users “followers”, “timeline”, “celebrity posts” 2.4
C8 Distributed job scheduler leases, at-least-once execution, time “run at 9am”, “cron at scale”, “exactly once” 2.5

C4 and C5 are home ground — Roost met both in production — so they run grill-first.

# Problem Core principle Interview signals Unlocks after Slice
C9 Video platform (YouTube, Netflix) blob storage, processing pipeline, CDN “upload”, “stream”, “different devices and speeds” 3.6
C10 Ride-hailing and nearby search (Uber, Yelp) geospatial indexing, high-rate location writes “nearby”, “within 2 km”, “drivers moving” 3.3
C11 Collaborative editor (Google Docs) concurrent edits — OT and CRDTs “same document, many editors”, “offline then sync” 3.2
# Problem Core principle Interview signals Unlocks after Slice
C12 ChatGPT-style assistant streaming, conversation state, cost per token “chat with a model”, “history”, “millions of users” 4.2
C13 RAG over documents retrieval quality, freshness, citations “answer from our docs”, “up to date”, “show sources” 4.5 yes
C14 Agent platform tool calling, sandboxing, evals, guardrails “takes actions”, “uses tools”, “safely” 4.6 yes
C15 LLM serving batching, GPU utilisation, routing, fallbacks “host our own model”, “latency SLO”, “cheaper” 4.2

Transfer exams — proof of “any system”

Section titled “Transfer exams — proof of “any system””

Three problems that no lesson or capstone covers, attempted cold after Part 5 — for example an ad-click aggregator, a stock-exchange order book, or a distributed counter for likes. Passing them shows the method transfers to systems never studied.

# Lesson
6.1 Roost explained at three depths — 30 seconds, 5 minutes, 30 minutes, with diagrams
6.2 Five war stories in STAR form — double-booking, payment idempotency, the outbox, agent tool calling, deploy safety
6.3 Trade-off probes — “why not microservices?”, “what breaks at 100×?”, “what would you change?”

One-sentence entries for topics that need recognition, not depth: OSI model, checksums, gossip protocol, peer-to-peer, heartbeats, serverless cold starts and similar.


Roughly 50 lessons at four a week is about twelve weeks. Part 0 comes first, and one full mock runs every week from week 2 in parallel with the lessons, so interviews can start before the course ends.

Each lesson ends with links. The primary index is awesome-system-design-resources, used as a coverage checklist and problem bank.