# darshankamate1254/securerag-enterprise-knowledge-assistant architecture

> Architecture diagram of the GitHub repository darshankamate1254/securerag-enterprise-knowledge-assistant, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/darshankamate1254/securerag-enterprise-knowledge-assistant
- Repository: https://github.com/darshankamate1254/securerag-enterprise-knowledge-assistant

## Overview

This is an enterprise RAG application: users sign in, submit a namespace-scoped question, and receive an answer with sources. Ingestion tags and chunks departmental documents; the query pipeline expands queries, retrieves and reranks context, synthesizes an answer, and redacts sensitive terms. The excerpts show the Flask-to-pipeline and retrieval internals. Caching, guardrails, streaming, and observability are documented capabilities, but their implementation paths are not established by the supplied tree and excerpts.

Main entry points: [`app/rag/pipeline.py`](https://github.com/darshankamate1254/securerag-enterprise-knowledge-assistant/blob/main/app/rag/pipeline.py) (Answer synthesis), [`app/main.py`](https://github.com/darshankamate1254/securerag-enterprise-knowledge-assistant/blob/main/app/main.py) (Flask routes), [`app/ingestion/loader.py`](https://github.com/darshankamate1254/securerag-enterprise-knowledge-assistant/blob/main/app/ingestion/loader.py) (Document loading), [`app/utils/config.py`](https://github.com/darshankamate1254/securerag-enterprise-knowledge-assistant/blob/main/app/utils/config.py) (Runtime settings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web and identity"]
  node_flask["Flask routes<br/>[main.py]"]
  node_accounts[("User accounts<br/>[users.py]")]
  node_access["Namespace access<br/>[rbac.py]"]
  node_chat_ui["Chat interface<br/>[chat.html]"]
end

subgraph group_ingestion["Document ingestion"]
  node_documents["Department documents"]
  node_loader["Document loading<br/>[loader.py]"]
  node_metadata["Namespace tagging<br/>[metadata.py]"]
  node_chunking["Hierarchical chunking<br/>[loader.py]"]
end

subgraph group_rag["RAG query pipeline"]
  node_vector_index[("Vector index")]
  node_hyde["HyDE and expansion<br/>[hyde.py]"]
  node_retrieval["Hybrid retrieval<br/>[retriever.py]"]
  node_reranker["Cross-encoder reranking<br/>[reranker.py]"]
  node_synthesis["Answer synthesis<br/>[pipeline.py]"]
end

subgraph group_platform["Platform capabilities"]
  node_settings["Runtime settings<br/>[config.py]"]
  node_guardrails["Query guardrails"]
  node_cache[("Semantic response cache")]
  node_streaming["SSE streaming<br/>[main.py]"]
  node_observability["Telemetry and logging"]
  node_evaluation["RAGAS evaluation<br/>[evaluate.py]"]
end

node_user(("User"))

node_user -->|"submits queries"| node_flask
node_flask -->|"authenticates"| node_accounts
node_flask -->|"checks permissions"| node_access
node_flask -->|"renders chat"| node_chat_ui
node_user -->|"uses"| node_chat_ui
node_documents -->|"loads documents"| node_loader
node_loader -->|"tags documents"| node_metadata
node_loader -->|"creates chunks"| node_chunking
node_chunking -.->|"indexes leaves"| node_vector_index
node_flask -->|"runs chat"| node_synthesis
node_synthesis -->|"redacts output"| node_access
node_synthesis -->|"expands query"| node_hyde
node_synthesis -->|"builds retriever"| node_retrieval
node_retrieval -.->|"retrieves context"| node_vector_index
node_synthesis -->|"reranks results"| node_reranker
node_synthesis -->|"reads settings"| node_settings
node_loader -->|"reads settings"| node_settings
node_flask -->|"loads settings"| node_settings
node_synthesis -.->|"applies safeguards"| node_guardrails
node_flask -.->|"uses response cache"| node_cache
node_flask -.->|"streams tokens"| node_streaming
node_synthesis -.->|"emits telemetry"| node_observability
node_evaluation -->|"evaluates answers"| node_synthesis

click node_flask "https://github.com/darshankamate1254/securerag-enterprise-knowledge-assistant/blob/main/app/main.py"
click node_accounts "https://github.com/darshankamate1254/securerag-enterprise-knowledge-assistant/blob/main/app/auth/users.py"
click node_access "https://github.com/darshankamate1254/securerag-enterprise-knowledge-assistant/blob/main/app/auth/rbac.py"
click node_chat_ui "https://github.com/darshankamate1254/securerag-enterprise-knowledge-assistant/blob/main/templates/chat.html"
click node_documents "https://github.com/darshankamate1254/securerag-enterprise-knowledge-assistant/tree/main/data"
click node_loader "https://github.com/darshankamate1254/securerag-enterprise-knowledge-assistant/blob/main/app/ingestion/loader.py"
click node_metadata "https://github.com/darshankamate1254/securerag-enterprise-knowledge-assistant/blob/main/app/ingestion/metadata.py"
click node_chunking "https://github.com/darshankamate1254/securerag-enterprise-knowledge-assistant/blob/main/app/ingestion/loader.py"
click node_hyde "https://github.com/darshankamate1254/securerag-enterprise-knowledge-assistant/blob/main/app/rag/hyde.py"
click node_retrieval "https://github.com/darshankamate1254/securerag-enterprise-knowledge-assistant/blob/main/app/rag/retriever.py"
click node_reranker "https://github.com/darshankamate1254/securerag-enterprise-knowledge-assistant/blob/main/app/rag/reranker.py"
click node_synthesis "https://github.com/darshankamate1254/securerag-enterprise-knowledge-assistant/blob/main/app/rag/pipeline.py"
click node_settings "https://github.com/darshankamate1254/securerag-enterprise-knowledge-assistant/blob/main/app/utils/config.py"
click node_guardrails "https://github.com/darshankamate1254/securerag-enterprise-knowledge-assistant/tree/main/app/rag"
click node_cache "https://github.com/darshankamate1254/securerag-enterprise-knowledge-assistant/tree/main/app/rag"
click node_streaming "https://github.com/darshankamate1254/securerag-enterprise-knowledge-assistant/blob/main/app/main.py"
click node_observability "https://github.com/darshankamate1254/securerag-enterprise-knowledge-assistant/tree/main/app"
click node_evaluation "https://github.com/darshankamate1254/securerag-enterprise-knowledge-assistant/blob/main/eval/evaluate.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_flask,node_accounts,node_access,node_chat_ui,node_user toneBlue
class node_documents,node_loader,node_metadata,node_chunking toneAmber
class node_vector_index,node_hyde,node_retrieval,node_reranker,node_synthesis toneMint
class node_settings,node_guardrails,node_cache,node_streaming,node_observability,node_evaluation toneRose
```

## Components

### Web and identity

- [Flask routes](https://github.com/darshankamate1254/securerag-enterprise-knowledge-assistant/blob/main/app/main.py): `app/main.py`
- [User accounts](https://github.com/darshankamate1254/securerag-enterprise-knowledge-assistant/blob/main/app/auth/users.py): `app/auth/users.py`
- [Namespace access](https://github.com/darshankamate1254/securerag-enterprise-knowledge-assistant/blob/main/app/auth/rbac.py): `app/auth/rbac.py`
- [Chat interface](https://github.com/darshankamate1254/securerag-enterprise-knowledge-assistant/blob/main/templates/chat.html): `templates/chat.html`

### Document ingestion

- [Department documents](https://github.com/darshankamate1254/securerag-enterprise-knowledge-assistant/tree/main/data): `data`
- [Document loading](https://github.com/darshankamate1254/securerag-enterprise-knowledge-assistant/blob/main/app/ingestion/loader.py): `app/ingestion/loader.py`
- [Namespace tagging](https://github.com/darshankamate1254/securerag-enterprise-knowledge-assistant/blob/main/app/ingestion/metadata.py): `app/ingestion/metadata.py`
- [Hierarchical chunking](https://github.com/darshankamate1254/securerag-enterprise-knowledge-assistant/blob/main/app/ingestion/loader.py): `app/ingestion/loader.py`

### RAG query pipeline

- **Vector index**
- [HyDE and expansion](https://github.com/darshankamate1254/securerag-enterprise-knowledge-assistant/blob/main/app/rag/hyde.py): `app/rag/hyde.py`
- [Hybrid retrieval](https://github.com/darshankamate1254/securerag-enterprise-knowledge-assistant/blob/main/app/rag/retriever.py): `app/rag/retriever.py`
- [Cross-encoder reranking](https://github.com/darshankamate1254/securerag-enterprise-knowledge-assistant/blob/main/app/rag/reranker.py): `app/rag/reranker.py`
- [Answer synthesis](https://github.com/darshankamate1254/securerag-enterprise-knowledge-assistant/blob/main/app/rag/pipeline.py): `app/rag/pipeline.py`

### Platform capabilities

- [Runtime settings](https://github.com/darshankamate1254/securerag-enterprise-knowledge-assistant/blob/main/app/utils/config.py): `app/utils/config.py`
- [Query guardrails](https://github.com/darshankamate1254/securerag-enterprise-knowledge-assistant/tree/main/app/rag): `app/rag`
- [Semantic response cache](https://github.com/darshankamate1254/securerag-enterprise-knowledge-assistant/tree/main/app/rag): `app/rag`
- [SSE streaming](https://github.com/darshankamate1254/securerag-enterprise-knowledge-assistant/blob/main/app/main.py): `app/main.py`
- [Telemetry and logging](https://github.com/darshankamate1254/securerag-enterprise-knowledge-assistant/tree/main/app): `app`
- [RAGAS evaluation](https://github.com/darshankamate1254/securerag-enterprise-knowledge-assistant/blob/main/eval/evaluate.py): `eval/evaluate.py`

### Other components

- **User**

## Connections

- User → Flask routes: submits queries (evidence: `app/main.py`)
- Flask routes → User accounts: authenticates (evidence: `app/main.py`)
- Flask routes → Namespace access: checks permissions (evidence: `app/main.py`)
- Flask routes → Chat interface: renders chat (evidence: `app/main.py`)
- User → Chat interface: uses (evidence: `README.md`)
- Department documents → Document loading: loads documents (evidence: `app/ingestion/loader.py`)
- Document loading → Namespace tagging: tags documents (evidence: `app/ingestion/loader.py`)
- Document loading → Hierarchical chunking: creates chunks (evidence: `app/ingestion/loader.py`)
- Hierarchical chunking → Vector index: indexes leaves (evidence: `README.md`)
- Flask routes → Answer synthesis: runs chat (evidence: `app/main.py`)
- Answer synthesis → Namespace access: redacts output (evidence: `app/rag/pipeline.py`)
- Answer synthesis → HyDE and expansion: expands query (evidence: `app/rag/pipeline.py`)
- Answer synthesis → Hybrid retrieval: builds retriever (evidence: `app/rag/pipeline.py`)
- Hybrid retrieval → Vector index: retrieves context
- Answer synthesis → Cross-encoder reranking: reranks results (evidence: `app/rag/pipeline.py`)
- Answer synthesis → Runtime settings: reads settings (evidence: `app/rag/pipeline.py`)
- Document loading → Runtime settings: reads settings (evidence: `app/ingestion/loader.py`)
- Flask routes → Runtime settings: loads settings (evidence: `app/main.py`)
- Answer synthesis → Query guardrails: applies safeguards (evidence: `README.md`)
- Flask routes → Semantic response cache: uses response cache (evidence: `README.md`)
- Flask routes → SSE streaming: streams tokens (evidence: `README.md`)
- Answer synthesis → Telemetry and logging: emits telemetry (evidence: `README.md`)
- RAGAS evaluation → Answer synthesis: evaluates answers (evidence: `eval/evaluate.py`)
