# aditya9122002/yojanagpt architecture

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

- Interactive diagram: https://gitdiagram.com/aditya9122002/yojanagpt
- Repository: https://github.com/aditya9122002/yojanagpt

## Overview

YojanaGPT is a multilingual assistant for discovering and understanding Indian government schemes. Citizens use its web interface and API to ask general questions or request eligibility checks, document lists, application guidance, comparisons, and contact details; the RAG pipeline retrieves scheme context, builds a task-specific prompt, and returns a grounded answer. A separate data workflow fetches scheme information and ingests it into ChromaDB. The API and RAG calls are visible in excerpts; scraper wiring and several subsystem details are documented but unsampled.

Main entry points: [`src/api/main.py`](https://github.com/aditya9122002/yojanagpt/blob/main/src/api/main.py) (FastAPI routes), [`src/retrieval/pipeline.py`](https://github.com/aditya9122002/yojanagpt/blob/main/src/retrieval/pipeline.py) (RAG orchestration), [`src/ingestion/pipeline.py`](https://github.com/aditya9122002/yojanagpt/blob/main/src/ingestion/pipeline.py) (Ingestion workflow), [`src/scraper/scraper.py`](https://github.com/aditya9122002/yojanagpt/blob/main/src/scraper/scraper.py) (Scrape orchestration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Citizen interface"]
  node_webui["Web interface<br/>[index.html]"]
  node_api["FastAPI routes<br/>[main.py]"]
  node_api_models["API schemas<br/>[models.py]"]
  node_dependencies["Pipeline dependency<br/>[deps.py]"]
  node_tts["Speech synthesis<br/>[tts.py]"]
end

subgraph group_answering["Answer generation"]
  node_rag["RAG orchestration<br/>[pipeline.py]"]
  node_language["Language detection<br/>[detector.py]"]
  node_translation["Query translation<br/>[translator.py]"]
  node_retriever["Hybrid retrieval<br/>[retriever.py]"]
  node_prompt["Task prompts<br/>[prompt.py]"]
  node_llm["Groq LLM client<br/>[llm.py]"]
end

subgraph group_knowledge["Scheme knowledge"]
  node_vectorstore[("ChromaDB store<br/>[vectorstore.py]")]
  node_chunker["Scheme chunking<br/>[chunker.py]"]
  node_embedder["Embedding generation<br/>[embedder.py]"]
  node_ingestion["Ingestion workflow<br/>[pipeline.py]"]
end

subgraph group_collection["Data collection"]
  node_scraper["Scrape orchestration<br/>[scraper.py]"]
  node_scraper_client["MyScheme client<br/>[client.py]"]
  node_parser["Scheme parser<br/>[parser.py]"]
  node_scheme_models["Scheme models<br/>[models.py]"]
end

node_citizen(("Citizen"))
node_groq{{"Groq API"}}
node_myscheme{{"MyScheme API"}}

node_citizen -.->|"asks through"| node_webui
node_webui -.->|"sends requests"| node_api
node_api -->|"validates with"| node_api_models
node_api -->|"gets pipeline"| node_dependencies
node_api -->|"routes questions"| node_rag
node_api -->|"detects language"| node_language
node_api -->|"synthesizes speech"| node_tts
node_rag -->|"translates text"| node_translation
node_rag -->|"retrieves chunks"| node_retriever
node_rag -->|"builds prompts"| node_prompt
node_rag -->|"generates answer"| node_llm
node_llm -->|"posts prompt"| node_groq
node_retriever -.->|"searches chunks"| node_vectorstore
node_ingestion -->|"chunks schemes"| node_chunker
node_ingestion -->|"embeds chunks"| node_embedder
node_ingestion -->|"stores embeddings"| node_vectorstore
node_scraper -.->|"fetches data"| node_scraper_client
node_scraper -.->|"parses responses"| node_parser
node_parser -.->|"creates models"| node_scheme_models
node_scraper_client -->|"requests scheme data"| node_myscheme
node_scraper -.->|"provides scraped data"| node_ingestion

click node_webui "https://github.com/aditya9122002/yojanagpt/blob/main/frontend/index.html"
click node_api "https://github.com/aditya9122002/yojanagpt/blob/main/src/api/main.py"
click node_api_models "https://github.com/aditya9122002/yojanagpt/blob/main/src/api/models.py"
click node_dependencies "https://github.com/aditya9122002/yojanagpt/blob/main/src/api/deps.py"
click node_tts "https://github.com/aditya9122002/yojanagpt/blob/main/src/api/tts.py"
click node_rag "https://github.com/aditya9122002/yojanagpt/blob/main/src/retrieval/pipeline.py"
click node_language "https://github.com/aditya9122002/yojanagpt/blob/main/src/translation/detector.py"
click node_translation "https://github.com/aditya9122002/yojanagpt/blob/main/src/translation/translator.py"
click node_retriever "https://github.com/aditya9122002/yojanagpt/blob/main/src/retrieval/retriever.py"
click node_prompt "https://github.com/aditya9122002/yojanagpt/blob/main/src/retrieval/prompt.py"
click node_llm "https://github.com/aditya9122002/yojanagpt/blob/main/src/retrieval/llm.py"
click node_vectorstore "https://github.com/aditya9122002/yojanagpt/blob/main/src/ingestion/vectorstore.py"
click node_chunker "https://github.com/aditya9122002/yojanagpt/blob/main/src/ingestion/chunker.py"
click node_embedder "https://github.com/aditya9122002/yojanagpt/blob/main/src/ingestion/embedder.py"
click node_ingestion "https://github.com/aditya9122002/yojanagpt/blob/main/src/ingestion/pipeline.py"
click node_scraper "https://github.com/aditya9122002/yojanagpt/blob/main/src/scraper/scraper.py"
click node_scraper_client "https://github.com/aditya9122002/yojanagpt/blob/main/src/scraper/client.py"
click node_parser "https://github.com/aditya9122002/yojanagpt/blob/main/src/scraper/parser.py"
click node_scheme_models "https://github.com/aditya9122002/yojanagpt/blob/main/src/scraper/models.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_webui,node_api,node_api_models,node_dependencies,node_tts toneBlue
class node_rag,node_language,node_translation,node_retriever,node_prompt,node_llm toneAmber
class node_vectorstore,node_chunker,node_embedder,node_ingestion,node_groq,node_myscheme toneMint
class node_scraper,node_scraper_client,node_parser,node_scheme_models toneRose
class node_citizen toneIndigo
```

## Components

### Citizen interface

- [Web interface](https://github.com/aditya9122002/yojanagpt/blob/main/frontend/index.html): `frontend/index.html`
- [FastAPI routes](https://github.com/aditya9122002/yojanagpt/blob/main/src/api/main.py): `src/api/main.py`
- [API schemas](https://github.com/aditya9122002/yojanagpt/blob/main/src/api/models.py): `src/api/models.py`
- [Pipeline dependency](https://github.com/aditya9122002/yojanagpt/blob/main/src/api/deps.py): `src/api/deps.py`
- [Speech synthesis](https://github.com/aditya9122002/yojanagpt/blob/main/src/api/tts.py): `src/api/tts.py`

### Answer generation

- [RAG orchestration](https://github.com/aditya9122002/yojanagpt/blob/main/src/retrieval/pipeline.py): `src/retrieval/pipeline.py`
- [Language detection](https://github.com/aditya9122002/yojanagpt/blob/main/src/translation/detector.py): `src/translation/detector.py`
- [Query translation](https://github.com/aditya9122002/yojanagpt/blob/main/src/translation/translator.py): `src/translation/translator.py`
- [Hybrid retrieval](https://github.com/aditya9122002/yojanagpt/blob/main/src/retrieval/retriever.py): `src/retrieval/retriever.py`
- [Task prompts](https://github.com/aditya9122002/yojanagpt/blob/main/src/retrieval/prompt.py): `src/retrieval/prompt.py`
- [Groq LLM client](https://github.com/aditya9122002/yojanagpt/blob/main/src/retrieval/llm.py): `src/retrieval/llm.py`

### Scheme knowledge

- [ChromaDB store](https://github.com/aditya9122002/yojanagpt/blob/main/src/ingestion/vectorstore.py): `src/ingestion/vectorstore.py`
- [Scheme chunking](https://github.com/aditya9122002/yojanagpt/blob/main/src/ingestion/chunker.py): `src/ingestion/chunker.py`
- [Embedding generation](https://github.com/aditya9122002/yojanagpt/blob/main/src/ingestion/embedder.py): `src/ingestion/embedder.py`
- [Ingestion workflow](https://github.com/aditya9122002/yojanagpt/blob/main/src/ingestion/pipeline.py): `src/ingestion/pipeline.py`

### Data collection

- [Scrape orchestration](https://github.com/aditya9122002/yojanagpt/blob/main/src/scraper/scraper.py): `src/scraper/scraper.py`
- [MyScheme client](https://github.com/aditya9122002/yojanagpt/blob/main/src/scraper/client.py): `src/scraper/client.py`
- [Scheme parser](https://github.com/aditya9122002/yojanagpt/blob/main/src/scraper/parser.py): `src/scraper/parser.py`
- [Scheme models](https://github.com/aditya9122002/yojanagpt/blob/main/src/scraper/models.py): `src/scraper/models.py`

### Other components

- **Citizen**
- **Groq API**
- **MyScheme API**

## Connections

- Citizen → Web interface: asks through
- Web interface → FastAPI routes: sends requests
- FastAPI routes → API schemas: validates with (evidence: `src/api/main.py`)
- FastAPI routes → Pipeline dependency: gets pipeline (evidence: `src/api/main.py`)
- FastAPI routes → RAG orchestration: routes questions (evidence: `src/api/main.py`)
- FastAPI routes → Language detection: detects language (evidence: `src/api/main.py`)
- FastAPI routes → Speech synthesis: synthesizes speech (evidence: `src/api/main.py`)
- RAG orchestration → Query translation: translates text (evidence: `src/retrieval/pipeline.py`)
- RAG orchestration → Hybrid retrieval: retrieves chunks (evidence: `src/retrieval/pipeline.py`)
- RAG orchestration → Task prompts: builds prompts (evidence: `src/retrieval/pipeline.py`)
- RAG orchestration → Groq LLM client: generates answer (evidence: `src/retrieval/pipeline.py`)
- Groq LLM client → Groq API: posts prompt (evidence: `src/retrieval/llm.py`)
- Hybrid retrieval → ChromaDB store: searches chunks
- Ingestion workflow → Scheme chunking: chunks schemes (evidence: `src/ingestion/pipeline.py`)
- Ingestion workflow → Embedding generation: embeds chunks (evidence: `src/ingestion/pipeline.py`)
- Ingestion workflow → ChromaDB store: stores embeddings (evidence: `src/ingestion/pipeline.py`)
- Scrape orchestration → MyScheme client: fetches data
- Scrape orchestration → Scheme parser: parses responses
- Scheme parser → Scheme models: creates models
- MyScheme client → MyScheme API: requests scheme data (evidence: `src/scraper/client.py`)
- Scrape orchestration → Ingestion workflow: provides scraped data (evidence: `README.md`)
