Project 01 · 2026
Meridian.
Enterprise RAG with access control enforced before retrieval
High-level architecture
Overview
Enterprise Retrieval-Augmented Generation platform built with FastAPI, PostgreSQL + pgvector, SeaweedFS, React, and Ollama. Features a PDF ingestion pipeline (extract, chunk, embed), document-level access control enforced before retrieval, BM25 / dense / hybrid / graph retrieval modes, cross-encoder reranking, and grounded local answers with citations.
What I built
- 01Ingestion pipeline: PDF upload, page-aware extraction, token-based chunking, embeddings, entity graph indexing
- 02Document-level ACLs resolved per user, team and department; unauthorized chunks are filtered before reranking or LLM context
- 03Four retrieval modes: BM25, dense, hybrid and graph, with optional cross-encoder reranking
- 04Grounded answers from a local LLM with citations mapped back to source chunks
Deep dive
How it works under the hood
- 01
Access control happens before retrieval, not after
Every request resolves the caller into a PermissionContext from database-backed user, team and department mappings. Each retriever only ever sees chunks that context allows: the BM25 corpus is built from authorized chunks, the pgvector query filters on ACL metadata, and graph traversal applies the same filter before returning anything. Because filtering happens first, an unauthorized passage can never reach the reranker or the LLM prompt, so it cannot leak through an answer or a citation.
- 02
Hybrid retrieval with Reciprocal Rank Fusion
BM25 catches exact terms and dense retrieval catches paraphrases, and each misses what the other finds. Hybrid mode runs both independently and merges the ranked lists with Reciprocal Rank Fusion: every chunk scores the sum of 1 / (60 + rank) across the lists it appears in. RRF needs no score normalisation between two very different scoring scales. A cross-encoder (ms-marco-MiniLM-L-6-v2), loaded lazily and reused, then rescores each query and passage pair to sharpen the final order, while the RRF score is kept alongside for comparison.
- 03
Idempotent, retryable ingestion
An upload stores the original file in SeaweedFS, then extracts text page by page, chunks by tokens, embeds with SentenceTransformers and writes chunks with a permission snapshot. Processing can be retried safely: existing documents, chunks, embeddings and ACL metadata are preserved and status is tracked per document. External datasets are imported by a source name and source document id, so re-running an import never duplicates records.
- 04
Graph retrieval and its limits
A rule-based extractor pulls technologies, algorithms, organisations and concepts out of chunks and stores entities, mentions and typed relationships in PostgreSQL. A graph query matches entities in the question, walks typed relationships and returns the chunks that mention them. It deliberately does not follow loose co-occurrence edges. It is fast for narrow entity questions, but because extraction is rule-based it can produce noisy matches, so hybrid plus reranking remains the default for accuracy.