The GenAI system design framework

In one sentence

Run the round as a chain of decisions: clarify the goal and costliest failure, size it, sketch offline and online paths, deep-dive with an eval per choice, then guardrails, failure modes and trade-offs.

Analogy: A good doctor's visit: symptoms and history first, tests sized to the suspicion, then treatment, and before you leave, which side effects to watch for and when to come back.

Requirements set the deep dives and the guardrails; each deep dive loops with its eval until it meets the target.

How it works

  • The round grades judgment under a clock, not boxes: write requirements first, then let them drive the architecture.
  • Spend the deep dives (~14 of 50 minutes) on the two components that carry the most risk.
  • Attach an eval to every choice: a metric, a dataset and a threshold, sliced by intent.
  • The model proposes, deterministic systems authorize: a system prompt is never an authorization boundary.
  • Prefer the simplest design that meets the requirements: a workflow before an agent, RAG before fine-tuning.

Check yourself

Answer to mark it learned; your answers aren't scored.

Design round: an HR policy assistant for 20k employees. Your estimate comes out at ~0.07 QPS and ~$24/day in tokens. The worst failure you clarified is a confidently wrong leave entitlement. Where do you spend the 14 minutes of deep dives?

Go deeper

Back-of-the-envelope calculator Interactive labDo this round in 45 minutes System design round
Full explanation

An AI system-design round grades judgment under a clock, not the boxes you draw. The framework is a fixed order of decisions: requirements drive the architecture, and every component arrives with its eval, its guardrail and its failure mode.

Steps and the clock (50-minute round)

  1. Clarify (~6 min): objective, users, success metric and the highest-cost failure — a wrong refund, a leaked document, a confident wrong dosage.
  2. Estimate (~4 min): QPS, tokens per request, latency budget, $/month (Back-of-the-envelope estimation).
  3. High-level design (~9 min): the offline path (ingest, index, train) and the online request path.
  4. Deep dives (~14 min): the two components that carry the most risk, usually retrieval, model choice, or agents and tools.
  5. Evaluation (~5 min): a metric, dataset and threshold for each choice.
  6. Safety (~4 min): the model proposes, deterministic systems authorize.
  7. Serving and cost (~3 min): caching, routing, batching, streaming.
  8. Failures (~3 min): monitoring, fallbacks, rollback.
  9. Close (~2 min): trade-offs, residual risk, what you'd build next.

Staff signals

  • You lead trade-offs unprompted: "I chose X over Y because of the latency budget; the price is Z."
  • You pick the simplest design that meets the requirements: a workflow before an agent, prompt + RAG before fine-tuning (Agents vs workflows, Prompt → RAG → fine-tune: the decision).
  • You name the residual risk and who owns it, instead of implying the design is safe.

Common mistakes

  • Boxes first: an LLM and a vector DB on the board before the success metric.
  • Agents everywhere: autonomy where a fixed workflow is cheaper, faster and testable.
  • A vector DB as the whole RAG design: parsing, ACLs, chunking, reranking and freshness are where RAG fails.
  • Prompts as an authorization boundary: "the system prompt forbids refunds over $100" is not a control (Prompt injection (direct & indirect)).
  • One aggregate eval score: it hides the slice that hurts; break scores down by intent and failure type.
  • No abstention path: nothing lets the system say "I don't know" or hand off to a human.
Real example

Prompt: "Design an assistant that answers HR policy questions for 20k employees." In the first 6 minutes you learn that answers must cite the policy, policies differ by country, and the worst failure is a wrong leave entitlement stated confidently. Estimate: assume 10% of employees ask once per working day → 2k questions/day ≈ 0.07 QPS even packed into 8 hours; at ~4k tokens each that is ~8M tokens/day, about $24/day at an assumed $3 per million tokens. Scale is not the risk; correctness and permissions are. So the deep dives become country-filtered retrieval and an abstention path, and the eval is 200 questions sliced by country, not autoscaling.

Trade-offs +3 · −3

+ You gain

  • Requirements and the worst failure drive the architecture, so every box has a stated reason.
  • Evals and safety don't fall off the end of the clock, which is where weak rounds lose them.
  • Maps one-to-one onto a real design doc, so the practice transfers to the job.

− You pay

  • Followed rigidly it sounds rehearsed; interviewers steer, and you must jump to the deep dive they want.
  • Time boxes trade depth for coverage; on a narrow prompt, compress steps 6–8 to a minute each.
  • It structures the conversation but can't supply the numbers and mechanisms; you still need those.

Use it when

Any open-ended "design an AI system" round, and real design reviews where you must justify an LLM feature to skeptical peers.

Avoid it when

Narrow deep-dive prompts ("design only the retrieval layer"): skip to step 4. Coding or ML-theory rounds where nobody asked for architecture.

Numbers to know 5
  • 50-minute split: clarify 6 · estimate 4 · architecture 9 · deep dives 14 · eval 5 · safety 4 · serving 3 · failures 3 · close 2.
  • QPS = requests/day ÷ 86,400: 1M/day ≈ 12 QPS average; assume peak ≈ 2–3× average.
  • Tokens/day = requests × (input + output); output tokens cost ~4–8× input tokens on major APIs.
  • Chat latency budget (assumed): retrieval ~150 ms + rerank ~100 ms + first token ~0.5–1 s; stream the rest.
  • Batch APIs (OpenAI, Anthropic) cost ~50% less for work that can wait up to 24 h.
Common pitfalls 4
  • Running out of clock: 15 minutes on requirements leaves nothing for evals or safety. Announce the agenda and time-box out loud.
  • Estimating, then ignoring the numbers. Each estimate should change a decision: caching, model size, or "scale isn't the risk here".
  • Monologuing past the interviewer's hints. Check in after each step; their follow-up tells you which deep dive they grade.
  • Naming products instead of mechanisms: "Pinecone + LangChain" explains nothing; "filtered HNSW with ACL metadata, because…" does.
Interview questions 3

Answer out loud first, then reveal.

The interviewer pulls you into retrieval details at minute 10. Follow, or stick to your plan?Show answer

I follow: their pull tells me what they grade. But I park the rest out loud: "I'll come back to evals and guardrails." I spend the deep dive there, then compress steps 6–8 to about a minute each, with the one decision per step that matters: the authorization boundary, the main cost lever, the rollback. Ending without safety and evals is worse than a shallower deep dive, so I watch the clock and say when I'm cutting.

How do you show your design is the simplest one that works?Show answer

By naming the ladder and the rung I stopped at. "One prompt with RAG meets the requirements. I considered an agent and rejected it: the task is a fixed sequence, and an agent adds latency and failure modes. I'd move up only if the eval shows, say, more than 15% of questions need several retrieval hops." Simplicity is a claim about requirements, so I tie it to a metric and a trigger, not to taste.

Your system scores 92% on the eval set. Ship it?Show answer

Not on that number alone. First, what is in the 8%: if failures cluster on one slice (refunds, one language, one country's policy), that slice may be the highest-cost failure we named at the start. Second, is the set representative, and how big is it? On 200 cases the 95% interval is roughly ±4 points. Third, what's the baseline and the cost of an error? I'd ship behind a canary with a slice-level gate and online metrics.

Deep dive 6

Clarify and size it (steps 1–2)

Ask 3–5 questions that change the design: Who are the users, and how many? What is success: deflection, time saved, revenue? What is the worst thing the system can do, and is it reversible? What latency is tolerable: streamed chat or sub-second autocomplete? What data may the model see, under whose permissions? Write the answers on the board as requirements; you will cite them later. Then estimate out loud: 1M requests/day ≈ 12 QPS average, ~30 at peak (assume 2.5×). At 3k input + 400 output tokens each, that is 3B input and 0.4B output tokens a day; the price per token turns that into $/month and tells you whether caching or a smaller model is mandatory.

Architecture and deep dives (steps 3–4)

Draw two paths. Offline: connectors, parsing, chunking, embedding, indexing, eval-set building, fine-tuning if any. Online: auth → router → retrieval → model → output validation → response, with the state store and the tool gateway beside it. Then choose the two deep dives where the risk lives, and say why you chose them. Retrieval: chunking, Hybrid search & RRF, Reranking (cross-encoders), permission filters. Model choice: quality bar, latency, cost per request, API vs self-hosted. Agents: tool schemas, loop limits, durable state. In each one, name the option you rejected and the number that would flip your decision.

An eval attached to every choice (step 5)

"We'll use LLM-as-judge" is not an eval plan. For each decision give a metric, a dataset and a threshold: recall@20 on 300 labeled queries for retrieval; groundedness and citation precision for answers; task success and wrong-action rate for agents. Slice every score by intent, language and user tier: a 92% aggregate can hide a 60% slice that is all your refunds. Offline evals gate releases in CI (Evals in CI/CD & release gates); online, track thumbs-down rate, escalations and A/B tests on the business metric (Offline vs online evaluation). Close the loop: production failures become new golden cases (Error analysis: look at your data).

Safety: the model proposes, systems authorize (step 6)

Treat every token the model reads (user messages, retrieved documents, tool outputs) as untrusted. Anything with side effects passes through code you control: identity-based permission filters before retrieval, typed tool schemas, a policy engine for amounts and scopes, and human approval for irreversible actions (Human-in-the-loop & approvals). Check the The lethal trifecta: private data, untrusted content and an exfiltration channel in one session means a successful Prompt injection (direct & indirect) leaks data, so remove one leg. Add input and output Guardrails: input, output, action for PII and policy, plus an abstention path when evidence is weak. Then say which risk remains.

Serving, cost and failure modes (steps 7–8)

Name the levers from cheapest up: Prompt caching for the stable prefix, Model routing & cascades of easy traffic to a small model, Streaming responses (SSE) to cut perceived latency, Batch inference for anything that can wait (~50% off on major APIs). Give a latency budget per hop, e.g. retrieval 150 ms, rerank 100 ms, first token 600 ms. For failures, walk the dependencies: model API down → fallback provider through an LLM gateway; stale index → freshness alarm; quality regression → canary, then roll back the prompt or model version, both deployed as versioned artifacts. Monitor cost per resolved task, not only cost per token (LLM observability & tracing).

Close: trade-offs and next steps (step 9)

Spend the last two minutes summarizing, not adding boxes. Three sentences do it. The main trade-off: "I spent ~100 ms on a reranker because a wrong answer costs more than a slow one." The residual risk: "a document mislabeled as public at the source will still be retrieved." The next step and its trigger: "if multi-hop questions exceed ~15% of failures, I'd add agentic retrieval." Knowing what you deliberately did not build, and what would change your mind, is the clearest Staff signal in the round.