Insights · AI
Enterprise RAG architecture: ingestion, retrieval, access control and evaluation
By the Cystem X Engineering Team - Published - 5 min read
In this article
Retrieval-augmented generation looks simple in a demo: embed documents, search, paste results into a prompt. Production systems fail in the details, namely messy documents, poor retrieval, leaked permissions and no way to measure quality. This guide covers the architecture decisions that separate a prototype from a dependable enterprise system.
Start with the documents
Quality begins at ingestion. Real documents include tables, headers, footnotes, scans and multiple languages. Parse structure rather than flattening to plain text, extract metadata such as title, owner and date, and record the source so answers can cite it.
Decide how updates and deletions flow through. Stale or withdrawn content that remains searchable is a quiet source of wrong answers.
Chunk with intent
Chunks must be small enough to be specific and large enough to hold meaning. Splitting along headings and sections usually beats fixed-length splitting. Adding context, such as the document title and section path, to each chunk improves retrieval.
Test chunking choices against real questions rather than assuming a size works.
Retrieval quality is the ceiling for answer quality.
Combine keyword and vector search
Vector search finds semantically similar text but can miss exact terms such as part numbers, names and acronyms. Keyword search does the opposite. Hybrid retrieval combines both, and a re-ranking model then orders candidates by relevance to the question.
Retrieval quality is the ceiling for answer quality. A model cannot use a passage it was never given.
Enforce access at retrieval time
Store access control metadata with every chunk and filter results using the identity of the person asking, so restricted content never enters the prompt. Do not rely on the model to withhold information it has been shown.
Synchronize permissions with the source systems, and test with accounts that should and should not see particular documents.
Generate grounded answers
Instruct the model to answer only from the provided context, cite the passages used and say when the context does not contain the answer. Keep prompts versioned and test changes.
Consider structured output so downstream systems can display citations and confidence signals reliably.
Evaluate continuously
Build a labelled set of realistic questions with expected sources and answers. Measure retrieval hit rate and answer correctness separately, so you know whether a problem lies in search or in generation.
Run the evaluation on every change to chunking, models or prompts, and monitor production with sampled human review and user feedback.
Deploy and operate securely
Decide where models and indexes run. Many regulated organizations host both on-premises or in a sovereign region. Log queries and retrievals for audit, protect against prompt injection hidden in documents and rate limit usage.
Plan for re-indexing, model upgrades and growth, because content and usage rise steadily after launch.
Key takeaways
- Parse document structure and keep metadata and source links.
- Chunk by structure and test sizes against real questions.
- Use hybrid retrieval with re-ranking.
- Enforce document permissions at retrieval, not in the prompt.
- Evaluate retrieval and answers separately and rerun on every change.
Sources and further reading
This article reflects general practice and publicly available guidance. Teams should consult primary sources, including the NIST AI Risk Management Framework, the OWASP Top 10 for LLM Applications and the documentation of your chosen search and vector technologies, and adapt the guidance to their own environment, risk appetite and legal obligations.
Keep reading
More engineering guidance from the Cystem X team.
AI
Agentic AI with bounded autonomy: design patterns for safe automation
Give agents real tools without unlimited power: permissions, approvals, limits and observability.
Read articleAI
Building an LLM evaluation harness you can trust
Datasets, metrics, judges and regression tests: how to know whether an LLM application is improving.
Read articleAI
Sovereign AI and data residency: what it means and how to deliver it
Keep data, models and operations inside a chosen jurisdiction: drivers, architectures and controls.
Read articleRAG & Enterprise Search
Build RAG that your security team can approve.
We design, build and evaluate permission-aware retrieval systems in cloud, on-premises and air-gapped settings.
Explore RAG & Enterprise Search