System design answer
Enterprise search with permissions
Connectors that sync content and permissions, permission-aware retrieval inside the search, and grounded answers with citations.
The question“Design an AI search assistant over a company's SharePoint, Jira and Google Drive, where each employee sees only what they are allowed to.”
1Clarify0-5 min
Ask before you draw. These answers change the design.
- Which sources, how many documents, how often do they change?
- How are permissions defined, and how fast must a revoked permission take effect?
- Do we answer questions or only find documents?
- Single sign-on provider?
2Requirements and numbers5-8 min
It must
- Search and answer across sources with citations
- Respect each source's access rights
- Show freshness and the source of every answer
And it must be
- A revoked permission applies within 10 minutes
- p95 answer under 6 s
- Audit log of who asked what and what was retrieved
Numbers to say out loud
- Corpus
- 2 million documents, about 40 million chunks
- Users
- 20,000 employees, peak 50 queries a second
- Change rate
- About 30,000 documents changed a day
3High-level design8-12 min
- SharePoint → delta sync → Connectors
- Jira → modified since → Connectors
- Google Drive → changes API → Connectors
- Connectors → Parse, chunk, embed
- Parse, chunk, embed → Index with allowed groups
- Employee → SSO → API
- API → Verified groups
- Verified groups → Hybrid search filtered by groups
- Hybrid search filtered by groups → Index with allowed groups
- Hybrid search filtered by groups → Rerank
- Rerank → Model
- Model → Answer with citations
4Deep dives12-26 min
Permissions
Store allowed users and groups on every chunk; filter inside the search before ranking; a chunk with missing permissions is visible to nobody. Re-sync permissions every 10 minutes and on webhook events, separate from content sync.
Connectors
Incremental sync with delta tokens, page through results, back off on 429s, resume after failure, and handle deletions. Every run logs read, added, changed, deleted and failed counts.
5Failures26-30 min
| What can go wrong | What stops it |
|---|---|
| A leak through stale permissions | Fast permission sync, deny by default, and an alert when sync lags |
| Connector falls behind | Lag metric per source and a backfill job |
| Answers mix old and new versions | Version metadata and filters for the latest |
6Evals and monitoring30-33 min
- Access tests: users from different groups must never see each other's restricted chunks
- Golden set of 200 questions with the expected source documents
- Freshness: time from edit to searchable
7Trade-offs33-35 min
- Filtering inside the search costs some speed but prevents leaks
- Answering vs only finding: answers are useful but need grounding and evals
Follow-ups to expect
- What happens when someone leaves a group?
- How would you search scanned PDFs?