How ajayjai30/rag_system_with_n8n_file-ingestion-with-rbac-control-for-kcs-application works
This repository is a secure, headless RAG API for internal assistants. A client submits a role-scoped chat request; the API creates or reuses a session, and the agent can answer from conversation context or invoke the RBAC-filtered hybrid search tool. Retrieved passages are reranked before the agent responds, then conversation memory is saved and periodically summarized. The README also documents retrieval, tool-calling, and KPI evaluation capabilities. The ingestion workflow files are present, but their runtime connections are not established by the sampled evidence, so they are not linked into the graph.
Main entry points: improved_and_optimized_RAG.py RBAC search tool · micro_rag_memory.py Memory engine · reindex_bm25.py Reindex trigger · 01_main_ingestion_flow.json Ingestion workflow
Components 18
API and agent
- Chat endpoint
improved_and_optimized_RAG.py - Query orchestration
improved_and_optimized_RAG.py - ReAct agent
improved_and_optimized_RAG.py
Secure retrieval
- RBAC search tool
improved_and_optimized_RAG.py - Qdrant collections
- Dense embeddings
- BM25 embeddings
- Cross-encoder reranker
Session memory
- Memory engine
micro_rag_memory.py - Short-term memory
chat_memory.sqlite - Long-term summaries
Index operations
- Reindex trigger
reindex_bm25.py - Ingestion workflow
n8n_workflows/01_main_ingestion_flow.json
Evaluation
- RAG evaluation
evaluate_rag.py - Tool-call evaluation
evaluate_tool_calling.py - KPI evaluation
final_kpi_evaluation.py
Other components
- Assistant client
- Chat model
Connections 19
- Assistant client → Chat endpoint: submits chat
README.md - Chat endpoint → Query orchestration: calls
improved_and_optimized_RAG.py - Query orchestration → ReAct agent: invokes
improved_and_optimized_RAG.py - ReAct agent → Chat model: reasons with
improved_and_optimized_RAG.py - ReAct agent → RBAC search tool: can invoke
improved_and_optimized_RAG.py - RBAC search tool → Dense embeddings: embeds query
improved_and_optimized_RAG.py - RBAC search tool → BM25 embeddings: creates sparse vector
improved_and_optimized_RAG.py - RBAC search tool → Qdrant collections: queries with RBAC
improved_and_optimized_RAG.py - RBAC search tool → Cross-encoder reranker: reranks passages
improved_and_optimized_RAG.py - Query orchestration → Memory engine: reads and writes
improved_and_optimized_RAG.py - Memory engine → Short-term memory: stores and recalls
micro_rag_memory.py - Memory engine → Long-term summaries: reads and writes
micro_rag_memory.py - Query orchestration → Memory engine: triggers summary rotation
improved_and_optimized_RAG.py - Memory engine → Chat model: summarizes with
micro_rag_memory.py - Reindex trigger → Qdrant collections: upserts BM25 vectors
reindex_bm25.py - RAG evaluation → Query orchestration: evaluates responses
evaluate_rag.py - Tool-call evaluation → Query orchestration: checks tool behavior
evaluate_tool_calling.py - KPI evaluation → RBAC search tool: measures retrieval
final_kpi_evaluation.py - Ingestion workflow → Qdrant collections: may populate