# digibhatia/rag-advance architecture

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

- Interactive diagram: https://gitdiagram.com/digibhatia/rag-advance
- Repository: https://github.com/digibhatia/rag-advance

## Overview

Disha is a document-grounded Q&A pipeline. Its main workflow loads varied source documents, redacts PII, chunks and embeds the text into a persistent vector store, then serves questions through retrieval, confidence checks, evidence packing, and cited LLM answers. The README also documents an HTTP question client and optional vector-store inspection. Edges reflect calls shown in excerpts or relationships stated in the README; the inspection tool’s internal connections are documented but not independently traced here.

Main entry points: [`app.py`](https://github.com/digibhatia/rag-advance/blob/main/app.py) (Q&A API), [`build_vectorstore.py`](https://github.com/digibhatia/rag-advance/blob/main/build_vectorstore.py) (Index Builder), [`retrieval.py`](https://github.com/digibhatia/rag-advance/blob/main/retrieval.py) (Retrieval Patterns), [`loaders.py`](https://github.com/digibhatia/rag-advance/blob/main/loaders.py) (Format Loaders)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingestion["Knowledge Ingestion"]
  node_source_docs["Source Documents"]
  node_builder["Index Builder"]
  node_loaders["Format Loaders<br/>[loaders.py]"]
  node_redaction["PII Redaction<br/>[pii.py]"]
  node_chunking["Chunk Strategies<br/>[chunking.py]"]
  node_store[("Chroma Vector Store")]
end

subgraph group_serving["Question Answering"]
  node_api["Q&amp;A API<br/>[app.py]"]
  node_retrieval["Retrieval Patterns<br/>[retrieval.py]"]
  node_context["Evidence Assembly<br/>[context.py]"]
  node_answer["Cited Answer<br/>[app.py]"]
end

subgraph group_integrations["External Services"]
  node_embedding["Embedding Model"]
  node_chat_model["Chat Model"]
end

subgraph group_clients["Clients and Inspection"]
  node_agent["HTTP Demo Client<br/>[agent.py]"]
  node_inspector["Store Inspector"]
end

node_questioner(("Questioner"))

node_builder -->|"loads units"| node_loaders
node_source_docs -->|"provides files"| node_loaders
node_builder -->|"redacts text"| node_redaction
node_builder -->|"chunks text"| node_chunking
node_builder -->|"embeds chunks"| node_embedding
node_builder -->|"writes vectors"| node_store
node_questioner -->|"asks question"| node_api
node_agent -->|"sends HTTP requests"| node_api
node_api -->|"requests matches"| node_retrieval
node_retrieval -->|"searches vectors"| node_store
node_api -->|"assembles evidence"| node_context
node_api -->|"requests answer"| node_chat_model
node_api -->|"returns citations"| node_answer
node_inspector -->|"inspects contents"| node_store

click node_source_docs "https://github.com/digibhatia/rag-advance/tree/main/documents"
click node_builder "https://github.com/digibhatia/rag-advance/blob/main/build_vectorstore.py"
click node_loaders "https://github.com/digibhatia/rag-advance/blob/main/loaders.py"
click node_redaction "https://github.com/digibhatia/rag-advance/blob/main/pii.py"
click node_chunking "https://github.com/digibhatia/rag-advance/blob/main/chunking.py"
click node_api "https://github.com/digibhatia/rag-advance/blob/main/app.py"
click node_retrieval "https://github.com/digibhatia/rag-advance/blob/main/retrieval.py"
click node_context "https://github.com/digibhatia/rag-advance/blob/main/context.py"
click node_answer "https://github.com/digibhatia/rag-advance/blob/main/app.py"
click node_agent "https://github.com/digibhatia/rag-advance/blob/main/agent.py"
click node_inspector "https://github.com/digibhatia/rag-advance/blob/main/inspect_vectorstore.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_source_docs,node_builder,node_loaders,node_redaction,node_chunking,node_store toneBlue
class node_api,node_retrieval,node_context,node_answer toneAmber
class node_embedding,node_chat_model toneMint
class node_agent,node_inspector toneRose
class node_questioner toneIndigo
```

## Components

### Knowledge Ingestion

- [Source Documents](https://github.com/digibhatia/rag-advance/tree/main/documents): `documents`
- [Index Builder](https://github.com/digibhatia/rag-advance/blob/main/build_vectorstore.py): `build_vectorstore.py`
- [Format Loaders](https://github.com/digibhatia/rag-advance/blob/main/loaders.py): `loaders.py`
- [PII Redaction](https://github.com/digibhatia/rag-advance/blob/main/pii.py): `pii.py`
- [Chunk Strategies](https://github.com/digibhatia/rag-advance/blob/main/chunking.py): `chunking.py`
- **Chroma Vector Store**

### Question Answering

- [Q&A API](https://github.com/digibhatia/rag-advance/blob/main/app.py): `app.py`
- [Retrieval Patterns](https://github.com/digibhatia/rag-advance/blob/main/retrieval.py): `retrieval.py`
- [Evidence Assembly](https://github.com/digibhatia/rag-advance/blob/main/context.py): `context.py`
- [Cited Answer](https://github.com/digibhatia/rag-advance/blob/main/app.py): `app.py`

### External Services

- **Embedding Model**
- **Chat Model**

### Clients and Inspection

- [HTTP Demo Client](https://github.com/digibhatia/rag-advance/blob/main/agent.py): `agent.py`
- [Store Inspector](https://github.com/digibhatia/rag-advance/blob/main/inspect_vectorstore.py): `inspect_vectorstore.py`

### Other components

- **Questioner**

## Connections

- Index Builder → Format Loaders: loads units (evidence: `build_vectorstore.py`)
- Source Documents → Format Loaders: provides files (evidence: `README.md`)
- Index Builder → PII Redaction: redacts text (evidence: `build_vectorstore.py`)
- Index Builder → Chunk Strategies: chunks text (evidence: `build_vectorstore.py`)
- Index Builder → Embedding Model: embeds chunks (evidence: `build_vectorstore.py`)
- Index Builder → Chroma Vector Store: writes vectors (evidence: `build_vectorstore.py`)
- Questioner → Q&A API: asks question (evidence: `README.md`)
- HTTP Demo Client → Q&A API: sends HTTP requests (evidence: `agent.py`)
- Q&A API → Retrieval Patterns: requests matches (evidence: `app.py`)
- Retrieval Patterns → Chroma Vector Store: searches vectors (evidence: `retrieval.py`)
- Q&A API → Evidence Assembly: assembles evidence (evidence: `app.py`)
- Q&A API → Chat Model: requests answer (evidence: `app.py`)
- Q&A API → Cited Answer: returns citations (evidence: `app.py`)
- Store Inspector → Chroma Vector Store: inspects contents (evidence: `inspect_vectorstore.py`)
