# rajumukkell/rag-llm-hdfcmf architecture

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

- Interactive diagram: https://gitdiagram.com/rajumukkell/rag-llm-hdfcmf
- Repository: https://github.com/rajumukkell/rag-llm-hdfcmf

## Overview

This repository is a facts-only HDFC Mutual Fund FAQ RAG chatbot. The user workflow runs through either the Streamlit UI or CLI: guardrails block PII, advice, and performance queries before retrieval; allowed questions retrieve relevant corpus chunks and produce a cited, length-limited answer. Its knowledge pipeline loads scheme snapshots (or optionally fetches live pages), chunks and embeds them, and persists vectors for retrieval. The README documents the CLI and optional Groq phrasing fallback; source excerpts show Streamlit wiring and retrieval, but not CLI wiring, so that edge is documented. Other relationships are limited to calls visible in excerpts; unsampled ingestion wiring is omitted.

Main entry points: [`app.py`](https://github.com/rajumukkell/rag-llm-hdfcmf/blob/main/app.py) (Streamlit UI), [`src/index_bootstrap.py`](https://github.com/rajumukkell/rag-llm-hdfcmf/blob/main/src/index_bootstrap.py) (Index bootstrap), [`src/answer_generator.py`](https://github.com/rajumukkell/rag-llm-hdfcmf/blob/main/src/answer_generator.py) (Answer generation), [`src/retriever.py`](https://github.com/rajumukkell/rag-llm-hdfcmf/blob/main/src/retriever.py) (Semantic retrieval)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User interfaces"]
  node_streamlit["Streamlit UI<br/>[app.py]"]
  node_cli["CLI chat<br/>[run_chat.py]"]
end

subgraph group_knowledge["Corpus pipeline"]
  node_loader["Scheme loader<br/>[loader.py]"]
  node_snapshots["Scheme snapshots"]
  node_source_pages["Public source pages"]
  node_chunker["Chunking<br/>[chunker.py]"]
  node_bootstrap["Index bootstrap<br/>[index_bootstrap.py]"]
end

subgraph group_retrieval["Retrieval and answers"]
  node_embedder["Text embeddings<br/>[embedder.py]"]
  node_vector_store[("Vector store<br/>[vector_store.py]")]
  node_retriever["Semantic retrieval<br/>[retriever.py]"]
  node_answer["Answer generation"]
end

subgraph group_policy["Safety controls"]
  node_guardrails["Query guardrails<br/>[guardrails.py]"]
  node_config["Product configuration<br/>[config.py]"]
end

node_user(("Questioner"))
node_groq["Groq API"]

node_user -->|"asks in"| node_streamlit
node_user -->|"asks in"| node_cli
node_streamlit -->|"checks query"| node_guardrails
node_guardrails -->|"uses policy links"| node_config
node_streamlit -->|"retrieves via"| node_retriever
node_streamlit -->|"generates answer"| node_answer
node_streamlit -->|"ensures index"| node_bootstrap
node_bootstrap -->|"loads corpus"| node_loader
node_loader -->|"reads snapshots"| node_snapshots
node_loader -->|"fetches optionally"| node_source_pages
node_bootstrap -->|"chunks corpus"| node_chunker
node_bootstrap -->|"embeds chunks"| node_embedder
node_bootstrap -->|"rebuilds index"| node_vector_store
node_retriever -->|"embeds query"| node_embedder
node_retriever -->|"queries vectors"| node_vector_store
node_answer -->|"splits sentences"| node_chunker
node_answer -->|"requests phrasing"| node_groq
node_answer -->|"uses limits"| node_config
node_streamlit -->|"renders disclaimers"| node_config
node_cli -.->|"checks before retrieval"| node_guardrails
node_cli -.->|"retrieves and answers"| node_retriever

click node_streamlit "https://github.com/rajumukkell/rag-llm-hdfcmf/blob/main/app.py"
click node_cli "https://github.com/rajumukkell/rag-llm-hdfcmf/blob/main/scripts/run_chat.py"
click node_guardrails "https://github.com/rajumukkell/rag-llm-hdfcmf/blob/main/src/guardrails.py"
click node_loader "https://github.com/rajumukkell/rag-llm-hdfcmf/blob/main/src/loader.py"
click node_snapshots "https://github.com/rajumukkell/rag-llm-hdfcmf/tree/main/data/raw/text"
click node_chunker "https://github.com/rajumukkell/rag-llm-hdfcmf/blob/main/src/chunker.py"
click node_bootstrap "https://github.com/rajumukkell/rag-llm-hdfcmf/blob/main/src/index_bootstrap.py"
click node_embedder "https://github.com/rajumukkell/rag-llm-hdfcmf/blob/main/src/embedder.py"
click node_vector_store "https://github.com/rajumukkell/rag-llm-hdfcmf/blob/main/src/vector_store.py"
click node_retriever "https://github.com/rajumukkell/rag-llm-hdfcmf/blob/main/src/retriever.py"
click node_answer "https://github.com/rajumukkell/rag-llm-hdfcmf/blob/main/src/answer_generator.py"
click node_config "https://github.com/rajumukkell/rag-llm-hdfcmf/blob/main/config.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_streamlit,node_cli toneBlue
class node_loader,node_snapshots,node_source_pages,node_chunker,node_bootstrap toneAmber
class node_embedder,node_vector_store,node_retriever,node_answer,node_groq toneMint
class node_guardrails,node_config toneRose
class node_user toneIndigo
```

## Components

### User interfaces

- [Streamlit UI](https://github.com/rajumukkell/rag-llm-hdfcmf/blob/main/app.py): `app.py`
- [CLI chat](https://github.com/rajumukkell/rag-llm-hdfcmf/blob/main/scripts/run_chat.py): `scripts/run_chat.py`

### Corpus pipeline

- [Scheme loader](https://github.com/rajumukkell/rag-llm-hdfcmf/blob/main/src/loader.py): `src/loader.py`
- [Scheme snapshots](https://github.com/rajumukkell/rag-llm-hdfcmf/tree/main/data/raw/text): `data/raw/text`
- **Public source pages**
- [Chunking](https://github.com/rajumukkell/rag-llm-hdfcmf/blob/main/src/chunker.py): `src/chunker.py`
- [Index bootstrap](https://github.com/rajumukkell/rag-llm-hdfcmf/blob/main/src/index_bootstrap.py): `src/index_bootstrap.py`

### Retrieval and answers

- [Text embeddings](https://github.com/rajumukkell/rag-llm-hdfcmf/blob/main/src/embedder.py): `src/embedder.py`
- [Vector store](https://github.com/rajumukkell/rag-llm-hdfcmf/blob/main/src/vector_store.py): `src/vector_store.py`
- [Semantic retrieval](https://github.com/rajumukkell/rag-llm-hdfcmf/blob/main/src/retriever.py): `src/retriever.py`
- [Answer generation](https://github.com/rajumukkell/rag-llm-hdfcmf/blob/main/src/answer_generator.py): `src/answer_generator.py`

### Safety controls

- [Query guardrails](https://github.com/rajumukkell/rag-llm-hdfcmf/blob/main/src/guardrails.py): `src/guardrails.py`
- [Product configuration](https://github.com/rajumukkell/rag-llm-hdfcmf/blob/main/config.py): `config.py`

### Other components

- **Questioner**
- **Groq API**

## Connections

- Questioner → Streamlit UI: asks in (evidence: `README.md`)
- Questioner → CLI chat: asks in (evidence: `README.md`)
- Streamlit UI → Query guardrails: checks query (evidence: `app.py`)
- Query guardrails → Product configuration: uses policy links (evidence: `src/guardrails.py`)
- Streamlit UI → Semantic retrieval: retrieves via (evidence: `app.py`)
- Streamlit UI → Answer generation: generates answer (evidence: `app.py`)
- Streamlit UI → Index bootstrap: ensures index (evidence: `app.py`)
- Index bootstrap → Scheme loader: loads corpus (evidence: `src/index_bootstrap.py`)
- Scheme loader → Scheme snapshots: reads snapshots (evidence: `src/loader.py`)
- Scheme loader → Public source pages: fetches optionally (evidence: `src/loader.py`)
- Index bootstrap → Chunking: chunks corpus (evidence: `src/index_bootstrap.py`)
- Index bootstrap → Text embeddings: embeds chunks (evidence: `src/index_bootstrap.py`)
- Index bootstrap → Vector store: rebuilds index (evidence: `src/index_bootstrap.py`)
- Semantic retrieval → Text embeddings: embeds query (evidence: `src/retriever.py`)
- Semantic retrieval → Vector store: queries vectors (evidence: `src/retriever.py`)
- Answer generation → Chunking: splits sentences (evidence: `src/answer_generator.py`)
- Answer generation → Groq API: requests phrasing (evidence: `README.md`)
- Answer generation → Product configuration: uses limits (evidence: `src/answer_generator.py`)
- Streamlit UI → Product configuration: renders disclaimers (evidence: `app.py`)
- CLI chat → Query guardrails: checks before retrieval (evidence: `README.md`)
- CLI chat → Semantic retrieval: retrieves and answers (evidence: `README.md`)
