# naresh1401/agenticragchatbot architecture

> Architecture diagram of the GitHub repository naresh1401/agenticragchatbot, 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/naresh1401/agenticragchatbot
- Repository: https://github.com/naresh1401/agenticragchatbot

## Overview

Agentic RAG chatbot: users chat through the web UI, while the FastAPI backend runs guarded agent reasoning over vector and SQL retrieval, uses session memory, verifies answers, and returns citations. Separate upload, URL-ingest, and scrape routes feed documents through loading, chunking, embedding, and indexing. The graph preserves the documented API and ingestion capabilities; several endpoint details and the agent’s internal routing are unsampled, so uncertain links are omitted.

Main entry points: [`backend/main.py`](https://github.com/naresh1401/agenticragchatbot/blob/main/backend/main.py) (FastAPI API), [`backend/agents/graph.py`](https://github.com/naresh1401/agenticragchatbot/blob/main/backend/agents/graph.py) (LangGraph agent), [`backend/ingestion/indexer.py`](https://github.com/naresh1401/agenticragchatbot/blob/main/backend/ingestion/indexer.py) (Ingestion indexer), [`backend/agents/tools.py`](https://github.com/naresh1401/agenticragchatbot/blob/main/backend/agents/tools.py) (Agent tools)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["User interaction"]
  node_web_ui["Chat UI<br/>[chat.html]"]
  node_api["FastAPI API<br/>[main.py]"]
  node_schemas["API schemas<br/>[schemas.py]"]
end

subgraph group_agent["Agent workflow"]
  node_agent_graph["LangGraph agent<br/>[graph.py]"]
  node_agent_tools["Agent tools<br/>[tools.py]"]
  node_input_guardrails["Input guardrails"]
  node_pii_redactor["PII redaction<br/>[pii_redactor.py]"]
  node_answer_verifier["Answer verification<br/>[answer_verifier.py]"]
end

subgraph group_ingestion["Knowledge ingestion"]
  node_indexer["Ingestion indexer<br/>[indexer.py]"]
  node_document_loader["Document loaders<br/>[document_loader.py]"]
  node_chunker["Chunking<br/>[chunker.py]"]
  node_embedder["Embedding<br/>[embedder.py]"]
end

subgraph group_stores["Retrieval and state"]
  node_session_memory[("Session memory<br/>[session_store.py]")]
  node_vector_store[("Chroma vector store<br/>[vector_store.py]")]
  node_sql_store[("SQLite store<br/>[sql_store.py]")]
end

subgraph group_platform["Shared services"]
  node_config["Configuration<br/>[config.py]"]
  node_logger["Structured logging<br/>[logger.py]"]
end

node_user(("User"))
node_llm_service{{"OpenAI-compatible LLM"}}

node_user -->|"uses"| node_web_ui
node_web_ui -->|"sends chat"| node_api
node_api -->|"runs chat"| node_agent_graph
node_api -->|"manages sessions"| node_session_memory
node_api -->|"starts ingestion"| node_indexer
node_api -->|"lists sources"| node_vector_store
node_api -->|"validates requests"| node_schemas
node_agent_graph -->|"checks input"| node_input_guardrails
node_agent_graph -->|"redacts input"| node_pii_redactor
node_agent_graph -->|"binds tools"| node_agent_tools
node_agent_graph -->|"verifies answer"| node_answer_verifier
node_agent_graph -.->|"invokes model"| node_llm_service
node_agent_tools -->|"retrieves documents"| node_vector_store
node_agent_tools -->|"queries tables"| node_sql_store
node_indexer -->|"loads files"| node_document_loader
node_indexer -->|"chunks text"| node_chunker
node_indexer -->|"embeds chunks"| node_embedder
node_indexer -->|"writes vectors"| node_vector_store
node_indexer -->|"loads structured data"| node_sql_store
node_embedder -.->|"requests embeddings"| node_llm_service
node_api -.->|"uses settings"| node_config
node_agent_graph -->|"reads settings"| node_config

click node_web_ui "https://github.com/naresh1401/agenticragchatbot/blob/main/frontend/chat.html"
click node_api "https://github.com/naresh1401/agenticragchatbot/blob/main/backend/main.py"
click node_schemas "https://github.com/naresh1401/agenticragchatbot/blob/main/backend/models/schemas.py"
click node_agent_graph "https://github.com/naresh1401/agenticragchatbot/blob/main/backend/agents/graph.py"
click node_agent_tools "https://github.com/naresh1401/agenticragchatbot/blob/main/backend/agents/tools.py"
click node_input_guardrails "https://github.com/naresh1401/agenticragchatbot/blob/main/backend/guardrails/injection_detector.py"
click node_pii_redactor "https://github.com/naresh1401/agenticragchatbot/blob/main/backend/guardrails/pii_redactor.py"
click node_answer_verifier "https://github.com/naresh1401/agenticragchatbot/blob/main/backend/guardrails/answer_verifier.py"
click node_session_memory "https://github.com/naresh1401/agenticragchatbot/blob/main/backend/memory/session_store.py"
click node_indexer "https://github.com/naresh1401/agenticragchatbot/blob/main/backend/ingestion/indexer.py"
click node_document_loader "https://github.com/naresh1401/agenticragchatbot/blob/main/backend/ingestion/document_loader.py"
click node_chunker "https://github.com/naresh1401/agenticragchatbot/blob/main/backend/ingestion/chunker.py"
click node_embedder "https://github.com/naresh1401/agenticragchatbot/blob/main/backend/ingestion/embedder.py"
click node_vector_store "https://github.com/naresh1401/agenticragchatbot/blob/main/backend/retrieval/vector_store.py"
click node_sql_store "https://github.com/naresh1401/agenticragchatbot/blob/main/backend/retrieval/sql_store.py"
click node_config "https://github.com/naresh1401/agenticragchatbot/blob/main/backend/config.py"
click node_logger "https://github.com/naresh1401/agenticragchatbot/blob/main/backend/utils/logger.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_web_ui,node_api,node_schemas,node_user toneBlue
class node_agent_graph,node_agent_tools,node_input_guardrails,node_pii_redactor,node_answer_verifier toneAmber
class node_indexer,node_document_loader,node_chunker,node_embedder toneMint
class node_session_memory,node_vector_store,node_sql_store toneRose
class node_config,node_logger,node_llm_service toneIndigo
```

## Components

### User interaction

- [Chat UI](https://github.com/naresh1401/agenticragchatbot/blob/main/frontend/chat.html): `frontend/chat.html`
- [FastAPI API](https://github.com/naresh1401/agenticragchatbot/blob/main/backend/main.py): `backend/main.py`
- [API schemas](https://github.com/naresh1401/agenticragchatbot/blob/main/backend/models/schemas.py): `backend/models/schemas.py`

### Agent workflow

- [LangGraph agent](https://github.com/naresh1401/agenticragchatbot/blob/main/backend/agents/graph.py): `backend/agents/graph.py`
- [Agent tools](https://github.com/naresh1401/agenticragchatbot/blob/main/backend/agents/tools.py): `backend/agents/tools.py`
- [Input guardrails](https://github.com/naresh1401/agenticragchatbot/blob/main/backend/guardrails/injection_detector.py): `backend/guardrails/injection_detector.py`
- [PII redaction](https://github.com/naresh1401/agenticragchatbot/blob/main/backend/guardrails/pii_redactor.py): `backend/guardrails/pii_redactor.py`
- [Answer verification](https://github.com/naresh1401/agenticragchatbot/blob/main/backend/guardrails/answer_verifier.py): `backend/guardrails/answer_verifier.py`

### Knowledge ingestion

- [Ingestion indexer](https://github.com/naresh1401/agenticragchatbot/blob/main/backend/ingestion/indexer.py): `backend/ingestion/indexer.py`
- [Document loaders](https://github.com/naresh1401/agenticragchatbot/blob/main/backend/ingestion/document_loader.py): `backend/ingestion/document_loader.py`
- [Chunking](https://github.com/naresh1401/agenticragchatbot/blob/main/backend/ingestion/chunker.py): `backend/ingestion/chunker.py`
- [Embedding](https://github.com/naresh1401/agenticragchatbot/blob/main/backend/ingestion/embedder.py): `backend/ingestion/embedder.py`

### Retrieval and state

- [Session memory](https://github.com/naresh1401/agenticragchatbot/blob/main/backend/memory/session_store.py): `backend/memory/session_store.py`
- [Chroma vector store](https://github.com/naresh1401/agenticragchatbot/blob/main/backend/retrieval/vector_store.py): `backend/retrieval/vector_store.py`
- [SQLite store](https://github.com/naresh1401/agenticragchatbot/blob/main/backend/retrieval/sql_store.py): `backend/retrieval/sql_store.py`

### Shared services

- [Configuration](https://github.com/naresh1401/agenticragchatbot/blob/main/backend/config.py): `backend/config.py`
- [Structured logging](https://github.com/naresh1401/agenticragchatbot/blob/main/backend/utils/logger.py): `backend/utils/logger.py`

### Other components

- **User**
- **OpenAI-compatible LLM**

## Connections

- User → Chat UI: uses (evidence: `README.md`)
- Chat UI → FastAPI API: sends chat (evidence: `README.md`)
- FastAPI API → LangGraph agent: runs chat (evidence: `backend/main.py`)
- FastAPI API → Session memory: manages sessions (evidence: `backend/main.py`)
- FastAPI API → Ingestion indexer: starts ingestion (evidence: `backend/main.py`)
- FastAPI API → Chroma vector store: lists sources (evidence: `backend/main.py`)
- FastAPI API → API schemas: validates requests (evidence: `backend/main.py`)
- LangGraph agent → Input guardrails: checks input (evidence: `backend/agents/graph.py`)
- LangGraph agent → PII redaction: redacts input (evidence: `backend/agents/graph.py`)
- LangGraph agent → Agent tools: binds tools (evidence: `backend/agents/graph.py`)
- LangGraph agent → Answer verification: verifies answer (evidence: `backend/agents/graph.py`)
- LangGraph agent → OpenAI-compatible LLM: invokes model (evidence: `README.md`)
- Agent tools → Chroma vector store: retrieves documents (evidence: `backend/agents/tools.py`)
- Agent tools → SQLite store: queries tables (evidence: `backend/agents/tools.py`)
- Ingestion indexer → Document loaders: loads files (evidence: `backend/ingestion/indexer.py`)
- Ingestion indexer → Chunking: chunks text (evidence: `backend/ingestion/indexer.py`)
- Ingestion indexer → Embedding: embeds chunks (evidence: `backend/ingestion/indexer.py`)
- Ingestion indexer → Chroma vector store: writes vectors (evidence: `backend/ingestion/indexer.py`)
- Ingestion indexer → SQLite store: loads structured data (evidence: `backend/ingestion/indexer.py`)
- Embedding → OpenAI-compatible LLM: requests embeddings (evidence: `README.md`)
- FastAPI API → Configuration: uses settings (evidence: `backend/main.py`)
- LangGraph agent → Configuration: reads settings (evidence: `backend/agents/graph.py`)
