KatInterview

Design a Retrieval-Augmented Chatbot with Access Control

System DesignModel answer
MediumModel answerSystem Designretrieval-augmented-generationaccess-controlembeddings

Last updated

Build a chatbot that answers employee questions from internal docs while enforcing document-level permissions and maintaining response quality.

You're building a conversational assistant that lets employees ask questions about company knowledge—product documentation, internal policies, engineering runbooks, and compliance materials. The assistant must generate answers grounded in these documents, respect who can see what, and handle thousands of concurrent users without degrading performance.

What the System Must Do

Core Capabilities

  • Accept natural language questions and return synthesized answers backed by real documents
  • Show which documents were used to form each answer
  • Remember earlier turns in a conversation so follow-up questions make sense

Performance and Scale

  • Serve a user base of 10,000 employees with peaks during business hours
  • Keep median response time under 2 seconds from question to first visible token
  • Scale to 100,000 users without fundamental redesign

Security and Compliance

  • Honor existing access controls: if a user cannot open a document in the source system, they must not receive answers derived from it
  • Prevent information leakage through conversation history or caching

What You Should Provide

  1. Architecture overview — describe the main components, data flow, and how they interact (text description is fine; a diagram is not required)
  2. Storage approach — explain how you store documents, vector representations, metadata, and conversation state
  3. Permission enforcement strategy — detail how you ensure users see only what they're authorized to see, and where in the pipeline you enforce this
  4. Answer quality controls — describe techniques to keep answers accurate and grounded in real content rather than model confabulation

Assume the company uses standard identity providers (OIDC or SAML) and document repositories like Confluence, SharePoint, or object storage with associated permission metadata.

Hints

Hint 1

Start by estimating queries per second under realistic load patterns—clarifying scale shapes every other decision

Hint 2

Pre-filtering at retrieval time is fundamentally different from post-filtering results; consider which approach protects both performance and security

Hint 3

Think through what happens when a document's permissions change after it has been embedded and indexed