How itachi5747/multi-tenant-enterprise-knowledge-base-rag-platform works
Enterprise Knowledge Base is a multi-tenant document ingestion and grounded question-answering service. Companies establish tenant accounts; employees authenticate, upload internal documents, and query their tenant’s corpus for answers with source attribution. The documented ingestion stages extract, chunk, contextualize, embed and index content, with optional entity-graph storage. Query-time retrieval combines reformulated queries, hybrid vector/lexical search and optional GraphRAG before reranking, relevance filtering and generation. The README also describes RAGAS evaluation. Sampled excerpts confirm core retrieval and storage behavior; some API-to-service wiring and evaluation details are unsampled.
Main entry points: ingestion.py Ingestion pipeline · multi_query.py Query expansion and fusion · auth.py Authentication · main.py FastAPI app
Components 29
Tenant access
- FastAPI app
backend/app/main.py - Authentication
backend/app/api/auth.py - Tenant and user records
backend/app/models
Document ingestion
- Document API
backend/app/api/documents.py - File storage
backend/app/services/storage.py - Ingestion pipeline
backend/app/services/ingestion.py - Text chunking
backend/app/rag/chunker.py - Chunk contextualization
backend/app/rag/contextualizer.py - Dense embeddings
backend/app/rag/embedder.py - Sparse encoding
backend/app/rag/sparse.py - Graph extraction
backend/app/rag/graph_extractor.py
Answer retrieval
- Chat API
backend/app/api/chats.py - Answer generation
backend/app/services/generation.py - Retrieval orchestration
backend/app/services/retrieval.py - Query expansion and fusion
backend/app/rag/multi_query.py - Hybrid retrieval
backend/app/rag/retriever.py - Result reranking
backend/app/rag/reranker.py - Grounded response
backend/app/rag/generator.py
Platform state
- PostgreSQL
- Qdrant index
- Neo4j graph
- Tenant document files
Quality evaluation
- Evaluation API
backend/app/api/eval.py - RAGAS evaluation runner
eval/run_eval.py - Golden dataset
eval/golden_dataset.json - Evaluation run records
backend/app/models/eval_run.py
Other components
- Company admin
- Employee
- NVIDIA NIM
Connections 44
- Company admin → Authentication: signs up
- Employee → Authentication: authenticates
- FastAPI app → Authentication: registers routes
- FastAPI app → Document API: registers routes
- FastAPI app → Chat API: registers routes
- FastAPI app → Evaluation API: registers routes
- Authentication → Tenant and user records: creates and reads
- Authentication → PostgreSQL: persists accounts
- Employee → Document API: uploads documents
- Document API → File storage: stores files
- File storage → Tenant document files: writes files
- Document API → Ingestion pipeline: schedules ingestion
- Ingestion pipeline → File storage: reads files
- Ingestion pipeline → Text chunking: chunks text
- Ingestion pipeline → Chunk contextualization: adds context
- Ingestion pipeline → Dense embeddings: embeds chunks
- Ingestion pipeline → Sparse encoding: encodes chunks
- Ingestion pipeline → Qdrant index: upserts vectors
- Ingestion pipeline → Graph extraction: extracts entities
- Graph extraction → NVIDIA NIM: requests extraction
- Ingestion pipeline → Neo4j graph: stores graph
- Ingestion pipeline → PostgreSQL: updates status
- Employee → Chat API: asks questions
- Chat API → Answer generation: requests answer
- Answer generation → Retrieval orchestration: requests context
- Retrieval orchestration → Query expansion and fusion: retrieves candidates
- Query expansion and fusion → NVIDIA NIM: generates variants
- Query expansion and fusion → Hybrid retrieval: searches variants
- Hybrid retrieval → Dense embeddings: embeds query
- Hybrid retrieval → Sparse encoding: encodes query
- Hybrid retrieval → Qdrant index: searches tenant index
- Query expansion and fusion → Neo4j graph: traverses entities
- Query expansion and fusion → Qdrant index: fetches graph chunks
- Retrieval orchestration → Result reranking: reranks candidates
- Answer generation → Grounded response: generates response
- Grounded response → NVIDIA NIM: requests completion
- Chat API → PostgreSQL: stores chat records
- Employee → Evaluation API: requests evaluation
- RAGAS evaluation runner → Golden dataset: loads questions
- RAGAS evaluation runner → Query expansion and fusion: runs retrieval
- RAGAS evaluation runner → Result reranking: reranks results
- RAGAS evaluation runner → PostgreSQL: stores metrics
- Evaluation API → Evaluation run records: manages runs
- Evaluation run records → PostgreSQL: persists results