Production patterns, real tradeoffs, interview-grade depth

AI System Design Guide

One hundred and eight chapters on how production AI systems are actually built: retrieval, agents, inference economics, evaluation, and the failure modes that never make it into a launch post. Written for engineers shipping LLM systems and for the staff-level interviews that interrogate them. It is a repository rather than a book because the model landscape rewrites itself faster than a print run.

108
chapters
162k
words
780
code samples
15
case studies
01 eighteen sections

The guide

00 Interview Prep Everything for the interview itself: the questions that get asked, the structures that make answers land, the mistakes that lose offers, and seven worked whiteboard problems 5 pages · 146 min 01 Foundations The mechanics under every later decision — tokens, attention, transformer blocks, embeddings, and the two-phase inference loop — explained at the depth a system designer needs 6 pages · 68 min 02 Model Landscape Which model to use and what it will cost: the field as of March 2026, how to assess capability for your own task, and pricing you can forecast 4 pages · 40 min 03 Training and Adaptation How models are built and then bent to a purpose — pretraining, SFT, LoRA, preference alignment, distillation, synthetic data, quantization — in the order those steps actually happen 7 pages · 21 min 04 Inference Optimization Making generation fast and cheap: the prefill and decode split, KV cache pressure, speculative decoding, continuous batching, PagedAttention, fleet serving, and a cost playbook 7 pages · 21 min 05 Prompting and Context Getting reliable behavior out of a model you cannot retrain — instruction design, example selection, reasoning elicitation, context budgeting, schema-constrained output, automatic optimization, injection defense 8 pages · 26 min 06 Retrieval Systems RAG end to end — chunking, embeddings, vector stores, hybrid search, reranking, graphs and agentic loops — with the failure modes that show up at each stage 12 pages · 57 min 07 Agentic Systems Building systems that take actions rather than answer questions: reasoning loops, tool protocols, multi-agent teams, planning, failure recovery, human oversight, sandboxing and trajectory evaluation 10 pages · 32 min 08 Memory and State How an AI system remembers: the tiered memory hierarchy, live context management, cross-session persistence, extracted-fact stores, semantic caching, and agent state that survives a crash 6 pages · 17 min 09 Frameworks & Tools Ten frameworks judged on what they cost you in production — LangChain, LangGraph, LlamaIndex, DSPy, Semantic Kernel, CrewAI, AutoGen — ending in a decision matrix and the coding-agent landscape. 10 pages · 43 min 10 Document Processing One chapter, because document parsing collapsed into a single question: rasterize the page and let a vision model read it, or keep maintaining an OCR pipeline? 1 pages · 3 min 11 Infrastructure & MLOps The operational layer: where self-hosting starts beating API pricing, how you autoscale GPU capacity, and how a prompt change gets through CI without shipping a quality regression. 2 pages · 14 min 12 Security & Access The LLM-specific attack surface — injection through retrieved content, extraction, unsafe tool output — plus the access-control machinery that keeps one tenant's data out of another tenant's answers. 2 pages · 16 min 13 Reliability & Safety Two different problems under one heading: keeping the system up when a provider fails, and keeping the output safe when the model says something it should not. 4 pages · 34 min 14 Evaluation & Observability How you know the system is good, and how you know it still is: judge design, retrieval scores, traces, token spend, and drift alerts on live traffic. 2 pages · 18 min 15 Design Patterns A pattern catalog and its shadow: seventeen named moves that work, then fifteen that look reasonable and quietly cost you accuracy, money, or an outage. 2 pages · 17 min 16 Case Studies Fifteen full designs, each starting from the constraint that makes it hard: 100ms fraud decisions, HIPAA-bound voice notes, two direct competitors on one vector database. 15 pages · 79 min 17 Reference The lookup shelf: every term defined, every pattern in one line, courses worth the time, a role-transition map, and the guide's single deepest chapter. 5 pages · 116 min
02 where to start

Learning paths

Curated routes through the guide. Each is a reading order, not a syllabus.

Prepare for interviews

5 pages · 127 min

The question bank and the answer frameworks first, then two case studies to practice saying the architecture out loud.

  1. Interview Question Bank

    Eighty numbered questions across RAG, agents, model selection, optimization, evaluation and MLOps, each paired with what interviewers are listening for in the answer

  2. Answer Frameworks

    Five reusable answer structures — SPIDER for system design, ETA for concepts, STAR-L for behavioral — plus what to say when you don't know

  3. Common Pitfalls

    The mistakes that sink otherwise strong candidates: skipping the data pipeline, hand-waving evaluation, over-designing, and talking past the interviewer's actual question

  4. Multi-Tenant AI SaaS

    Coca-Cola and Pepsi on shared infrastructure: hybrid namespace-versus-dedicated-pod isolation, defense in depth on every query, and GDPR deletion that truly removes embeddings.

  5. Real-Time AI Search Engine

    Market intelligence with a five-minute freshness guarantee: Kafka ingestion into paired vector and full-text indexes, RRF fusion, sourced answers inside three seconds.

Learn AI systems fast

5 pages · 49 min

The shortest route from transformer internals to a working mental model of retrieval, model choice and the patterns that recur everywhere.

  1. LLM Internals

    The moving parts inside a transformer LLM — attention, feed-forward blocks, position encodings, MoE routing — and the scaling laws that set what any of it costs

  2. Embeddings and Vector Spaces

    What a vector actually encodes, which distance metric to use, and how Matryoshka truncation and binary quantization cut index size without wrecking recall

  3. RAG Fundamentals

    Grounding versus training as the core choice, the current RAG taxonomy, and where a two-million-token context window makes retrieval unnecessary — and where it does not

  4. Model Taxonomy

    A map of the March 2026 model field — frontier, reasoning, fast, open-weight, specialized — with the capability tiers and residency constraints that narrow your shortlist

  5. AI Design Patterns

    Seventeen named patterns from naive RAG through Corrective RAG, plan-and-execute agents, model cascades and token budgets, each with a when-to-use and a stated cost.

Build production RAG

5 pages · 21 min

Chunking, vector store selection and reranking, ending in the 500,000-document enterprise build that uses all three.

  1. RAG Fundamentals

    Grounding versus training as the core choice, the current RAG taxonomy, and where a two-million-token context window makes retrieval unnecessary — and where it does not

  2. Chunking Strategies

    Small chunks find, large chunks explain — resolve that tension with recursive structure splitting, semantic boundaries, and parent-child hierarchies tuned per content type

  3. Vector Database Comparison

    A vendor-by-vendor read on Pinecone, Qdrant, Weaviate, Milvus and pgvector, scored on scale, filtering, tenancy and the real cost of managed versus self-hosted

  4. Reranking Strategies

    The bi-encoder to cross-encoder funnel in brief, with listwise LLM reranking and distilled small-model rerankers weighed against the milliseconds they add per query

  5. Enterprise RAG

    A financial firm's 500,000-document search, where daily updates, department permissions and mandatory citations drive the shift from small-chunk RAG to million-token balanced context.

Build agents

6 pages · 27 min

Loops, tools and MCP, then LangGraph for state, then sandboxing — because the interesting failures are all about what an agent is allowed to do.

  1. Agent Fundamentals

    What separates an agent from a chatbot — reasoning model, tools, memory, environment feedback — and the autonomy levels you should deliberately choose between

  2. Tool Use and MCP

    Tool schemas, the Model Context Protocol with its Streamable HTTP and auth updates, computer-use tools, and how MCP differs from plain function calling

  3. LangGraph Orchestration

    Agents as graphs: nodes, conditional edges and a typed state schema, with checkpointing that lets a run pause for human approval and resume later.

  4. Agentic Security and Sandboxing

    An injected agent does not leak data, it acts — so isolate execution in sandboxes, scope credentials to minimum agency, proxy every call, and log the trail

  5. Claude Code

    Anthropic's terminal-native coding agent end to end: the tool loop, the CLAUDE.md manifest, sub-agent parallelism, permission model, and headless use inside CI.

  6. Autonomous Coding Agent

    A planner-coder-debugger loop running inside an E2B sandbox on thousand-file repos, iterating until the test suite passes, for under fifty cents a task.

Run it in production

5 pages · 42 min

Evaluation before observability, reliability before guardrails, security throughout, and a release pipeline that can catch a bad prompt.

  1. LLM Evaluation

    Building an eval that can actually fail: quality dimensions, calibrated LLM judges, human annotation, RAGAS-style retrieval scores, and monitoring that runs on live traffic.

  2. LLM Observability

    Logs, metrics and traces reshaped for non-deterministic systems, where quality ranks alongside latency as a first-class signal and cost is attributed per pipeline step.

  3. Reliability Patterns

    Retry with jittered backoff, circuit breakers, bulkheads, per-stage timeouts, graceful degradation and multi-provider failover, each sized against a real availability target.

  4. LLM Security

    Prompt injection, indirect injection through retrieved content, data extraction and unsafe output, mapped onto the OWASP LLM Top 10 with layered defenses and red-team tests.

  5. CI/CD for LLM Applications

    Shipping prompt and model changes safely: staged eval suites, quality gates that block a regression, canary rollout, and a rollback that actually works.

Move into an AI role

4 pages · 134 min

Map your current job to a target role, close the gaps with vetted courses, then come back through the interview prep section.

  1. Role Transition Guide

    Backend, QA, PM, EM and data engineers mapped onto AI roles: which existing skills transfer, which gaps to close, and which chapters close them.

  2. Courses & Learning Paths

    Verified courses per topic, from Karpathy and Stanford CS324 to the DeepLearning.AI shorts and the Maven evals course, with role-based sequences through them.

  3. Glossary

    Every term the guide uses, defined once: ABAC and BM25 through MCP and SWE-bench Verified to zero-shot, so the chapters can stay dense.

  4. Interview Question Bank

    Eighty numbered questions across RAG, agents, model selection, optimization, evaluation and MLOps, each paired with what interviewers are listening for in the answer

Last Updated · March 2026License · MITPRs WelcomeStars
03navigation

📚 Quick Navigation

I want to...Start here
Prepare for interviewsQuestion BankAnswer Frameworks
Learn AI systems fastLLM InternalsRAG Fundamentals
Build production RAGChunkingVector DBsReranking
Design multi-tenant AIIsolation PatternsCase Study
Build agentsAgent FundamentalsMCPLangGraph
Autonomous coding agentsClaude CodeOpenCoder Landscape
Pick the right model (2026)Model TaxonomyPricing
Evaluate AI in productionAI Evals Guide (Phoenix/Langfuse)AI Evals Guide (LangWatch/Langfuse)
Find the best courses to learn AIRecommended Courses & Learning Paths
Transition from my current role to AIRole Transition Guide
04guide

🎯 Why This Guide

Traditional books are outdated before they ship. This is a living document: when new models release, when patterns evolve, this updates.

This GuidePrinted Books
March 2026 models (Claude 3.7 Sonnet, GPT-4.5, o3, Gemini 2.0 Flash, Grok 3)Stuck on GPT-4
MCP, Claude Code, Agentic RAG, OpenCoder landscapeDoes not exist
Real pricing with verification datesAlready wrong
Staff-level interview Q&AGeneric questions
05structure

📖 Guide Structure

07deep-dive guides

🔬 Bonus Deep-Dive Guides

Two companion guides (3,000+ lines each) covering AI evaluation end-to-end — for Engineers, PMs, and QAs:

GuidePlatforms CoveredWhat's Inside
AI Evals: Comprehensive Study GuideArize Phoenix + LangfuseLLM-as-a-Judge, RAG eval, multi-turn eval, production safety, statistical correction with judgy, 30-day learning path
AI Evals: LangWatch + Langfuse GuideLangWatch + LangfuseSame syllabus with LangWatch's 40+ built-in evaluators, side-by-side platform comparisons, platform choice guidance

Topics covered across both guides:

  • Tracing and observability setup (Phoenix, LangWatch, Langfuse)
  • Error analysis: open coding → axial coding → failure mode taxonomy
  • Building LLM judges with Train/Dev/Test split and ground truth calibration
  • Code-based evaluators (regex, JSON schema, format validators)
  • RAG-specific evals: faithfulness, context recall, answer relevance
  • Multi-step pipeline evaluation and multi-turn conversation eval
  • Production guardrails, safety monitoring, real-time drift detection
  • Statistical correction with judgy library
  • Human annotation best practices and inter-rater reliability
  • Cost/latency optimization for eval pipelines at scale
08prep

🎓 For Interview Prep

AI system design interviews ask questions like:

This guide gives you concrete patterns, real tradeoffs, and production failure modes: the depth interviewers expect at senior levels.

➡️ Start with Interview Prep

09book

🔄 Living Book

This guide tracks:

  • New model releases and real-world performance
  • Emerging patterns (MCP, Agentic RAG, Flow Engineering)
  • Updated pricing and rate limits
  • Deprecations and best practice changes

⭐ Star and Watch to get notified when updates are pushed.

10contributing

🤝 Contributing

Found outdated info? Have production experience to share? PRs welcome. See Contributing Guide.

11license

📄 License

MIT License. See LICENSE.


Last updated: March 2026