Prompt
I’m planning a private AI assistant over our company docs, tickets, and CRM. What architecture should I use if I need citations, permissions-aware retrieval, and fresh sync from source systems?
Latest observation
For your use case, the safest and most practical pattern is:
Recommended architecture: RAG with permission-aware retrieval + incremental sync
Use a Retrieval-Augmented Generation (RAG) system, not fine-tuning, as the core. Add:
- Document ingestion pipeline from docs, tickets, CRM
- Chunking + metadata enrichment
- Two indexes:
- keyword / full-text index
- vector index
- Permission-aware retrieval layer
- Citation generation from retrieved source chunks
- Incremental sync / event-driven updates from source systems
High-level flow
-
Sync data from source systems
- Pull docs, tickets, CRM records via API/webhooks/ETL
- Normalize into a common document schema
- Store raw source payloads for traceability
-
Process and chunk content
- Split into semantically meaningful chunks
- Attach metadata:
- source system
- document ID
- title
- updated_at
- author/owner
- ACL / group / user permissions
- tenant/org ID
- URL / deep link
-
Index the content
- Vector index for semantic search
- Text index for exact match / filters / keyword recall
- Keep metadata filters alongside both
-
Query-time retrieval
- Resolve user identity and permission context
- Filter candidate documents/chunks by access rules
- Retrieve top-k chunks from vector + keyword search
- Rerank results if needed
-
Answer generation
- Send only approved chunks to the LLM
- Require the model to cite chunk IDs / URLs
- Render citations as footnotes or inline references
-
Freshness
- Use webhooks or change feeds where possible
- Fall back to scheduled incremental sync
- Reindex changed items only
- Handle deletes and permission changes immediately
Key design choices
1. Use RAG, not training, for citations and freshness
Fine-tuning is poor for:
- up-to-date content
- source attribution
- permission enforcement
- deletions and edits
RAG lets you:
- cite exact passages
- refresh data without retraining
- enforce ACLs at retrieval time
2. Make permissions a retrieval-time filter, not just a UI concern
This is critical.
You should enforce access in at least one of these ways:
- Pre-filtering: only search chunks the user can access
- Post-filtering: retrieve broadly, then remove unauthorized items before generation
- Pre-filtering is usually safer and more efficient
Best practice:
- store ACL metadata on every chunk
- compute effective permissions at sync time or query time
- filter before retrieval or at the database query layer
If permissions are complex, consider:
- document-level ACLs for simplicity
- chunk-level ACL inheritance from parent docs
- a centralized authorization service
3. Keep citation anchors immutable
For good citations, each chunk should have:
- stable chunk ID
- source URI
- source version or revision ID
- excerpt text
- timestamp
When generating answers, cite:
- document title
- section/chunk
- link to source
- optionally quoted snippet
Avoid citing ephemeral internal IDs alone.
4. Fresh sync should be incremental and event-driven
Ideal pattern:
- Webhook / event bus from source systems for create/update/delete
- Change detection job as fallback
- Idempotent indexing pipeline
- Versioning for content and permissions
You want the system to answer:
- what changed?
- what was deleted?
- who can now see it?
- is the index consistent?
Reference architecture
Core services
- Connectors: Jira, Zendesk, Salesforce, Confluence, Google Drive, SharePoint, etc.
- Ingestion/normalization service
- Authorization service
- Chunking/embedding service
- Search service
- full-text engine
- vector DB
- Reranker
- LLM orchestration service
- Audit/logging service
Data stores
- Object store for raw documents and snapshots
- Relational DB for metadata, ACLs, sync state, chunk mappings
- Search index for keyword retrieval
- Vector DB for semantic retrieval
- Optional: cache for user permissions and frequent queries
Suggested retrieval pattern
A strong pattern is:
- Identify user and their groups/roles
- Build permission filter
- Run hybrid search:
- vector similarity
- BM25 / keyword
- Merge candidates
- Rerank with a cross-encoder or LLM-based reranker
- Pass top chunks to the generator
- Generate answer with citations only from retrieved chunks
This gives:
- better recall
- better precision
- defensible citations
Handling source-system freshness
Best case
Use source system webhooks/events:
- doc updated
- ticket changed
- CRM record modified
- permissions changed
- record deleted
Fallback
Scheduled sync:
- poll every N minutes
- use
updated_since - diff by revision/hash
- reindex only changed chunks
Important
Track:
- source revision/version
- last sync time
- index state
- delete tombstones
- permission-change events
Without this, your assistant may cite stale or unauthorized content.
Security and governance recommendations
- Separate tenants/orgs strictly
- Encrypt data at rest and in transit
- Log every retrieval and answer generation event
- Redact sensitive fields before indexing if needed
- Support legal holds / deletion workflows
- Optionally store “answer provenance” for auditability
What I’d build first
If you want a pragmatic v1:
- One ingestion pipeline
- One metadata schema
- Hybrid search over docs/tickets/CRM
- ACL enforcement at query time
- Citations from chunk IDs and source links
- Incremental sync jobs every few minutes
- Webhooks later for high-freshness systems
In one sentence
Use a hybrid RAG architecture with permission-aware retrieval, stable chunk-level citations, and event-driven incremental indexing from source systems.
If you want, I can also give you:
- a concrete component diagram,
- a recommended tech stack, or
- a data model for ACL-aware chunks and citations.