Skip to content

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.

Long context< ~100 pagesSingle-shot RAGvectors, top-kHybrid + rerankthe defaultAgentic RAGmulti-hop, toolsGraphRAGglobal questionsFreshnessbatch vs streamingPermissionsper-doc ACLScaledocs, QPS, tenantsCost₹ per answerPick the simplest that meets the barCross-cutting choices
Each step to the right adds capability and adds latency, cost and failure modes. Justify every step with 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.

Common misconception: “Architecture is picking the best tools.” Architecture is choosing trade-offs on purpose and writing down why, so the next person can change them safely.

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.

Tip: In interviews, state the numbers you assume and the one risk you’d watch most closely. That is what makes a design sound like it came from someone who has run one.

Hands-on: coding window

The coding window and the full VS Code lab are available after you sign in.

Sign in to code

Labs

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

Further reading

GitHub repositories

Checkpoint quiz

1. The corpus is 80 pages that rarely change. Simplest design to try first?
2. What belongs in an ADR?
3. Freshness within 10 minutes points to…
4. For the 20,000-employee HR assistant, the biggest risk is…
5. When should you move to a more complex architecture?

Interview questions

  1. Design a RAG system for a bank’s internal policies. Start with your questions.
  2. When would you choose long context over RAG, and when the reverse?
  3. How do you decide between single-shot, agentic and graph-based RAG?
  4. What goes in an architecture decision record, and why do teams skip it?
  5. 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).