Courses / GenAI & LLM / Module 13
Module 13: Architecture and system design for LLM applications
12 h · theory 4 · hands-on 5 · project 2 · revision 1
You will be able to
- Compare RAG, agentic, fine-tuned and hybrid architectures on cost, latency and risk
- Apply a decision framework to an unseen brief
- Draw and defend an end-to-end design
- Plan a project from scope to rollout
Capstone increment: Architecture Decision Records (ADRs) for the capstone, plus 3 design exercises with model answers.
Job-description skills: System design, Architecture · Lab tools: mermaid
1. The shape of most LLM systems
Strip away the branding and most GenAI products share one shape: a client, an API with auth and rate limits, an orchestration layer (a fixed workflow or an agent), a model gateway, retrieval over your data, guardrails on the way in and out, and evaluation and observability around everything. Design is deciding which of these boxes you need, how big each must be, and what each one costs.
Start every design from requirements, not technology: who the users are, what a correct answer is worth and what a wrong one costs, latency targets, traffic, data sensitivity, budget and team size. The architecture follows from those.
2. The main architectures and when to use them
Prompt only: one well-engineered call to a capable model. Fastest to build; fine for tasks the model already knows. Weak when answers depend on private or changing data.
RAG: retrieval over your documents plus generation with citations. The default for knowledge questions over private, changing content. Costs: an ingestion pipeline, index upkeep and retrieval evals.
Fine-tuned model: a small model trained for one behaviour. Best for high-volume, narrow tasks where latency and cost per call dominate, or data can't leave your servers. Costs: data work, training, and re-training when base models change.
Agent: a model choosing tools in a loop. For tasks whose steps can't be known in advance. Costs: higher latency and spend, harder testing, and a larger security surface.
Hybrids are normal: a workflow with RAG for context, a small fine-tuned model for the high-volume step, and a larger model as the escalation path.
3. A decision framework
Use the same steps for any unseen brief: (1) restate the problem and the success metric; (2) list constraints: latency, traffic, data residency, budget, team; (3) name two or three candidate architectures; (4) score them in a trade-off matrix against weighted requirements; (5) choose, and write down the main risks; (6) plan the rollout: a thin end-to-end slice first, evals before scale, and a staged release.
Record each significant decision as an Architecture Decision Record (ADR): context, decision, alternatives considered, consequences. ADRs are short, live in the repo, and are the best evidence in an interview that you made deliberate choices.
4. Numbers every design needs
Estimate traffic (average and peak queries per second), tokens per request, monthly model cost, and a latency budget split across stages (retrieval, re-ranking, first token, guardrails). These back-of-the-envelope numbers decide between an API and self-hosting, between a large and a small model, and whether caching is essential.
Design for failure: what happens when the model provider is down (fallback model, queue, graceful message), when retrieval returns nothing (honest not-found), and when costs spike (budgets and alerts).
5. Design exercises
Practise on three briefs and compare your design with the model answers in the course repository: (1) a multilingual agri-advisory assistant for farmers on low-end phones with patchy connectivity; (2) contract review for a law firm where nothing may leave its servers; (3) an internal IT helpdesk agent that can reset passwords and open tickets.
For each: requirements, a diagram, the chosen architecture with an ADR, a cost and latency estimate, an evaluation plan, the top three risks, and a rollout plan. Time-box each to 90 minutes, like a take-home assignment.
Hands-on: coding window
The coding window and the full VS Code lab are available after you sign in.
Sign in to codeLabs
Lab 13.1: ADRs for the capstone (capstone increment)
Write ADRs for the capstone’s main decisions: model choice and routing, structured-output approach, confidence and review design, hosting, and observability tool. Each with context, decision, alternatives and consequences.
Expected: Five ADRs in docs/adr, each under one page, linked from the README.
Lab 13.2: Three design exercises
Complete the three design briefs from section 5 with a diagram, ADR, cost and latency estimate, eval plan, risks and rollout. Compare each with the model answer and note what you missed.
Expected: Three design documents and a list of the gaps you found against the model answers.
Lab 13.3: Defend a design
Present one design to a peer (or record yourself) in 10 minutes, then answer 10 minutes of hard questions on cost, failure modes and alternatives.
Expected: A recording or notes, and a revised ADR reflecting the best challenge you received.
Go deeper
Videos
- How We Build Effective Agents: Barry Zhang, Anthropic · AI Engineer · ~15 min. Workflow patterns versus agents: the core architectural choice in most designs.
- Design ChatGPT - System Design Mock Interview (with eBay EM) · Aced (formerly Exponent) · ~35 min. A full LLM system design worked through end to end, with trade-offs said out loud.
Further reading
- Article Building A Generative AI Platform · Chip Huyen. The components of a production GenAI system added one at a time, with the reason for each.
- Article What We've Learned From A Year of Building with LLMs · Yan, Bischof, Frye, Husain, Liu, Shankar. Tactical, operational and strategic lessons from people who shipped LLM products.
- Article Patterns for Building LLM-based Systems & Products · Eugene Yan. Seven patterns with when to use each; good input for the trade-off matrix.
GitHub repositories
- architecture-decision-record/architecture-decision-record: ADR templates (Nygard, MADR) and examples; pick one for the capstone.
- chiphuyen/aie-book: Resources for the AI Engineering book, especially the chapters on architecture and the AI engineering stack.
- anthropics/claude-cookbooks: patterns/agents: runnable versions of chaining, routing, parallelisation and orchestrator-workers.
Checkpoint quiz
Interview questions
- Design a multilingual support assistant for an Indian bank. Walk through requirements, architecture, cost and risks.
- RAG, fine-tuning or an agent: how do you decide for a new project?
- Estimate the monthly model cost for 50,000 users asking 3 questions a day.
- What happens in your design when the model provider goes down?
- Tell me about an architecture decision you made, the alternatives, and what you’d change now.
Ask the professor
Sign in to ask questions about this module.
Discussion
Community discussion appears here once giscus is configured (see README).