# wtfmadrid/langgraph-chatbot architecture

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

- Interactive diagram: https://gitdiagram.com/wtfmadrid/langgraph-chatbot
- Repository: https://github.com/wtfmadrid/langgraph-chatbot

## Overview

This is a FastAPI conversational AI backend. A client submits a chat turn; the API validates it and delegates to ChatService, which invokes a stateful LangGraph workflow and returns the reply, thread ID, remembered name, and selected specialist. The graph routes to general chat or timekeeping specialists, which can use tools and a configured chat model. It also exposes a health endpoint. Wiring and several module relationships are supported by excerpts and README statements; tool internals and some peripheral behavior were not sampled.

Main entry points: [`src/app/agents/graph.py`](https://github.com/wtfmadrid/langgraph-chatbot/blob/main/src/app/agents/graph.py) (Supervisor Graph), [`src/app/main.py`](https://github.com/wtfmadrid/langgraph-chatbot/blob/main/src/app/main.py) (Application Wiring), [`src/app/api/routers/chat.py`](https://github.com/wtfmadrid/langgraph-chatbot/blob/main/src/app/api/routers/chat.py) (Chat Endpoint), [`src/app/llm/openai_factory.py`](https://github.com/wtfmadrid/langgraph-chatbot/blob/main/src/app/llm/openai_factory.py) (OpenAI Adapter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_chat_route["Chat Endpoint<br/>[chat.py]"]
  node_chat_contract["Chat Schema<br/>[chat.py]"]
  node_health_route["Health Endpoint<br/>[health.py]"]
  node_health_contract["Health Schema<br/>[health.py]"]
  node_dependencies["API Dependencies<br/>[deps.py]"]
end

subgraph group_workflow["Agent Workflow"]
  node_chat_service["Chat Service<br/>[chat_service.py]"]
  node_agent_graph["Supervisor Graph<br/>[graph.py]"]
  node_supervisor["Request Supervisor<br/>[nodes.py]"]
  node_chat_specialist["Chat Specialist<br/>[nodes.py]"]
  node_time_specialist["Timekeeper Specialist<br/>[nodes.py]"]
  node_tools["Specialist Tools<br/>[tools.py]"]
  node_conversation_state["Conversation State<br/>[state.py]"]
  node_memory[("Thread Checkpointer<br/>[checkpointer.py]")]
end

subgraph group_model["Model Access"]
  node_model_port["Chat Model Port<br/>[ports.py]"]
  node_openai_adapter["OpenAI Adapter<br/>[openai_factory.py]"]
end

subgraph group_runtime["Runtime Support"]
  node_settings["Settings<br/>[settings.py]"]
  node_app_wiring["Application Wiring<br/>[main.py]"]
  node_error_handling["Error Handling<br/>[exceptions.py]"]
end

node_client(("API Client"))
node_openai["OpenAI Platform"]

node_client -->|"submits turn"| node_chat_route
node_chat_route -->|"validates with"| node_chat_contract
node_chat_route -->|"requests service"| node_dependencies
node_chat_route -->|"calls"| node_chat_service
node_chat_service -->|"invokes"| node_agent_graph
node_agent_graph -->|"starts with"| node_supervisor
node_supervisor -->|"routes to"| node_chat_specialist
node_supervisor -->|"routes to"| node_time_specialist
node_agent_graph -->|"registers"| node_tools
node_chat_specialist -->|"may invoke"| node_tools
node_time_specialist -->|"may invoke"| node_tools
node_agent_graph -->|"uses"| node_conversation_state
node_agent_graph -->|"compiles with"| node_memory
node_agent_graph -->|"depends on"| node_model_port
node_chat_specialist -->|"generates with"| node_model_port
node_time_specialist -->|"generates with"| node_model_port
node_app_wiring -->|"builds"| node_agent_graph
node_app_wiring -->|"creates"| node_memory
node_app_wiring -->|"creates"| node_openai_adapter
node_openai_adapter -->|"configures from"| node_settings
node_openai_adapter -->|"delegates to"| node_openai
node_openai_adapter -->|"implements"| node_model_port
node_app_wiring -->|"loads"| node_settings
node_client -->|"checks service"| node_health_route
node_health_route -->|"returns"| node_health_contract
node_app_wiring -->|"handles"| node_error_handling
node_chat_service -->|"raises on failure"| node_error_handling

click node_chat_route "https://github.com/wtfmadrid/langgraph-chatbot/blob/main/src/app/api/routers/chat.py"
click node_chat_contract "https://github.com/wtfmadrid/langgraph-chatbot/blob/main/src/app/schemas/chat.py"
click node_health_route "https://github.com/wtfmadrid/langgraph-chatbot/blob/main/src/app/api/routers/health.py"
click node_health_contract "https://github.com/wtfmadrid/langgraph-chatbot/blob/main/src/app/schemas/health.py"
click node_dependencies "https://github.com/wtfmadrid/langgraph-chatbot/blob/main/src/app/api/deps.py"
click node_chat_service "https://github.com/wtfmadrid/langgraph-chatbot/blob/main/src/app/services/chat_service.py"
click node_agent_graph "https://github.com/wtfmadrid/langgraph-chatbot/blob/main/src/app/agents/graph.py"
click node_supervisor "https://github.com/wtfmadrid/langgraph-chatbot/blob/main/src/app/agents/nodes.py"
click node_chat_specialist "https://github.com/wtfmadrid/langgraph-chatbot/blob/main/src/app/agents/nodes.py"
click node_time_specialist "https://github.com/wtfmadrid/langgraph-chatbot/blob/main/src/app/agents/nodes.py"
click node_tools "https://github.com/wtfmadrid/langgraph-chatbot/blob/main/src/app/agents/tools.py"
click node_conversation_state "https://github.com/wtfmadrid/langgraph-chatbot/blob/main/src/app/agents/state.py"
click node_memory "https://github.com/wtfmadrid/langgraph-chatbot/blob/main/src/app/agents/checkpointer.py"
click node_model_port "https://github.com/wtfmadrid/langgraph-chatbot/blob/main/src/app/llm/ports.py"
click node_openai_adapter "https://github.com/wtfmadrid/langgraph-chatbot/blob/main/src/app/llm/openai_factory.py"
click node_settings "https://github.com/wtfmadrid/langgraph-chatbot/blob/main/src/app/core/settings.py"
click node_app_wiring "https://github.com/wtfmadrid/langgraph-chatbot/blob/main/src/app/main.py"
click node_error_handling "https://github.com/wtfmadrid/langgraph-chatbot/blob/main/src/app/core/exceptions.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_route,node_chat_contract,node_health_route,node_health_contract,node_dependencies,node_client toneBlue
class node_chat_service,node_agent_graph,node_supervisor,node_chat_specialist,node_time_specialist,node_tools,node_conversation_state,node_memory toneAmber
class node_model_port,node_openai_adapter toneMint
class node_settings,node_app_wiring,node_error_handling toneRose
class node_openai toneIndigo
```

## Components

### HTTP API

- [Chat Endpoint](https://github.com/wtfmadrid/langgraph-chatbot/blob/main/src/app/api/routers/chat.py): `src/app/api/routers/chat.py`
- [Chat Schema](https://github.com/wtfmadrid/langgraph-chatbot/blob/main/src/app/schemas/chat.py): `src/app/schemas/chat.py`
- [Health Endpoint](https://github.com/wtfmadrid/langgraph-chatbot/blob/main/src/app/api/routers/health.py): `src/app/api/routers/health.py`
- [Health Schema](https://github.com/wtfmadrid/langgraph-chatbot/blob/main/src/app/schemas/health.py): `src/app/schemas/health.py`
- [API Dependencies](https://github.com/wtfmadrid/langgraph-chatbot/blob/main/src/app/api/deps.py): `src/app/api/deps.py`

### Agent Workflow

- [Chat Service](https://github.com/wtfmadrid/langgraph-chatbot/blob/main/src/app/services/chat_service.py): `src/app/services/chat_service.py`
- [Supervisor Graph](https://github.com/wtfmadrid/langgraph-chatbot/blob/main/src/app/agents/graph.py): `src/app/agents/graph.py`
- [Request Supervisor](https://github.com/wtfmadrid/langgraph-chatbot/blob/main/src/app/agents/nodes.py): `src/app/agents/nodes.py`
- [Chat Specialist](https://github.com/wtfmadrid/langgraph-chatbot/blob/main/src/app/agents/nodes.py): `src/app/agents/nodes.py`
- [Timekeeper Specialist](https://github.com/wtfmadrid/langgraph-chatbot/blob/main/src/app/agents/nodes.py): `src/app/agents/nodes.py`
- [Specialist Tools](https://github.com/wtfmadrid/langgraph-chatbot/blob/main/src/app/agents/tools.py): `src/app/agents/tools.py`
- [Conversation State](https://github.com/wtfmadrid/langgraph-chatbot/blob/main/src/app/agents/state.py): `src/app/agents/state.py`
- [Thread Checkpointer](https://github.com/wtfmadrid/langgraph-chatbot/blob/main/src/app/agents/checkpointer.py): `src/app/agents/checkpointer.py`

### Model Access

- [Chat Model Port](https://github.com/wtfmadrid/langgraph-chatbot/blob/main/src/app/llm/ports.py): `src/app/llm/ports.py`
- [OpenAI Adapter](https://github.com/wtfmadrid/langgraph-chatbot/blob/main/src/app/llm/openai_factory.py): `src/app/llm/openai_factory.py`

### Runtime Support

- [Settings](https://github.com/wtfmadrid/langgraph-chatbot/blob/main/src/app/core/settings.py): `src/app/core/settings.py`
- [Application Wiring](https://github.com/wtfmadrid/langgraph-chatbot/blob/main/src/app/main.py): `src/app/main.py`
- [Error Handling](https://github.com/wtfmadrid/langgraph-chatbot/blob/main/src/app/core/exceptions.py): `src/app/core/exceptions.py`

### Other components

- **API Client**
- **OpenAI Platform**

## Connections

- API Client → Chat Endpoint: submits turn (evidence: `README.md`)
- Chat Endpoint → Chat Schema: validates with (evidence: `src/app/api/routers/chat.py`)
- Chat Endpoint → API Dependencies: requests service (evidence: `src/app/api/routers/chat.py`)
- Chat Endpoint → Chat Service: calls (evidence: `src/app/api/routers/chat.py`)
- Chat Service → Supervisor Graph: invokes (evidence: `README.md`)
- Supervisor Graph → Request Supervisor: starts with (evidence: `src/app/agents/graph.py`)
- Request Supervisor → Chat Specialist: routes to (evidence: `README.md`)
- Request Supervisor → Timekeeper Specialist: routes to (evidence: `README.md`)
- Supervisor Graph → Specialist Tools: registers (evidence: `src/app/agents/graph.py`)
- Chat Specialist → Specialist Tools: may invoke (evidence: `README.md`)
- Timekeeper Specialist → Specialist Tools: may invoke (evidence: `README.md`)
- Supervisor Graph → Conversation State: uses (evidence: `src/app/agents/graph.py`)
- Supervisor Graph → Thread Checkpointer: compiles with (evidence: `src/app/agents/graph.py`)
- Supervisor Graph → Chat Model Port: depends on (evidence: `src/app/agents/graph.py`)
- Chat Specialist → Chat Model Port: generates with (evidence: `README.md`)
- Timekeeper Specialist → Chat Model Port: generates with (evidence: `README.md`)
- Application Wiring → Supervisor Graph: builds (evidence: `src/app/main.py`)
- Application Wiring → Thread Checkpointer: creates (evidence: `src/app/main.py`)
- Application Wiring → OpenAI Adapter: creates (evidence: `src/app/main.py`)
- OpenAI Adapter → Settings: configures from (evidence: `src/app/llm/openai_factory.py`)
- OpenAI Adapter → OpenAI Platform: delegates to (evidence: `src/app/llm/openai_factory.py`)
- OpenAI Adapter → Chat Model Port: implements (evidence: `src/app/llm/ports.py`)
- Application Wiring → Settings: loads (evidence: `src/app/main.py`)
- API Client → Health Endpoint: checks service (evidence: `README.md`)
- Health Endpoint → Health Schema: returns (evidence: `src/app/api/routers/health.py`)
- Application Wiring → Error Handling: handles (evidence: `src/app/main.py`)
- Chat Service → Error Handling: raises on failure (evidence: `src/app/services/chat_service.py`)
