# krbuti/setu-compliance-rag architecture

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

- Interactive diagram: https://gitdiagram.com/krbuti/setu-compliance-rag
- Repository: https://github.com/krbuti/setu-compliance-rag

## Overview

SETU Compliance Policy RAG answers policy questions through a Gradio or CLI entry point, classifies each query, then retrieves grounded policy information, runs policy-navigation tools when needed, and combines available results into a cited response. A separate preparation path converts policy PDFs to JSON and indexes chunks in persistent ChromaDB. The README documents the major retrieval, chunking, reflection, and provider capabilities; sampled source confirms key orchestration and indexing calls. Some retrieval internals and PDF conversion details are documented but their implementations were not sampled.

Main entry points: [`main_agent.py`](https://github.com/krbuti/setu-compliance-rag/blob/dev/main_agent.py) (Query Orchestrator), [`config/llm_config.py`](https://github.com/krbuti/setu-compliance-rag/blob/dev/config/llm_config.py) (Model Factories), [`information_agent.py`](https://github.com/krbuti/setu-compliance-rag/blob/dev/information_agent.py) (Policy Retrieval), [`ingest.py`](https://github.com/krbuti/setu-compliance-rag/blob/dev/ingest.py) (Dataset Ingestion)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User Interface"]
  node_gradio["Gradio Chat<br/>[app_gradio.py]"]
end

subgraph group_answering["Query Answering"]
  node_orchestrator["Query Orchestrator<br/>[main_agent.py]"]
  node_triage["Query Triage<br/>[triage_agent.py]"]
  node_retrieval["Policy Retrieval"]
  node_hybrid["Hybrid Search"]
  node_rerank["Reranking"]
  node_answer["Answer and Reflection"]
  node_navigation["Policy Navigation Tools<br/>[action_agent.py]"]
  node_combine["Response Combiner<br/>[main_agent.py]"]
end

subgraph group_indexing["Policy Indexing"]
  node_pdfs["Policy PDFs"]
  node_conversion["PDF Conversion<br/>[build_dataset.py]"]
  node_policy_json["Policy JSON Dataset"]
  node_chunking["Table-aware Chunking"]
  node_ingestion["Dataset Ingestion<br/>[ingest.py]"]
end

subgraph group_services["Models and Storage"]
  node_config["Model Factories<br/>[llm_config.py]"]
  node_llm{{"LLM Providers"}}
  node_embeddings{{"Embedding Provider"}}
  node_chroma[("ChromaDB Index")]
end

node_user(("Policy User"))
node_response["Cited Response"]

node_user -->|"submits query"| node_gradio
node_gradio -->|"invokes"| node_orchestrator
node_user -->|"submits query"| node_orchestrator
node_orchestrator -->|"classifies via"| node_triage
node_orchestrator -->|"routes to"| node_retrieval
node_orchestrator -->|"routes to"| node_navigation
node_triage -->|"returns routing"| node_orchestrator
node_retrieval -->|"retrieves with"| node_hybrid
node_hybrid -->|"searches"| node_chroma
node_hybrid -->|"ranks results"| node_rerank
node_retrieval -->|"generates and verifies"| node_answer
node_retrieval -->|"gets model"| node_config
node_navigation -->|"gets model"| node_config
node_orchestrator -->|"combines results"| node_combine
node_combine -->|"gets model"| node_config
node_combine -->|"returns response"| node_response
node_pdfs -->|"parsed into"| node_conversion
node_conversion -->|"writes dataset"| node_policy_json
node_policy_json -->|"loads documents"| node_ingestion
node_ingestion -->|"creates chunks"| node_chunking
node_ingestion -->|"gets embeddings"| node_config
node_config -->|"creates client"| node_llm
node_config -->|"creates client"| node_embeddings
node_ingestion -->|"writes chunks"| node_chroma

click node_gradio "https://github.com/krbuti/setu-compliance-rag/blob/dev/app_gradio.py"
click node_orchestrator "https://github.com/krbuti/setu-compliance-rag/blob/dev/main_agent.py"
click node_triage "https://github.com/krbuti/setu-compliance-rag/blob/dev/triage_agent.py"
click node_retrieval "https://github.com/krbuti/setu-compliance-rag/blob/dev/information_agent.py"
click node_hybrid "https://github.com/krbuti/setu-compliance-rag/blob/dev/information_agent.py"
click node_rerank "https://github.com/krbuti/setu-compliance-rag/blob/dev/information_agent.py"
click node_answer "https://github.com/krbuti/setu-compliance-rag/blob/dev/information_agent.py"
click node_navigation "https://github.com/krbuti/setu-compliance-rag/blob/dev/action_agent.py"
click node_combine "https://github.com/krbuti/setu-compliance-rag/blob/dev/main_agent.py"
click node_conversion "https://github.com/krbuti/setu-compliance-rag/blob/dev/build_dataset.py"
click node_policy_json "https://github.com/krbuti/setu-compliance-rag/tree/dev/dataset"
click node_chunking "https://github.com/krbuti/setu-compliance-rag/blob/dev/data_preprocessing.py"
click node_ingestion "https://github.com/krbuti/setu-compliance-rag/blob/dev/ingest.py"
click node_config "https://github.com/krbuti/setu-compliance-rag/blob/dev/config/llm_config.py"
click node_chroma "https://github.com/krbuti/setu-compliance-rag/tree/dev/chroma_db"

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_gradio,node_user toneBlue
class node_orchestrator,node_triage,node_retrieval,node_hybrid,node_rerank,node_answer,node_navigation,node_combine toneAmber
class node_pdfs,node_conversion,node_policy_json,node_chunking,node_ingestion toneMint
class node_config,node_llm,node_embeddings,node_chroma toneRose
class node_response toneIndigo
```

## Components

### User Interface

- [Gradio Chat](https://github.com/krbuti/setu-compliance-rag/blob/dev/app_gradio.py): `app_gradio.py`

### Query Answering

- [Query Orchestrator](https://github.com/krbuti/setu-compliance-rag/blob/dev/main_agent.py): `main_agent.py`
- [Query Triage](https://github.com/krbuti/setu-compliance-rag/blob/dev/triage_agent.py): `triage_agent.py`
- [Policy Retrieval](https://github.com/krbuti/setu-compliance-rag/blob/dev/information_agent.py): `information_agent.py`
- [Hybrid Search](https://github.com/krbuti/setu-compliance-rag/blob/dev/information_agent.py): `information_agent.py`
- [Reranking](https://github.com/krbuti/setu-compliance-rag/blob/dev/information_agent.py): `information_agent.py`
- [Answer and Reflection](https://github.com/krbuti/setu-compliance-rag/blob/dev/information_agent.py): `information_agent.py`
- [Policy Navigation Tools](https://github.com/krbuti/setu-compliance-rag/blob/dev/action_agent.py): `action_agent.py`
- [Response Combiner](https://github.com/krbuti/setu-compliance-rag/blob/dev/main_agent.py): `main_agent.py`

### Policy Indexing

- **Policy PDFs**
- [PDF Conversion](https://github.com/krbuti/setu-compliance-rag/blob/dev/build_dataset.py): `build_dataset.py`
- [Policy JSON Dataset](https://github.com/krbuti/setu-compliance-rag/tree/dev/dataset): `dataset`
- [Table-aware Chunking](https://github.com/krbuti/setu-compliance-rag/blob/dev/data_preprocessing.py): `data_preprocessing.py`
- [Dataset Ingestion](https://github.com/krbuti/setu-compliance-rag/blob/dev/ingest.py): `ingest.py`

### Models and Storage

- [Model Factories](https://github.com/krbuti/setu-compliance-rag/blob/dev/config/llm_config.py): `config/llm_config.py`
- **LLM Providers**
- **Embedding Provider**
- [ChromaDB Index](https://github.com/krbuti/setu-compliance-rag/tree/dev/chroma_db): `chroma_db`

### Other components

- **Policy User**
- **Cited Response**

## Connections

- Policy User → Gradio Chat: submits query (evidence: `README.md`)
- Gradio Chat → Query Orchestrator: invokes (evidence: `app_gradio.py`)
- Policy User → Query Orchestrator: submits query (evidence: `README.md`)
- Query Orchestrator → Query Triage: classifies via (evidence: `main_agent.py`)
- Query Orchestrator → Policy Retrieval: routes to (evidence: `main_agent.py`)
- Query Orchestrator → Policy Navigation Tools: routes to (evidence: `main_agent.py`)
- Query Triage → Query Orchestrator: returns routing (evidence: `main_agent.py`)
- Policy Retrieval → Hybrid Search: retrieves with (evidence: `README.md`)
- Hybrid Search → ChromaDB Index: searches (evidence: `README.md`)
- Hybrid Search → Reranking: ranks results (evidence: `README.md`)
- Policy Retrieval → Answer and Reflection: generates and verifies (evidence: `README.md`)
- Policy Retrieval → Model Factories: gets model (evidence: `information_agent.py`)
- Policy Navigation Tools → Model Factories: gets model (evidence: `action_agent.py`)
- Query Orchestrator → Response Combiner: combines results (evidence: `main_agent.py`)
- Response Combiner → Model Factories: gets model (evidence: `main_agent.py`)
- Response Combiner → Cited Response: returns response (evidence: `README.md`)
- Policy PDFs → PDF Conversion: parsed into (evidence: `README.md`)
- PDF Conversion → Policy JSON Dataset: writes dataset (evidence: `README.md`)
- Policy JSON Dataset → Dataset Ingestion: loads documents (evidence: `ingest.py`)
- Dataset Ingestion → Table-aware Chunking: creates chunks (evidence: `ingest.py`)
- Dataset Ingestion → Model Factories: gets embeddings (evidence: `ingest.py`)
- Model Factories → LLM Providers: creates client (evidence: `README.md`)
- Model Factories → Embedding Provider: creates client (evidence: `README.md`)
- Dataset Ingestion → ChromaDB Index: writes chunks (evidence: `ingest.py`)
