How wtfmadrid/langgraph-chatbot works
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: graph.py Supervisor Graph · main.py Application Wiring · chat.py Chat Endpoint · openai_factory.py OpenAI Adapter
Components 20
HTTP API
- Chat Endpoint
src/app/api/routers/chat.py - Chat Schema
src/app/schemas/chat.py - Health Endpoint
src/app/api/routers/health.py - Health Schema
src/app/schemas/health.py - API Dependencies
src/app/api/deps.py
Agent Workflow
- Chat Service
src/app/services/chat_service.py - Supervisor Graph
src/app/agents/graph.py - Request Supervisor
src/app/agents/nodes.py - Chat Specialist
src/app/agents/nodes.py - Timekeeper Specialist
src/app/agents/nodes.py - Specialist Tools
src/app/agents/tools.py - Conversation State
src/app/agents/state.py - Thread Checkpointer
src/app/agents/checkpointer.py
Model Access
- Chat Model Port
src/app/llm/ports.py - OpenAI Adapter
src/app/llm/openai_factory.py
Runtime Support
- Settings
src/app/core/settings.py - Application Wiring
src/app/main.py - Error Handling
src/app/core/exceptions.py
Other components
- API Client
- OpenAI Platform
Connections 27
- API Client → Chat Endpoint: submits turn
README.md - Chat Endpoint → Chat Schema: validates with
src/app/api/routers/chat.py - Chat Endpoint → API Dependencies: requests service
src/app/api/routers/chat.py - Chat Endpoint → Chat Service: calls
src/app/api/routers/chat.py - Chat Service → Supervisor Graph: invokes
README.md - Supervisor Graph → Request Supervisor: starts with
src/app/agents/graph.py - Request Supervisor → Chat Specialist: routes to
README.md - Request Supervisor → Timekeeper Specialist: routes to
README.md - Supervisor Graph → Specialist Tools: registers
src/app/agents/graph.py - Chat Specialist → Specialist Tools: may invoke
README.md - Timekeeper Specialist → Specialist Tools: may invoke
README.md - Supervisor Graph → Conversation State: uses
src/app/agents/graph.py - Supervisor Graph → Thread Checkpointer: compiles with
src/app/agents/graph.py - Supervisor Graph → Chat Model Port: depends on
src/app/agents/graph.py - Chat Specialist → Chat Model Port: generates with
README.md - Timekeeper Specialist → Chat Model Port: generates with
README.md - Application Wiring → Supervisor Graph: builds
src/app/main.py - Application Wiring → Thread Checkpointer: creates
src/app/main.py - Application Wiring → OpenAI Adapter: creates
src/app/main.py - OpenAI Adapter → Settings: configures from
src/app/llm/openai_factory.py - OpenAI Adapter → OpenAI Platform: delegates to
src/app/llm/openai_factory.py - OpenAI Adapter → Chat Model Port: implements
src/app/llm/ports.py - Application Wiring → Settings: loads
src/app/main.py - API Client → Health Endpoint: checks service
README.md - Health Endpoint → Health Schema: returns
src/app/api/routers/health.py - Application Wiring → Error Handling: handles
src/app/main.py - Chat Service → Error Handling: raises on failure
src/app/services/chat_service.py