Courses / RAG Systems / Module 15
Module 15: Architecture and system design for retrieval systems
10 h · theory 3 · hands-on 4 · project 2 · revision 1
You will be able to
- Compare RAG architectures on cost, latency and risk
- Apply a decision framework to an unseen brief
- Design for freshness, permissions and scale
- Defend a design in an interview
Capstone increment: Architecture decision records for the capstone, plus two design exercises with model answers.
Job-description skills: System design · Lab tools: mermaid
1. A catalogue of RAG architectures
From simplest to most complex: long context with no retrieval (put the documents in the prompt; viable for a few hundred pages, especially with prompt caching), single-shot RAG, hybrid retrieval with re-ranking (the right default for most enterprise assistants), agentic RAG for multi-hop questions, and GraphRAG for global and relationship questions. Fine-tuning sits beside all of them for behaviour, not knowledge.
Each step to the right adds capability and adds latency, cost, moving parts and failure modes. Choose the simplest design that meets the bar, and move right only for a measured gap.
2. A decision framework
Work through it in order. Requirements: users, question types, languages, accuracy bar, latency target. Constraints: corpus size and change rate, permissions, data residency, budget, team skills. Candidates: two or three architectures from the catalogue. Trade-off matrix: score each against weighted criteria using your measurements. Choice, with the risks and how you’ll detect them. Rollout: pilot users, metrics, gates.
Write it down as an architecture decision record: context, options, decision, consequences, and the numbers behind it. A short ADR per decision (chunking, embeddings, index, hybrid weights, caching) is what makes a system explainable a year later.
3. Design for freshness, permissions and scale
Freshness: how stale can an answer be? Nightly batch ingestion is fine for policies; ticket search may need minutes, which means event-driven ingestion and incremental indexing. Permissions: where do access lists come from, how fast must changes apply, and how do you test for leaks? Scale: documents, queries per second, tenants and growth, and which of them forces sharding.
Data residency matters in India for regulated sectors such as banking and health: know where documents, embeddings, logs and model calls are processed, and whether a hosted model in another region is acceptable.
4. Design exercise: HR policy assistant for 20,000 employees
Brief: answer HR and travel policy questions for 20,000 employees in English and Hindi, from 3,000 documents that change monthly, with answers limited to each employee’s location and grade. Try it yourself before reading the model answer.
Model answer: hybrid retrieval with re-ranking over structurally chunked policies with effective dates; permission filters by location and grade from the HR system; Hindi golden set and a multilingual embedding model; grounded answers with page citations and a “not found” path that names the HR contact; monthly batch ingestion with index versions; semantic cache scoped by location and grade. The scale is small (about 10,000 questions a day), so the risk is wrong or leaked answers, not throughput.
5. Design exercise: support search over 2 million tickets and docs
Brief: a SaaS company wants agents and customers to search 2 million support tickets, product docs and release notes, with p95 under 1.5 seconds, strict tenant isolation for customers, and freshness within 10 minutes.
Model answer: event-driven ingestion from the ticket system into an incremental pipeline; a shared index with an enforced tenant filter, plus separate collections for the largest enterprise tenants; hybrid search with re-ranking of the top 30; routing of metric questions (“how many open P1s?”) to SQL; exact and scoped semantic caches; quantized vectors with rescoring and replicas sized from a load test; evals per tenant segment in CI and drift monitoring on the not-found rate.
Hands-on: coding window
The coding window and the full VS Code lab are available after you sign in.
Sign in to codeLabs
Lab 15.1: Capstone ADRs
Write or finish ADRs for chunking, embeddings, index, hybrid retrieval, grounding, caching and permissions, each with the numbers from your experiments.
Expected: docs/adr/ with one short record per decision, linked from the README.
Lab 15.2: Design exercise 1
Do the HR assistant brief on paper in 45 minutes: diagram, estimates, trade-off matrix and risks. Then compare with the model answer and list what you missed.
Expected: A one-page design and a list of gaps.
Lab 15.3: Design exercise 2 with review (capstone increment)
Do the support-search brief, then swap designs with a peer (or the course’s AI professor) and review each other’s against the framework.
Expected: Your design, the review comments and a revised version in docs/designs/.
Go deeper
Videos
- How to Build a Scalable RAG System for AI Apps (Full Architecture) · ByteMonk · ~16 min. A full architecture for a scalable RAG system, component by component.
- Is RAG Still Needed? Choosing the Best Approach for LLMs · IBM Technology · ~11 min. When long context, RAG or other approaches fit, a useful frame for the first box of the catalogue.
- Are Vector Databases Still Needed? RAG, AI Agents & Search · IBM Technology · ~10 min. The case for and against a dedicated vector database as context windows grow.
Further reading
- Paper Retrieval-Augmented Generation for Large Language Models: A Survey · Gao et al., 2023. A map of naive, advanced and modular RAG and the techniques in each stage.
- 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 Building A Generative AI Platform · Chip Huyen. The components of a production GenAI system added one at a time, with the reason for each.
GitHub repositories
- architecture-decision-record/architecture-decision-record: ADR templates and examples; pick one template and use it for every capstone decision.
- Azure-Samples/azure-search-openai-demo: A reference RAG architecture with infrastructure as code; read its docs on design choices.
- onyx-dot-app/onyx: A production open-source enterprise search and assistant: connectors, permissions sync and hybrid search.
Checkpoint quiz
Interview questions
- Design a RAG system for a bank’s internal policies. Start with your questions.
- When would you choose long context over RAG, and when the reverse?
- How do you decide between single-shot, agentic and graph-based RAG?
- What goes in an architecture decision record, and why do teams skip it?
- Your design must keep data in India. What changes?
Ask the professor
Sign in to ask questions about this module.
Discussion
Community discussion appears here once giscus is configured (see README).