# battulayaswanth/rag architecture

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

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

## Overview

Advanced RAG ingests PDF/DOCX documents, cleans and deduplicates their text, chunks it, embeds it, and indexes it in Chroma. For a question, the serving API delegates to the RAG application, which retrieves and reranks candidate chunks, prepares grounded context, generates an answer, and optionally evaluates it; the React chat UI presents answers and sources. The README documents batch evaluation and local/cloud and model-provider options. Edges reflect shown calls or documented relationships; some integrations are documented but their full implementation was not sampled.

Main entry points: [`src/advanced_rag/main.py`](https://github.com/battulayaswanth/rag/blob/main/src/advanced_rag/main.py) (Ingestion pipeline), [`src/advanced_rag/app.py`](https://github.com/battulayaswanth/rag/blob/main/src/advanced_rag/app.py) (RAG application), [`src/advanced_rag/Retrieval/retriever.py`](https://github.com/battulayaswanth/rag/blob/main/src/advanced_rag/Retrieval/retriever.py) (Hybrid retrieval and rerank), [`src/advanced_rag/api.py`](https://github.com/battulayaswanth/rag/blob/main/src/advanced_rag/api.py) (FastAPI service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Document ingestion"]
  node_ingest_entry["Ingestion pipeline<br/>[main.py]"]
  node_loader["Document loading<br/>[data_loader.py]"]
  node_cleaner["Cleaning and dedup<br/>[data_cleaner.py]"]
  node_chunker["Text chunking<br/>[text_chunker.py]"]
  node_vector_store["Vector indexing<br/>[vector_store.py]"]
  node_chroma_client["Chroma client<br/>[chroma_client.py]"]
end

subgraph group_retrieve["Retrieval and grounding"]
  node_retriever["Hybrid retrieval and rerank<br/>[retriever.py]"]
  node_augmentor["Context and citations<br/>[augmentor.py]"]
  node_generator["Grounded generation<br/>[generator.py]"]
end

subgraph group_serve["Serving and chat"]
  node_api["FastAPI service<br/>[api.py]"]
  node_app["RAG application<br/>[app.py]"]
  node_frontend["React chat UI<br/>[App.jsx]"]
  node_frontend_api["Frontend API client<br/>[api.js]"]
end

subgraph group_eval["Evaluation"]
  node_evaluation["Claim-level evaluation<br/>[evaluator.py]"]
  node_batch_eval["Batch evaluation<br/>[run_batch.py]"]
end

node_user(("User"))
node_docs["PDF/DOCX documents"]
node_chroma[("Chroma store")]
node_question(("Question"))
node_embed_service{{"Voyage embeddings"}}
node_rerank_service{{"Cohere reranker"}}
node_llm{{"Ollama or Groq"}}
node_judge_llm{{"Evaluation LLM"}}

node_docs -->|"ingests"| node_ingest_entry
node_ingest_entry -->|"loads"| node_loader
node_ingest_entry -->|"cleans and deduplicates"| node_cleaner
node_ingest_entry -->|"chunks"| node_chunker
node_ingest_entry -->|"indexes chunks"| node_vector_store
node_vector_store -->|"gets client"| node_chroma_client
node_chroma_client -->|"connects"| node_chroma
node_user -->|"asks"| node_frontend
node_frontend -->|"calls"| node_frontend_api
node_frontend_api -->|"HTTP query"| node_api
node_question -->|"submits"| node_api
node_api -->|"delegates"| node_app
node_app -->|"retrieves"| node_retriever
node_retriever -->|"searches"| node_chroma
node_retriever -.->|"embeds query"| node_embed_service
node_retriever -.->|"reranks"| node_rerank_service
node_app -->|"prepares context"| node_augmentor
node_app -->|"generates answer"| node_generator
node_generator -.->|"invokes"| node_llm
node_app -->|"optionally evaluates"| node_evaluation
node_evaluation -.->|"judges claims"| node_judge_llm
node_batch_eval -->|"runs queries"| node_retriever
node_batch_eval -->|"evaluates results"| node_evaluation
node_api -.->|"returns answer and sources"| node_frontend

click node_ingest_entry "https://github.com/battulayaswanth/rag/blob/main/src/advanced_rag/main.py"
click node_loader "https://github.com/battulayaswanth/rag/blob/main/src/advanced_rag/Loaders/data_loader.py"
click node_cleaner "https://github.com/battulayaswanth/rag/blob/main/src/advanced_rag/Loaders/data_cleaner.py"
click node_chunker "https://github.com/battulayaswanth/rag/blob/main/src/advanced_rag/Chunker/text_chunker.py"
click node_vector_store "https://github.com/battulayaswanth/rag/blob/main/src/advanced_rag/Vector/vector_store.py"
click node_chroma_client "https://github.com/battulayaswanth/rag/blob/main/src/advanced_rag/Vector/chroma_client.py"
click node_api "https://github.com/battulayaswanth/rag/blob/main/src/advanced_rag/api.py"
click node_app "https://github.com/battulayaswanth/rag/blob/main/src/advanced_rag/app.py"
click node_retriever "https://github.com/battulayaswanth/rag/blob/main/src/advanced_rag/Retrieval/retriever.py"
click node_augmentor "https://github.com/battulayaswanth/rag/blob/main/src/advanced_rag/Augmentor/augmentor.py"
click node_generator "https://github.com/battulayaswanth/rag/blob/main/src/advanced_rag/Generator/generator.py"
click node_evaluation "https://github.com/battulayaswanth/rag/blob/main/src/advanced_rag/Evaluation/evaluator.py"
click node_batch_eval "https://github.com/battulayaswanth/rag/blob/main/src/advanced_rag/Evaluation/run_batch.py"
click node_frontend "https://github.com/battulayaswanth/rag/blob/main/frontend/src/App.jsx"
click node_frontend_api "https://github.com/battulayaswanth/rag/blob/main/frontend/src/api.js"

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_ingest_entry,node_loader,node_cleaner,node_chunker,node_vector_store,node_chroma_client,node_user toneBlue
class node_retriever,node_augmentor,node_generator,node_chroma toneAmber
class node_api,node_app,node_frontend,node_frontend_api toneMint
class node_evaluation,node_batch_eval toneRose
class node_docs,node_question,node_embed_service,node_rerank_service,node_llm,node_judge_llm toneIndigo
```

## Components

### Document ingestion

- [Ingestion pipeline](https://github.com/battulayaswanth/rag/blob/main/src/advanced_rag/main.py): `src/advanced_rag/main.py`
- [Document loading](https://github.com/battulayaswanth/rag/blob/main/src/advanced_rag/Loaders/data_loader.py): `src/advanced_rag/Loaders/data_loader.py`
- [Cleaning and dedup](https://github.com/battulayaswanth/rag/blob/main/src/advanced_rag/Loaders/data_cleaner.py): `src/advanced_rag/Loaders/data_cleaner.py`
- [Text chunking](https://github.com/battulayaswanth/rag/blob/main/src/advanced_rag/Chunker/text_chunker.py): `src/advanced_rag/Chunker/text_chunker.py`
- [Vector indexing](https://github.com/battulayaswanth/rag/blob/main/src/advanced_rag/Vector/vector_store.py): `src/advanced_rag/Vector/vector_store.py`
- [Chroma client](https://github.com/battulayaswanth/rag/blob/main/src/advanced_rag/Vector/chroma_client.py): `src/advanced_rag/Vector/chroma_client.py`

### Retrieval and grounding

- [Hybrid retrieval and rerank](https://github.com/battulayaswanth/rag/blob/main/src/advanced_rag/Retrieval/retriever.py): `src/advanced_rag/Retrieval/retriever.py`
- [Context and citations](https://github.com/battulayaswanth/rag/blob/main/src/advanced_rag/Augmentor/augmentor.py): `src/advanced_rag/Augmentor/augmentor.py`
- [Grounded generation](https://github.com/battulayaswanth/rag/blob/main/src/advanced_rag/Generator/generator.py): `src/advanced_rag/Generator/generator.py`

### Serving and chat

- [FastAPI service](https://github.com/battulayaswanth/rag/blob/main/src/advanced_rag/api.py): `src/advanced_rag/api.py`
- [RAG application](https://github.com/battulayaswanth/rag/blob/main/src/advanced_rag/app.py): `src/advanced_rag/app.py`
- [React chat UI](https://github.com/battulayaswanth/rag/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Frontend API client](https://github.com/battulayaswanth/rag/blob/main/frontend/src/api.js): `frontend/src/api.js`

### Evaluation

- [Claim-level evaluation](https://github.com/battulayaswanth/rag/blob/main/src/advanced_rag/Evaluation/evaluator.py): `src/advanced_rag/Evaluation/evaluator.py`
- [Batch evaluation](https://github.com/battulayaswanth/rag/blob/main/src/advanced_rag/Evaluation/run_batch.py): `src/advanced_rag/Evaluation/run_batch.py`

### Other components

- **User**
- **PDF/DOCX documents**
- **Chroma store**
- **Question**
- **Voyage embeddings**
- **Cohere reranker**
- **Ollama or Groq**
- **Evaluation LLM**

## Connections

- PDF/DOCX documents → Ingestion pipeline: ingests (evidence: `README.md`)
- Ingestion pipeline → Document loading: loads (evidence: `src/advanced_rag/main.py`)
- Ingestion pipeline → Cleaning and dedup: cleans and deduplicates (evidence: `src/advanced_rag/main.py`)
- Ingestion pipeline → Text chunking: chunks (evidence: `src/advanced_rag/main.py`)
- Ingestion pipeline → Vector indexing: indexes chunks (evidence: `src/advanced_rag/main.py`)
- Vector indexing → Chroma client: gets client (evidence: `src/advanced_rag/Vector/vector_store.py`)
- Chroma client → Chroma store: connects (evidence: `src/advanced_rag/Vector/chroma_client.py`)
- User → React chat UI: asks (evidence: `README.md`)
- React chat UI → Frontend API client: calls (evidence: `frontend/src/App.jsx`)
- Frontend API client → FastAPI service: HTTP query (evidence: `README.md`)
- Question → FastAPI service: submits (evidence: `README.md`)
- FastAPI service → RAG application: delegates (evidence: `src/advanced_rag/api.py`)
- RAG application → Hybrid retrieval and rerank: retrieves (evidence: `src/advanced_rag/app.py`)
- Hybrid retrieval and rerank → Chroma store: searches (evidence: `src/advanced_rag/Retrieval/retriever.py`)
- Hybrid retrieval and rerank → Voyage embeddings: embeds query (evidence: `README.md`)
- Hybrid retrieval and rerank → Cohere reranker: reranks (evidence: `README.md`)
- RAG application → Context and citations: prepares context (evidence: `src/advanced_rag/app.py`)
- RAG application → Grounded generation: generates answer (evidence: `src/advanced_rag/app.py`)
- Grounded generation → Ollama or Groq: invokes (evidence: `README.md`)
- RAG application → Claim-level evaluation: optionally evaluates (evidence: `src/advanced_rag/app.py`)
- Claim-level evaluation → Evaluation LLM: judges claims (evidence: `README.md`)
- Batch evaluation → Hybrid retrieval and rerank: runs queries (evidence: `src/advanced_rag/Evaluation/run_batch.py`)
- Batch evaluation → Claim-level evaluation: evaluates results (evidence: `src/advanced_rag/Evaluation/run_batch.py`)
- FastAPI service → React chat UI: returns answer and sources (evidence: `README.md`)
