# rgnarmadha/chatbot-trial architecture

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

- Interactive diagram: https://gitdiagram.com/rgnarmadha/chatbot-trial
- Repository: https://github.com/rgnarmadha/chatbot-trial

## Overview

This is a LangGraph conversational chatbot whose CLI accepts a user turn, runs a stateful router loop, and returns a final answer. The router can request knowledge retrieval or an MCP tool call before dispatching to the responder. A separate ingestion workflow loads and chunks documents, embeds them, and persists vectors for retrieval. The graph captures the documented runtime branches and source-visible calls; MCP server details and some LLM backend behavior are not fully sampled, so uncertain integrations are omitted.

Main entry points: [`agent/graph.py`](https://github.com/rgnarmadha/chatbot-trial/blob/master/agent/graph.py) (Graph runner), [`rag/ingestion/pipeline.py`](https://github.com/rgnarmadha/chatbot-trial/blob/master/rag/ingestion/pipeline.py) (Ingestion pipeline), [`mcp_tools/registry.py`](https://github.com/rgnarmadha/chatbot-trial/blob/master/mcp_tools/registry.py) (MCP registry), [`agent/nodes/router.py`](https://github.com/rgnarmadha/chatbot-trial/blob/master/agent/nodes/router.py) (Action router)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_conversation["Conversation workflow"]
  node_entry["CLI entry<br/>[main.py]"]
  node_cli["Chat interface<br/>[interface.py]"]
  node_graph["Graph runner<br/>[graph.py]"]
  node_state["Conversation state<br/>[state.py]"]
  node_router["Action router<br/>[router.py]"]
  node_prompt["System prompts<br/>[system.py]"]
  node_retriever_node["Retrieval node<br/>[retriever.py]"]
  node_tool_caller["Tool caller<br/>[tool_caller.py]"]
  node_responder["Response node<br/>[responder.py]"]
end

subgraph group_knowledge["Knowledge base"]
  node_ingestion["Ingestion pipeline<br/>[pipeline.py]"]
  node_loaders["Document loaders<br/>[loaders.py]"]
  node_chunker["Document chunker<br/>[chunker.py]"]
  node_embedder["Text embeddings<br/>[embeddings.py]"]
  node_rag_retriever["RAG retriever<br/>[retriever.py]"]
  node_store[("Vector store<br/>[store.py]")]
end

subgraph group_tools["MCP tools"]
  node_registry["MCP registry<br/>[registry.py]"]
  node_mcp_client["MCP client<br/>[client.py]"]
end

subgraph group_runtime["Runtime services"]
  node_llm["LLM backend<br/>[backend.py]"]
  node_settings["Application settings<br/>[settings.py]"]
end

node_user(("Chat user"))
node_llm_service{{"LLM service"}}
node_mcp_server{{"MCP servers"}}

node_user -->|"enters turn"| node_cli
node_entry -->|"builds graph"| node_graph
node_entry -->|"starts loop"| node_cli
node_cli -->|"runs turn"| node_graph
node_graph -->|"dispatches"| node_router
node_graph -->|"dispatches"| node_retriever_node
node_graph -->|"dispatches"| node_tool_caller
node_graph -->|"dispatches"| node_responder
node_graph -->|"tracks state"| node_state
node_router -->|"requests decision"| node_llm
node_responder -->|"generates answer"| node_llm
node_router -->|"formats prompt"| node_prompt
node_responder -->|"uses prompt"| node_prompt
node_retriever_node -->|"retrieves context"| node_rag_retriever
node_tool_caller -->|"calls tool"| node_registry
node_graph -->|"discovers tools"| node_registry
node_registry -->|"routes calls"| node_mcp_client
node_mcp_client -.->|"connects"| node_mcp_server
node_ingestion -->|"loads documents"| node_loaders
node_ingestion -->|"chunks documents"| node_chunker
node_ingestion -->|"embeds chunks"| node_embedder
node_ingestion -->|"upserts vectors"| node_store
node_rag_retriever -->|"embeds query"| node_embedder
node_rag_retriever -->|"queries vectors"| node_store
node_llm -->|"reads config"| node_settings
node_registry -->|"reads servers"| node_settings

click node_entry "https://github.com/rgnarmadha/chatbot-trial/blob/master/main.py"
click node_cli "https://github.com/rgnarmadha/chatbot-trial/blob/master/cli/interface.py"
click node_graph "https://github.com/rgnarmadha/chatbot-trial/blob/master/agent/graph.py"
click node_state "https://github.com/rgnarmadha/chatbot-trial/blob/master/agent/state.py"
click node_router "https://github.com/rgnarmadha/chatbot-trial/blob/master/agent/nodes/router.py"
click node_prompt "https://github.com/rgnarmadha/chatbot-trial/blob/master/agent/prompts/system.py"
click node_retriever_node "https://github.com/rgnarmadha/chatbot-trial/blob/master/agent/nodes/retriever.py"
click node_tool_caller "https://github.com/rgnarmadha/chatbot-trial/blob/master/agent/nodes/tool_caller.py"
click node_responder "https://github.com/rgnarmadha/chatbot-trial/blob/master/agent/nodes/responder.py"
click node_llm "https://github.com/rgnarmadha/chatbot-trial/blob/master/llm/backend.py"
click node_ingestion "https://github.com/rgnarmadha/chatbot-trial/blob/master/rag/ingestion/pipeline.py"
click node_loaders "https://github.com/rgnarmadha/chatbot-trial/blob/master/rag/ingestion/loaders.py"
click node_chunker "https://github.com/rgnarmadha/chatbot-trial/blob/master/rag/ingestion/chunker.py"
click node_embedder "https://github.com/rgnarmadha/chatbot-trial/blob/master/rag/embeddings.py"
click node_rag_retriever "https://github.com/rgnarmadha/chatbot-trial/blob/master/rag/retriever.py"
click node_store "https://github.com/rgnarmadha/chatbot-trial/blob/master/rag/store.py"
click node_registry "https://github.com/rgnarmadha/chatbot-trial/blob/master/mcp_tools/registry.py"
click node_mcp_client "https://github.com/rgnarmadha/chatbot-trial/blob/master/mcp_tools/client.py"
click node_settings "https://github.com/rgnarmadha/chatbot-trial/blob/master/config/settings.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_entry,node_cli,node_graph,node_state,node_router,node_prompt,node_retriever_node,node_tool_caller,node_responder,node_user toneBlue
class node_ingestion,node_loaders,node_chunker,node_embedder,node_rag_retriever,node_store toneAmber
class node_registry,node_mcp_client,node_mcp_server toneMint
class node_llm,node_settings toneRose
class node_llm_service toneIndigo
```

## Components

### Conversation workflow

- [CLI entry](https://github.com/rgnarmadha/chatbot-trial/blob/master/main.py): `main.py`
- [Chat interface](https://github.com/rgnarmadha/chatbot-trial/blob/master/cli/interface.py): `cli/interface.py`
- [Graph runner](https://github.com/rgnarmadha/chatbot-trial/blob/master/agent/graph.py): `agent/graph.py`
- [Conversation state](https://github.com/rgnarmadha/chatbot-trial/blob/master/agent/state.py): `agent/state.py`
- [Action router](https://github.com/rgnarmadha/chatbot-trial/blob/master/agent/nodes/router.py): `agent/nodes/router.py`
- [System prompts](https://github.com/rgnarmadha/chatbot-trial/blob/master/agent/prompts/system.py): `agent/prompts/system.py`
- [Retrieval node](https://github.com/rgnarmadha/chatbot-trial/blob/master/agent/nodes/retriever.py): `agent/nodes/retriever.py`
- [Tool caller](https://github.com/rgnarmadha/chatbot-trial/blob/master/agent/nodes/tool_caller.py): `agent/nodes/tool_caller.py`
- [Response node](https://github.com/rgnarmadha/chatbot-trial/blob/master/agent/nodes/responder.py): `agent/nodes/responder.py`

### Knowledge base

- [Ingestion pipeline](https://github.com/rgnarmadha/chatbot-trial/blob/master/rag/ingestion/pipeline.py): `rag/ingestion/pipeline.py`
- [Document loaders](https://github.com/rgnarmadha/chatbot-trial/blob/master/rag/ingestion/loaders.py): `rag/ingestion/loaders.py`
- [Document chunker](https://github.com/rgnarmadha/chatbot-trial/blob/master/rag/ingestion/chunker.py): `rag/ingestion/chunker.py`
- [Text embeddings](https://github.com/rgnarmadha/chatbot-trial/blob/master/rag/embeddings.py): `rag/embeddings.py`
- [RAG retriever](https://github.com/rgnarmadha/chatbot-trial/blob/master/rag/retriever.py): `rag/retriever.py`
- [Vector store](https://github.com/rgnarmadha/chatbot-trial/blob/master/rag/store.py): `rag/store.py`

### MCP tools

- [MCP registry](https://github.com/rgnarmadha/chatbot-trial/blob/master/mcp_tools/registry.py): `mcp_tools/registry.py`
- [MCP client](https://github.com/rgnarmadha/chatbot-trial/blob/master/mcp_tools/client.py): `mcp_tools/client.py`

### Runtime services

- [LLM backend](https://github.com/rgnarmadha/chatbot-trial/blob/master/llm/backend.py): `llm/backend.py`
- [Application settings](https://github.com/rgnarmadha/chatbot-trial/blob/master/config/settings.py): `config/settings.py`

### Other components

- **Chat user**
- **LLM service**
- **MCP servers**

## Connections

- Chat user → Chat interface: enters turn (evidence: `README.md`)
- CLI entry → Graph runner: builds graph (evidence: `main.py`)
- CLI entry → Chat interface: starts loop (evidence: `main.py`)
- Chat interface → Graph runner: runs turn (evidence: `cli/interface.py`)
- Graph runner → Action router: dispatches (evidence: `agent/graph.py`)
- Graph runner → Retrieval node: dispatches (evidence: `agent/graph.py`)
- Graph runner → Tool caller: dispatches (evidence: `agent/graph.py`)
- Graph runner → Response node: dispatches (evidence: `agent/graph.py`)
- Graph runner → Conversation state: tracks state (evidence: `agent/graph.py`)
- Action router → LLM backend: requests decision (evidence: `agent/nodes/router.py`)
- Response node → LLM backend: generates answer (evidence: `agent/nodes/responder.py`)
- Action router → System prompts: formats prompt (evidence: `agent/nodes/router.py`)
- Response node → System prompts: uses prompt (evidence: `agent/nodes/responder.py`)
- Retrieval node → RAG retriever: retrieves context (evidence: `agent/nodes/retriever.py`)
- Tool caller → MCP registry: calls tool (evidence: `agent/nodes/tool_caller.py`)
- Graph runner → MCP registry: discovers tools (evidence: `agent/graph.py`)
- MCP registry → MCP client: routes calls (evidence: `mcp_tools/registry.py`)
- MCP client → MCP servers: connects (evidence: `mcp_tools/client.py`)
- Ingestion pipeline → Document loaders: loads documents (evidence: `rag/ingestion/pipeline.py`)
- Ingestion pipeline → Document chunker: chunks documents (evidence: `rag/ingestion/pipeline.py`)
- Ingestion pipeline → Text embeddings: embeds chunks (evidence: `rag/ingestion/pipeline.py`)
- Ingestion pipeline → Vector store: upserts vectors (evidence: `rag/ingestion/pipeline.py`)
- RAG retriever → Text embeddings: embeds query (evidence: `rag/retriever.py`)
- RAG retriever → Vector store: queries vectors (evidence: `rag/retriever.py`)
- LLM backend → Application settings: reads config (evidence: `llm/backend.py`)
- MCP registry → Application settings: reads servers (evidence: `mcp_tools/registry.py`)
