KatInterview

Design a RAG-Powered Internal Knowledge Assistant

System DesignModel answer
MediumModel answerSystem Designragvector-searchaccess-control

Last updated

Architect a multi-turn chatbot that retrieves answers from internal docs using RAG, enforces per-user access controls, and handles traffic spikes under a 2-second latency budget.

Context

Your company wants to replace the "search and hope" workflow for internal documentation. Employees currently dig through wikis, project trackers, and ticket archives to find answers. The goal is a conversational assistant that understands follow-up questions, grounds every answer in real documents, and respects the fact that not everyone is allowed to read everything.

Functional Requirements

  1. Employees ask questions in natural language and get responses that cite specific internal documents.
  2. The assistant remembers what was said earlier in a conversation for at least 10 minutes.
  3. When the system is not confident in its answer, it routes the conversation to a human support agent rather than guessing.
  4. Answers must never be fabricated — every claim must be traceable to a document the user is authorized to see.

Non-Functional Requirements

  • Latency: first token of the response within 2 seconds at p95, with the rest streamed.
  • Concurrency: 10,000 simultaneous users across global time zones; plan for 5–10x spikes during company-wide events.
  • Correctness: minimize hallucinations by strictly grounding the model in retrieved context.
  • Security: a user must never receive content from a document they lack permission to access — even indirectly through timing signals or result counts.

What to Cover

Produce a high-level architecture design that addresses:

  1. Ingestion pipeline — how documents get chunked, embedded, and indexed, including how ACL metadata flows into the index.
  2. Retrieval and inference pipeline — the full path from a user's typed question to a streamed, cited answer, including how multi-turn context is handled.
  3. Storage schemas — how you store conversation state and document embeddings; what databases you choose and why.
  4. Access control strategy — how you enforce document-level permissions inside the retrieval step, not just at the API boundary.
  5. Post-deployment monitoring — how you detect when answer quality or retrieval relevance degrades over time.

You are expected to state your assumptions, justify your component choices, discuss trade-offs, and flag the trickiest failure modes.

Hints

Hint 1

Start by sizing the problem: estimate corpus size in chunks, embedding storage in GB, steady-state QPS, and peak QPS. Interviewers watch whether you anchor decisions in numbers or just name technologies.

Hint 2

Access control is the hardest sub-problem. Think about where filtering happens — pre-filter inside the ANN search vs. post-filter after retrieving top-k — and what goes wrong in each case when a user's permissions are very restrictive.

Hint 3

A 2-second latency target covers several sequential steps. Sketch a latency budget that allocates time to auth, query rewriting, embedding, retrieval, reranking, and LLM time-to-first-token. That budget exposes which steps need caching or can run in parallel.