# udaykamalbotcha-ctrl/rbi-corpora-rag-eval architecture

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

- Interactive diagram: https://gitdiagram.com/udaykamalbotcha-ctrl/rbi-corpora-rag-eval
- Repository: https://github.com/udaykamalbotcha-ctrl/rbi-corpora-rag-eval

## Overview

This repository combines an RBI regulatory-document RAG service with an empirical evaluation benchmark. In the user workflow, a question enters through the web/API layer, the service retrieves regulatory chunks, applies answerability guardrails, and returns a cited response. Separately, ingestion parses and chunks source directives for indexing; benchmark runs compare retrieval and answer quality over the golden set. The sampled excerpts support the main parser, index, service, and evaluation links; documented but unsampled capabilities are included only where the README establishes them.

Main entry points: [`eval/eval_runner.py`](https://github.com/udaykamalbotcha-ctrl/rbi-corpora-rag-eval/blob/main/eval/eval_runner.py) (Evaluation Runner), [`src/vector_store.py`](https://github.com/udaykamalbotcha-ctrl/rbi-corpora-rag-eval/blob/main/src/vector_store.py) (Vector Index), [`src/ingest.py`](https://github.com/udaykamalbotcha-ctrl/rbi-corpora-rag-eval/blob/main/src/ingest.py) (Clause Parser), [`src/rag_service.py`](https://github.com/udaykamalbotcha-ctrl/rbi-corpora-rag-eval/blob/main/src/rag_service.py) (RAG Service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_corpus["Corpus Preparation"]
  node_documents["RBI Directives"]
  node_parser["Clause Parser<br/>[ingest.py]"]
  node_chunker["Chunk Strategies<br/>[chunker.py]"]
  node_vector_store[("Vector Index<br/>[vector_store.py]")]
end

subgraph group_rag["RAG Query Service"]
  node_service["RAG Service<br/>[rag_service.py]"]
end

subgraph group_evaluation["Benchmark Evaluation"]
  node_golden["Golden Questions<br/>[questions.jsonl]"]
  node_eval_runner["Evaluation Runner<br/>[eval_runner.py]"]
  node_experiments["Retrieval Experiments"]
  node_metrics["Retrieval Metrics<br/>[metrics.py]"]
  node_judge["LLM Judge<br/>[judge.py]"]
  node_reports["Evaluation Reports"]
  node_regression_gate["Quality Gate<br/>[ci_gate.py]"]
end

subgraph group_interface["User Interface"]
  node_web["Web Client<br/>[app.js]"]
  node_api["FastAPI Endpoints<br/>[api.py]"]
end

node_user(("Questioner"))
node_chroma[("ChromaDB")]
node_gemini{{"Gemini API"}}

node_user -.->|"asks"| node_web
node_web -.->|"queries"| node_api
node_api -->|"serves"| node_web
node_api -->|"delegates"| node_service
node_documents -->|"provides PDFs"| node_parser
node_parser -->|"chunks clauses"| node_chunker
node_parser -->|"indexes chunks"| node_vector_store
node_vector_store -->|"stores vectors"| node_chroma
node_service -->|"retrieves chunks"| node_vector_store
node_service -->|"generates judgments"| node_gemini
node_golden -->|"supplies questions"| node_eval_runner
node_eval_runner -->|"queries index"| node_vector_store
node_eval_runner -->|"calculates scores"| node_metrics
node_eval_runner -->|"grades answers"| node_judge
node_experiments -->|"runs configurations"| node_eval_runner
node_eval_runner -->|"writes results"| node_reports
node_regression_gate -.->|"checks quality"| node_reports

click node_documents "https://github.com/udaykamalbotcha-ctrl/rbi-corpora-rag-eval/tree/main/data"
click node_parser "https://github.com/udaykamalbotcha-ctrl/rbi-corpora-rag-eval/blob/main/src/ingest.py"
click node_chunker "https://github.com/udaykamalbotcha-ctrl/rbi-corpora-rag-eval/blob/main/src/chunker.py"
click node_vector_store "https://github.com/udaykamalbotcha-ctrl/rbi-corpora-rag-eval/blob/main/src/vector_store.py"
click node_web "https://github.com/udaykamalbotcha-ctrl/rbi-corpora-rag-eval/blob/main/web/app.js"
click node_api "https://github.com/udaykamalbotcha-ctrl/rbi-corpora-rag-eval/blob/main/src/api.py"
click node_service "https://github.com/udaykamalbotcha-ctrl/rbi-corpora-rag-eval/blob/main/src/rag_service.py"
click node_golden "https://github.com/udaykamalbotcha-ctrl/rbi-corpora-rag-eval/blob/main/golden_set/questions.jsonl"
click node_eval_runner "https://github.com/udaykamalbotcha-ctrl/rbi-corpora-rag-eval/blob/main/eval/eval_runner.py"
click node_experiments "https://github.com/udaykamalbotcha-ctrl/rbi-corpora-rag-eval/blob/main/eval/experiment_runner.py"
click node_metrics "https://github.com/udaykamalbotcha-ctrl/rbi-corpora-rag-eval/blob/main/eval/metrics.py"
click node_judge "https://github.com/udaykamalbotcha-ctrl/rbi-corpora-rag-eval/blob/main/eval/judge.py"
click node_reports "https://github.com/udaykamalbotcha-ctrl/rbi-corpora-rag-eval/tree/main/reports"
click node_regression_gate "https://github.com/udaykamalbotcha-ctrl/rbi-corpora-rag-eval/blob/main/eval/ci_gate.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_documents,node_parser,node_chunker,node_vector_store toneBlue
class node_service,node_chroma toneAmber
class node_golden,node_eval_runner,node_experiments,node_metrics,node_judge,node_reports,node_regression_gate,node_gemini toneMint
class node_web,node_api toneRose
class node_user toneIndigo
```

## Components

### Corpus Preparation

- [RBI Directives](https://github.com/udaykamalbotcha-ctrl/rbi-corpora-rag-eval/tree/main/data): `data`
- [Clause Parser](https://github.com/udaykamalbotcha-ctrl/rbi-corpora-rag-eval/blob/main/src/ingest.py): `src/ingest.py`
- [Chunk Strategies](https://github.com/udaykamalbotcha-ctrl/rbi-corpora-rag-eval/blob/main/src/chunker.py): `src/chunker.py`
- [Vector Index](https://github.com/udaykamalbotcha-ctrl/rbi-corpora-rag-eval/blob/main/src/vector_store.py): `src/vector_store.py`

### RAG Query Service

- [RAG Service](https://github.com/udaykamalbotcha-ctrl/rbi-corpora-rag-eval/blob/main/src/rag_service.py): `src/rag_service.py`

### Benchmark Evaluation

- [Golden Questions](https://github.com/udaykamalbotcha-ctrl/rbi-corpora-rag-eval/blob/main/golden_set/questions.jsonl): `golden_set/questions.jsonl`
- [Evaluation Runner](https://github.com/udaykamalbotcha-ctrl/rbi-corpora-rag-eval/blob/main/eval/eval_runner.py): `eval/eval_runner.py`
- [Retrieval Experiments](https://github.com/udaykamalbotcha-ctrl/rbi-corpora-rag-eval/blob/main/eval/experiment_runner.py): `eval/experiment_runner.py`
- [Retrieval Metrics](https://github.com/udaykamalbotcha-ctrl/rbi-corpora-rag-eval/blob/main/eval/metrics.py): `eval/metrics.py`
- [LLM Judge](https://github.com/udaykamalbotcha-ctrl/rbi-corpora-rag-eval/blob/main/eval/judge.py): `eval/judge.py`
- [Evaluation Reports](https://github.com/udaykamalbotcha-ctrl/rbi-corpora-rag-eval/tree/main/reports): `reports`
- [Quality Gate](https://github.com/udaykamalbotcha-ctrl/rbi-corpora-rag-eval/blob/main/eval/ci_gate.py): `eval/ci_gate.py`

### User Interface

- [Web Client](https://github.com/udaykamalbotcha-ctrl/rbi-corpora-rag-eval/blob/main/web/app.js): `web/app.js`
- [FastAPI Endpoints](https://github.com/udaykamalbotcha-ctrl/rbi-corpora-rag-eval/blob/main/src/api.py): `src/api.py`

### Other components

- **Questioner**
- **ChromaDB**
- **Gemini API**

## Connections

- Questioner → Web Client: asks
- Web Client → FastAPI Endpoints: queries
- FastAPI Endpoints → Web Client: serves (evidence: `src/api.py`)
- FastAPI Endpoints → RAG Service: delegates (evidence: `src/api.py`)
- RBI Directives → Clause Parser: provides PDFs (evidence: `README.md`)
- Clause Parser → Chunk Strategies: chunks clauses (evidence: `src/ingest.py`)
- Clause Parser → Vector Index: indexes chunks (evidence: `src/ingest.py`)
- Vector Index → ChromaDB: stores vectors (evidence: `README.md`)
- RAG Service → Vector Index: retrieves chunks (evidence: `src/rag_service.py`)
- RAG Service → Gemini API: generates judgments
- Golden Questions → Evaluation Runner: supplies questions (evidence: `README.md`)
- Evaluation Runner → Vector Index: queries index (evidence: `eval/eval_runner.py`)
- Evaluation Runner → Retrieval Metrics: calculates scores (evidence: `eval/eval_runner.py`)
- Evaluation Runner → LLM Judge: grades answers (evidence: `eval/eval_runner.py`)
- Retrieval Experiments → Evaluation Runner: runs configurations (evidence: `eval/experiment_runner.py`)
- Evaluation Runner → Evaluation Reports: writes results (evidence: `README.md`)
- Quality Gate → Evaluation Reports: checks quality (evidence: `README.md`)
