# mahfuz-raihan/agentic-rag-system architecture

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

- Interactive diagram: https://gitdiagram.com/mahfuz-raihan/agentic-rag-system
- Repository: https://github.com/mahfuz-raihan/agentic-rag-system

## Overview

This is a session-isolated, multi-agent RAG assistant for document questions, tabular analysis, and general chat. Users upload files and ask a question in the Chainlit UI; attachments are parsed into per-session text indexes or dataframes, then the LangGraph workflow routes the question to a specialist. Document retrieval and data analysis produce answers for critic review, with rejected answers rewritten and retried up to the workflow limit. README-described capabilities are included; wiring is based on the sampled UI, ingestion, agent, and graph code.

Main entry points: [`core/graph.py`](https://github.com/mahfuz-raihan/agentic-rag-system/blob/main/core/graph.py) (Agent graph), [`core/llm.py`](https://github.com/mahfuz-raihan/agentic-rag-system/blob/main/core/llm.py) (LLM clients), [`ui/app.py`](https://github.com/mahfuz-raihan/agentic-rag-system/blob/main/ui/app.py) (Chainlit UI), [`core/ingestion.py`](https://github.com/mahfuz-raihan/agentic-rag-system/blob/main/core/ingestion.py) (File ingestion)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["User interface"]
  node_chat_ui["Chainlit UI<br/>[app.py]"]
end

subgraph group_data["Ingestion and session data"]
  node_ingestion["File ingestion<br/>[ingestion.py]"]
  node_session_store[("Session store<br/>[session_store.py]")]
end

subgraph group_workflow["Workflow orchestration"]
  node_workflow_graph["Agent graph<br/>[graph.py]"]
  node_state["Workflow state<br/>[state.py]"]
end

subgraph group_agents["Specialist agents"]
  node_supervisor["Supervisor<br/>[supervisor.py]"]
  node_retrieve["Document retrieval<br/>[text_rag.py]"]
  node_generate["Answer generation<br/>[text_rag.py]"]
  node_data_analyst["Data analyst<br/>[data_analyst.py]"]
  node_critic["Answer critic"]
  node_transformer["Query rewriting"]
  node_general["General chat<br/>[general.py]"]
end

subgraph group_services["Model service"]
  node_llm_client["LLM clients<br/>[llm.py]"]
end

node_user(("User"))
node_azure_openai["Azure OpenAI"]

node_user -->|"sends query"| node_chat_ui
node_chat_ui -->|"processes attachments"| node_ingestion
node_ingestion -->|"stores session data"| node_session_store
node_ingestion -->|"requests embeddings"| node_llm_client
node_llm_client -->|"calls embeddings"| node_azure_openai
node_chat_ui -->|"invokes workflow"| node_workflow_graph
node_workflow_graph -->|"dispatches"| node_supervisor
node_workflow_graph -->|"dispatches"| node_retrieve
node_workflow_graph -->|"dispatches"| node_generate
node_workflow_graph -->|"dispatches"| node_data_analyst
node_workflow_graph -->|"dispatches"| node_critic
node_workflow_graph -->|"dispatches"| node_transformer
node_workflow_graph -->|"dispatches"| node_general
node_retrieve -->|"reads index"| node_session_store
node_data_analyst -->|"reads dataframe"| node_session_store
node_supervisor -->|"creates chat client"| node_llm_client
node_retrieve -->|"passes documents"| node_generate
node_generate -->|"creates chat client"| node_llm_client
node_data_analyst -->|"creates chat client"| node_llm_client
node_critic -->|"creates chat client"| node_llm_client
node_transformer -->|"creates chat client"| node_llm_client
node_general -->|"creates chat client"| node_llm_client
node_llm_client -->|"calls chat model"| node_azure_openai
node_workflow_graph -->|"retries rejected answer"| node_transformer
node_chat_ui -->|"streams answer and charts"| node_user
node_workflow_graph -->|"returns workflow updates"| node_chat_ui

click node_chat_ui "https://github.com/mahfuz-raihan/agentic-rag-system/blob/main/ui/app.py"
click node_ingestion "https://github.com/mahfuz-raihan/agentic-rag-system/blob/main/core/ingestion.py"
click node_session_store "https://github.com/mahfuz-raihan/agentic-rag-system/blob/main/core/session_store.py"
click node_llm_client "https://github.com/mahfuz-raihan/agentic-rag-system/blob/main/core/llm.py"
click node_workflow_graph "https://github.com/mahfuz-raihan/agentic-rag-system/blob/main/core/graph.py"
click node_state "https://github.com/mahfuz-raihan/agentic-rag-system/blob/main/core/state.py"
click node_supervisor "https://github.com/mahfuz-raihan/agentic-rag-system/blob/main/agents/supervisor.py"
click node_retrieve "https://github.com/mahfuz-raihan/agentic-rag-system/blob/main/agents/text_rag.py"
click node_generate "https://github.com/mahfuz-raihan/agentic-rag-system/blob/main/agents/text_rag.py"
click node_data_analyst "https://github.com/mahfuz-raihan/agentic-rag-system/blob/main/agents/data_analyst.py"
click node_critic "https://github.com/mahfuz-raihan/agentic-rag-system/blob/main/agents/critic_transformer.py"
click node_transformer "https://github.com/mahfuz-raihan/agentic-rag-system/blob/main/agents/critic_transformer.py"
click node_general "https://github.com/mahfuz-raihan/agentic-rag-system/blob/main/agents/general.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_chat_ui,node_user toneBlue
class node_ingestion,node_session_store toneAmber
class node_workflow_graph,node_state toneMint
class node_supervisor,node_retrieve,node_generate,node_data_analyst,node_critic,node_transformer,node_general toneRose
class node_llm_client,node_azure_openai toneIndigo
```

## Components

### User interface

- [Chainlit UI](https://github.com/mahfuz-raihan/agentic-rag-system/blob/main/ui/app.py): `ui/app.py`

### Ingestion and session data

- [File ingestion](https://github.com/mahfuz-raihan/agentic-rag-system/blob/main/core/ingestion.py): `core/ingestion.py`
- [Session store](https://github.com/mahfuz-raihan/agentic-rag-system/blob/main/core/session_store.py): `core/session_store.py`

### Workflow orchestration

- [Agent graph](https://github.com/mahfuz-raihan/agentic-rag-system/blob/main/core/graph.py): `core/graph.py`
- [Workflow state](https://github.com/mahfuz-raihan/agentic-rag-system/blob/main/core/state.py): `core/state.py`

### Specialist agents

- [Supervisor](https://github.com/mahfuz-raihan/agentic-rag-system/blob/main/agents/supervisor.py): `agents/supervisor.py`
- [Document retrieval](https://github.com/mahfuz-raihan/agentic-rag-system/blob/main/agents/text_rag.py): `agents/text_rag.py`
- [Answer generation](https://github.com/mahfuz-raihan/agentic-rag-system/blob/main/agents/text_rag.py): `agents/text_rag.py`
- [Data analyst](https://github.com/mahfuz-raihan/agentic-rag-system/blob/main/agents/data_analyst.py): `agents/data_analyst.py`
- [Answer critic](https://github.com/mahfuz-raihan/agentic-rag-system/blob/main/agents/critic_transformer.py): `agents/critic_transformer.py`
- [Query rewriting](https://github.com/mahfuz-raihan/agentic-rag-system/blob/main/agents/critic_transformer.py): `agents/critic_transformer.py`
- [General chat](https://github.com/mahfuz-raihan/agentic-rag-system/blob/main/agents/general.py): `agents/general.py`

### Model service

- [LLM clients](https://github.com/mahfuz-raihan/agentic-rag-system/blob/main/core/llm.py): `core/llm.py`

### Other components

- **User**
- **Azure OpenAI**

## Connections

- User → Chainlit UI: sends query
- Chainlit UI → File ingestion: processes attachments
- File ingestion → Session store: stores session data
- File ingestion → LLM clients: requests embeddings
- LLM clients → Azure OpenAI: calls embeddings
- Chainlit UI → Agent graph: invokes workflow
- Agent graph → Supervisor: dispatches
- Agent graph → Document retrieval: dispatches
- Agent graph → Answer generation: dispatches
- Agent graph → Data analyst: dispatches
- Agent graph → Answer critic: dispatches
- Agent graph → Query rewriting: dispatches
- Agent graph → General chat: dispatches
- Document retrieval → Session store: reads index
- Data analyst → Session store: reads dataframe
- Supervisor → LLM clients: creates chat client
- Document retrieval → Answer generation: passes documents
- Answer generation → LLM clients: creates chat client
- Data analyst → LLM clients: creates chat client
- Answer critic → LLM clients: creates chat client
- Query rewriting → LLM clients: creates chat client
- General chat → LLM clients: creates chat client
- LLM clients → Azure OpenAI: calls chat model
- Agent graph → Query rewriting: retries rejected answer
- Chainlit UI → User: streams answer and charts
- Agent graph → Chainlit UI: returns workflow updates
