# hamdha-saheer/agentic-rag-insurance-lk architecture

> Architecture diagram of the GitHub repository hamdha-saheer/agentic-rag-insurance-lk, 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/hamdha-saheer/agentic-rag-insurance-lk
- Repository: https://github.com/hamdha-saheer/agentic-rag-insurance-lk

## Overview

This is a Streamlit advisor for Sri Lankan insurance questions. A user supplies a question and optional profile; the LangGraph supervisor selects up to two domains, domain agents query their separate indexes, and an aggregator returns advice and sources to the UI. The retrieval layer loads FAISS indexes, embeds queries, and generates cited answers with Groq. The README also documents optional Tavily search and OCR-based document preparation, but their implementation is not present in the shown tree. Evaluation is a separate workflow; its source was sampled.

Main entry points: [`agents/rag_pipeline.py`](https://github.com/hamdha-saheer/agentic-rag-insurance-lk/blob/main/agents/rag_pipeline.py) (RAG pipeline), [`agents/multi_agent.py`](https://github.com/hamdha-saheer/agentic-rag-insurance-lk/blob/main/agents/multi_agent.py) (Supervisor routing), [`evaluation/evaluator.py`](https://github.com/hamdha-saheer/agentic-rag-insurance-lk/blob/main/evaluation/evaluator.py) (Answer evaluator), [`app.py`](https://github.com/hamdha-saheer/agentic-rag-insurance-lk/blob/main/app.py) (Streamlit advisor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interface"]
  node_streamlit["Streamlit advisor<br/>[app.py]"]
end

subgraph group_orchestration["Query orchestration"]
  node_supervisor["Supervisor routing<br/>[multi_agent.py]"]
  node_domain_router["Domain classifier<br/>[domain_router.py]"]
  node_motor_agent["Motor agent<br/>[multi_agent.py]"]
  node_health_agent["Health agent<br/>[multi_agent.py]"]
  node_life_agent["Life agent<br/>[multi_agent.py]"]
  node_general_agent["General agent<br/>[multi_agent.py]"]
  node_aggregator["Answer aggregator<br/>[multi_agent.py]"]
end

subgraph group_retrieval["Retrieval and generation"]
  node_rag["RAG pipeline<br/>[rag_pipeline.py]"]
  node_embeddings["Query embeddings<br/>[rag_pipeline.py]"]
  node_faiss_indexes[("Domain FAISS indexes<br/>[rag_pipeline.py]")]
  node_prompt_llm["Prompt and generation<br/>[rag_pipeline.py]"]
  node_groq{{"Groq LLM"}}
  node_config["Runtime configuration<br/>[config.py]"]
  node_tavily{{"Tavily search"}}
end

subgraph group_evaluation["Evaluation"]
  node_evaluator["Answer evaluator<br/>[evaluator.py]"]
  node_ground_truth["Ground-truth questions<br/>[ground_truth.json]"]
  node_evaluation_results["Evaluation results"]
end

node_user(("Insurance user"))

node_user -->|"asks question"| node_streamlit
node_streamlit -->|"submits query"| node_supervisor
node_supervisor -->|"classifies query"| node_domain_router
node_supervisor -->|"dispatches motor"| node_motor_agent
node_supervisor -->|"dispatches health"| node_health_agent
node_supervisor -->|"dispatches life"| node_life_agent
node_supervisor -->|"dispatches general"| node_general_agent
node_motor_agent -->|"queries index"| node_rag
node_health_agent -->|"queries index"| node_rag
node_life_agent -->|"queries index"| node_rag
node_general_agent -->|"queries index"| node_rag
node_motor_agent -->|"joins result"| node_aggregator
node_health_agent -->|"joins result"| node_aggregator
node_life_agent -->|"joins result"| node_aggregator
node_general_agent -->|"joins result"| node_aggregator
node_aggregator -->|"returns advice"| node_streamlit
node_rag -->|"reads settings"| node_config
node_rag -->|"loads and searches"| node_faiss_indexes
node_rag -->|"embeds query"| node_embeddings
node_rag -->|"builds prompt"| node_prompt_llm
node_prompt_llm -->|"generates answer"| node_groq
node_evaluator -->|"loads questions"| node_ground_truth
node_evaluator -->|"routes questions"| node_domain_router
node_evaluator -->|"generates answers"| node_rag
node_evaluator -->|"scores answers"| node_groq
node_evaluator -->|"writes scores"| node_evaluation_results
node_rag -.->|"optional web search"| node_tavily

click node_streamlit "https://github.com/hamdha-saheer/agentic-rag-insurance-lk/blob/main/app.py"
click node_supervisor "https://github.com/hamdha-saheer/agentic-rag-insurance-lk/blob/main/agents/multi_agent.py"
click node_domain_router "https://github.com/hamdha-saheer/agentic-rag-insurance-lk/blob/main/agents/domain_router.py"
click node_motor_agent "https://github.com/hamdha-saheer/agentic-rag-insurance-lk/blob/main/agents/multi_agent.py"
click node_health_agent "https://github.com/hamdha-saheer/agentic-rag-insurance-lk/blob/main/agents/multi_agent.py"
click node_life_agent "https://github.com/hamdha-saheer/agentic-rag-insurance-lk/blob/main/agents/multi_agent.py"
click node_general_agent "https://github.com/hamdha-saheer/agentic-rag-insurance-lk/blob/main/agents/multi_agent.py"
click node_aggregator "https://github.com/hamdha-saheer/agentic-rag-insurance-lk/blob/main/agents/multi_agent.py"
click node_rag "https://github.com/hamdha-saheer/agentic-rag-insurance-lk/blob/main/agents/rag_pipeline.py"
click node_embeddings "https://github.com/hamdha-saheer/agentic-rag-insurance-lk/blob/main/agents/rag_pipeline.py"
click node_faiss_indexes "https://github.com/hamdha-saheer/agentic-rag-insurance-lk/blob/main/agents/rag_pipeline.py"
click node_prompt_llm "https://github.com/hamdha-saheer/agentic-rag-insurance-lk/blob/main/agents/rag_pipeline.py"
click node_config "https://github.com/hamdha-saheer/agentic-rag-insurance-lk/blob/main/config.py"
click node_evaluator "https://github.com/hamdha-saheer/agentic-rag-insurance-lk/blob/main/evaluation/evaluator.py"
click node_ground_truth "https://github.com/hamdha-saheer/agentic-rag-insurance-lk/blob/main/evaluation/ground_truth.json"
click node_evaluation_results "https://github.com/hamdha-saheer/agentic-rag-insurance-lk/tree/main/evaluation/results"

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_user toneBlue
class node_supervisor,node_domain_router,node_motor_agent,node_health_agent,node_life_agent,node_general_agent,node_aggregator toneAmber
class node_rag,node_embeddings,node_faiss_indexes,node_prompt_llm,node_groq,node_config,node_tavily toneMint
class node_evaluator,node_ground_truth,node_evaluation_results toneRose
```

## Components

### User interface

- [Streamlit advisor](https://github.com/hamdha-saheer/agentic-rag-insurance-lk/blob/main/app.py): `app.py`

### Query orchestration

- [Supervisor routing](https://github.com/hamdha-saheer/agentic-rag-insurance-lk/blob/main/agents/multi_agent.py): `agents/multi_agent.py`
- [Domain classifier](https://github.com/hamdha-saheer/agentic-rag-insurance-lk/blob/main/agents/domain_router.py): `agents/domain_router.py`
- [Motor agent](https://github.com/hamdha-saheer/agentic-rag-insurance-lk/blob/main/agents/multi_agent.py): `agents/multi_agent.py`
- [Health agent](https://github.com/hamdha-saheer/agentic-rag-insurance-lk/blob/main/agents/multi_agent.py): `agents/multi_agent.py`
- [Life agent](https://github.com/hamdha-saheer/agentic-rag-insurance-lk/blob/main/agents/multi_agent.py): `agents/multi_agent.py`
- [General agent](https://github.com/hamdha-saheer/agentic-rag-insurance-lk/blob/main/agents/multi_agent.py): `agents/multi_agent.py`
- [Answer aggregator](https://github.com/hamdha-saheer/agentic-rag-insurance-lk/blob/main/agents/multi_agent.py): `agents/multi_agent.py`

### Retrieval and generation

- [RAG pipeline](https://github.com/hamdha-saheer/agentic-rag-insurance-lk/blob/main/agents/rag_pipeline.py): `agents/rag_pipeline.py`
- [Query embeddings](https://github.com/hamdha-saheer/agentic-rag-insurance-lk/blob/main/agents/rag_pipeline.py): `agents/rag_pipeline.py`
- [Domain FAISS indexes](https://github.com/hamdha-saheer/agentic-rag-insurance-lk/blob/main/agents/rag_pipeline.py): `agents/rag_pipeline.py`
- [Prompt and generation](https://github.com/hamdha-saheer/agentic-rag-insurance-lk/blob/main/agents/rag_pipeline.py): `agents/rag_pipeline.py`
- **Groq LLM**
- [Runtime configuration](https://github.com/hamdha-saheer/agentic-rag-insurance-lk/blob/main/config.py): `config.py`
- **Tavily search**

### Evaluation

- [Answer evaluator](https://github.com/hamdha-saheer/agentic-rag-insurance-lk/blob/main/evaluation/evaluator.py): `evaluation/evaluator.py`
- [Ground-truth questions](https://github.com/hamdha-saheer/agentic-rag-insurance-lk/blob/main/evaluation/ground_truth.json): `evaluation/ground_truth.json`
- [Evaluation results](https://github.com/hamdha-saheer/agentic-rag-insurance-lk/tree/main/evaluation/results): `evaluation/results`

### Other components

- **Insurance user**

## Connections

- Insurance user → Streamlit advisor: asks question (evidence: `app.py`)
- Streamlit advisor → Supervisor routing: submits query (evidence: `app.py`)
- Supervisor routing → Domain classifier: classifies query (evidence: `agents/multi_agent.py`)
- Supervisor routing → Motor agent: dispatches motor (evidence: `agents/multi_agent.py`)
- Supervisor routing → Health agent: dispatches health (evidence: `agents/multi_agent.py`)
- Supervisor routing → Life agent: dispatches life (evidence: `agents/multi_agent.py`)
- Supervisor routing → General agent: dispatches general (evidence: `agents/multi_agent.py`)
- Motor agent → RAG pipeline: queries index (evidence: `agents/multi_agent.py`)
- Health agent → RAG pipeline: queries index (evidence: `agents/multi_agent.py`)
- Life agent → RAG pipeline: queries index (evidence: `agents/multi_agent.py`)
- General agent → RAG pipeline: queries index (evidence: `agents/multi_agent.py`)
- Motor agent → Answer aggregator: joins result (evidence: `agents/multi_agent.py`)
- Health agent → Answer aggregator: joins result (evidence: `agents/multi_agent.py`)
- Life agent → Answer aggregator: joins result (evidence: `agents/multi_agent.py`)
- General agent → Answer aggregator: joins result (evidence: `agents/multi_agent.py`)
- Answer aggregator → Streamlit advisor: returns advice (evidence: `agents/multi_agent.py`)
- RAG pipeline → Runtime configuration: reads settings (evidence: `agents/rag_pipeline.py`)
- RAG pipeline → Domain FAISS indexes: loads and searches (evidence: `agents/rag_pipeline.py`)
- RAG pipeline → Query embeddings: embeds query (evidence: `agents/rag_pipeline.py`)
- RAG pipeline → Prompt and generation: builds prompt (evidence: `agents/rag_pipeline.py`)
- Prompt and generation → Groq LLM: generates answer (evidence: `agents/rag_pipeline.py`)
- Answer evaluator → Ground-truth questions: loads questions (evidence: `evaluation/evaluator.py`)
- Answer evaluator → Domain classifier: routes questions (evidence: `evaluation/evaluator.py`)
- Answer evaluator → RAG pipeline: generates answers (evidence: `evaluation/evaluator.py`)
- Answer evaluator → Groq LLM: scores answers (evidence: `evaluation/evaluator.py`)
- Answer evaluator → Evaluation results: writes scores (evidence: `evaluation/evaluator.py`)
- RAG pipeline → Tavily search: optional web search (evidence: `README.md`)
