Design a RAG Document Q&A System

Retrieval-augmented Q&A over company documents inspired by Perplexity, Notion AI and Glean: documents split into overlapping passages and embedded by workers, hybrid vector and keyword retrieval, cross-encoder re-ranking, answers grounded in cited passages, an answer cache keyed by meaning and document version, and access lists enforced inside retrieval. A teaching design.

Functional requirements

  • Users can upload documents and connect apps such as Drive and Notion.
  • Users ask questions in plain language and get an answer drawn from their documents.
  • Every answer cites the passages it used.
  • Users only get answers from documents they are allowed to read.
  • Edited and deleted documents are reflected in answers within minutes.

Non-functional requirements

  • Answer latency: first words within 2 seconds.
  • Scale: 5M daily users, 2K requests/s at peak, 500M passages indexed.
  • New documents are searchable within minutes.
  • Never leak content across permission boundaries.
  • Availability: 99.9%.

How the design evolves

Stage 1: Paste Every Matching Document into the Prompt

See why keyword matching plus a giant prompt is slow, expensive and often wrong.

What was missing: Nothing yet.

Why that's risky: Keywords miss documents that say the same thing in other words, and match many that don't help. Long prompts are slow and costly, and they overflow the model's context window. The model may answer from its own memory instead of the documents.

What gets added: One server that finds documents containing the question's keywords and pastes all of them into the LLM prompt.

Trade-offs: No indexing work at all, paid for on every single question.

Stage 2: Split, Embed and Retrieve the Right Passages

Send the model only the few passages that answer the question.

What was missing: Whole documents went into the prompt, found by keyword.

Why that's risky: Pure vector search misses exact terms like error codes and product names, 20 passages is still a lot of prompt, and the same questions are answered from scratch again and again.

What gets added: Uploads are saved and queued. Embedding workers split each document into overlapping passages of about 500 tokens, turn each into a vector, and store it in a vector index. A question is embedded the same way, its 20 nearest passages are retrieved, and only those go to the LLM, which must answer from them and cite them.

Trade-offs: Passages that are too small lose context, and passages that are too large dilute the match. About 500 tokens with some overlap is a common starting point.

Stage 3: Hybrid Search, Re-ranking and an Answer Cache

Find exact terms as well as meanings, send fewer and better passages, and skip repeat work.

What was missing: Vector search alone missed exact terms, prompts carried 20 passages, and repeat questions cost the same as new ones.

Why that's risky: Everyone sees passages from every document, including ones they aren't allowed to open, and edited documents can leave old passages behind.

What gets added: Retrieval combines nearest-neighbour search with keyword search (hybrid), a small cross-encoder re-ranks the candidates and keeps the best 5, and an answer cache returns recent answers when the question means the same thing and the cited documents haven't changed.

Trade-offs: Re-ranking adds about 40ms but noticeably improves which passages reach the model. Cached answers can be slightly stale until a cited document changes.

Stage 4: Permissions and Fresh Documents

Never show a passage the user can't open, and keep answers current as documents change.

What was missing: Retrieval ignored who may read what, and stale passages outlived edits.

Why that's risky: One load balancer, no per-user limits on an expensive LLM, and no measure of answer quality.

What gets added: Each passage carries its document's access list, and retrieval filters to documents the user can read before ranking. Changes from connected apps are re-processed: a new version's passages replace the old ones, and deleted documents are removed from the index.

Trade-offs: Access lists are copied into the index, so a permission change takes effect after the document is re-processed, usually within a minute.

Stage 5: Limits, Redundancy and Quality Monitoring

Control LLM spend, and know when answers get worse.

What was missing: No spending limits, a single load balancer and index, and no idea whether answers were good.

Why that's risky: Remaining risk is the LLM provider: if it is down, answers stop, though retrieval can still return the relevant passages.

What gets added: A rate limiter per user and workspace, a second load balancer, index and re-ranker replicas, more query instances, and monitoring of latency, ingest lag, thumbs-down rate and how often the cited passages actually contain the answer.

Trade-offs: Measuring quality needs a sample of graded answers, which costs people's time or an extra model call.

PRISM
System Design Interview
Round 1 of 4 · Architecture Design · 60:00 remaining
PRISM logo
AI Interview
Interview Prep
Interview Challenges
Build & Stress Test NEW
System Architectures
Design & Fix NEW
Interactive Roadmap System Design Guides
Notifications
  • No new notifications
Feedback
Signed in
Send feedback
Phase
Build & Stress Test
Phase 01: Thinking in Systems
Upcoming

Components

User
CDN
Load Balancer
Server
Cache
Database
Blob Storage
Search Index
Queue
Worker
Rate Limiter
Service
API Gateway
Reverse Proxy
WebSocket Server
Third-party API

Inspector

Notes
Use clear names so your design intent is easy to understand.
Good
Name by business meaning
"Order API", "Restaurant Service"
Avoid
Generic names = zero signal
"Server 1", "API", "Queue"
A short description for each component makes feedback much better.
100%
Start by identifying:
  • Users & entry points
  • APIs & services
  • Databases & storage
  • Traffic flow & scale

Round 1 of 4 Architecture Design

Run a simulation to see results.

Time Remaining
60:00
System Design Interview

What are the core functional requirements?
What are the key non-functional constraints?

Questions

Start Evaluation to unlock questions.

EVALUATE MODE

Test yourself like it's the real thing.

A structured 4-module evaluation that mirrors how top companies assess system design candidates.

Architecture Design
Draw your system on the canvas. Define components, connections, and data flow.
FR & NFR Requirements
Answer functional and non-functional requirement questions about your design.
MCQ Round
Multiple choice questions testing your depth on the chosen system.
Tradeoff Analysis
Justify your design decisions and defend your architectural tradeoffs.
AI Report Generated
Choose a Problem
No problem selected
  • 30 min
  • 45 min
  • 60 min
Round 2 of 4
MCQ Round
Answer multiple-choice questions based on your design.

Exit Interview?

You're in the middle of an interview session. Leaving now will end your current attempt.

Your progress will be saved.

Open a saved design

Select a design to load into the canvas.

My Evaluations

Your past evaluation sessions

Here’s a simple request flow that follows the expected layer order.

External User
→
Edge CDN → API Gateway → Load Balancer
→
Compute App Servers / Services
→
DataAccess Cache
→
Storage Database / Search Index
→
Async Queue → Worker

Tip: keep arrows moving forward through layers (Edge → Compute → Storage). Avoid sending storage back to compute.

Evaluation Instructions

Read the rules carefully before starting. The test auto-submits on refresh.

Before you start

  • Build your architecture on the canvas. The timer starts when you click Start Evaluation.
  • Don't forget to answer Functional Requirement and Non Functional Requirements.
  • When satisfied with your design, click Next to lock it and view the questions.
  • Please answer final step questions to complete the evaluation.

Dos

  • Do read each question carefully before answering.
  • Do include required components to maximize component coverage.
  • Do save a copy of your design if you want to keep it before submission.

Don'ts

  • Don't refresh or close the tab during an active evaluation — this will auto-submit your answers.
  • Don't switch app modes or open another tab while the evaluation is running.
  • Don't attempt to edit the design after clicking Next; the workspace will be locked.

All the best!!

Confirm

Input

Notice

Evaluation Report

Evaluation Complete

Generating Your Report

Hang tight — our AI is evaluating your design…

Did you know?

Loading…

Share feedback

Tell us what worked well and what we can improve.

Let's personalize this

Answer a couple of quick questions so we can tailor your journey and missions.

Your welcome gift: of Full PRISM Access

You can change these answers from Mission Control until your missions are done.

Your personalized missions are ready

We tailored these first steps based on your answers.

    PRISM Welcome Gift

    This is a personal welcome gift from PRISM.

    Congratulations.

    You explored PRISM.

    You earned Apprentice.

    As a welcome gift, unlock Full PRISM Access for the configured trial duration.

    This starts Trial. Trial timer begins only after you activate this gift.

    Welcome to PRISM

    We've prepared a personalized Apprentice Journey based on your goals and experience.

    This journey introduces you to the capabilities of PRISM that are most relevant to you.

    Complete all 5 missions to earn your Apprentice title. 5 MISSIONS

    PRISM Surprise Offer

    Complete your Apprentice Journey to unlock a special gift from PRISM.

    • No payment required
    • No credit card required
    • Just complete the journey
    MISSION CONTROL
    0 / 8 missions complete
    NEXT UP Continue your missions
    View full roadmap →
    Mission Complete 0 / 8 Completed Next: Keep going
    SYSTEM BRIEF

    System Constraints

    What the system must do — every item is a user-facing behaviour your architecture must support.

      ↑ Engineering Constraints

      These are the failure modes you must design against — latency SLAs, durability targets, traffic ceilings.

        ⇆ Architecture Constraints

        Core Concepts to Master

        Your Journey
        PHASE – –
        0 / 0 0%
        0
        Mock Interview Checklist

        Pick a topic to start

        Explore concept overviews, real-system examples, key tradeoffs, and interview talking points for each roadmap section.

        Phase Mastered

        You've conquered this phase. These are the skills you now own:

          +500 XP

          Company Interview Paths

          Progress Summary