How emarco177/langgraph-customer-support works
Project type and purpose
• This is a backend-focused AI-driven “customer support control flow” service built in Python/Flask.
• It orchestrates a multi-step conversation (“Human-in-the-Loop”), persists intermediate state in SQLite, and invokes LLMs via LangGraph/LangChain/MistralAI.
File structure
• app.py: Flask entry point / HTTP API.
• db/profile.json & SQLite files under db/: persistent store for conversation checkpoints.
• support_agent/ package:
• consts.py: global constants/config.
• graph.py: builds and wires the LangGraph control-flow graph.
• state.py: graph-execution state management (persistence hooks).
• nodes/: discrete steps in the flow (e.g., verify_information, assistant_node, safe_agent).
• tools/: safe utility wrappers for external LLM tool calls.
• static/: assets (logo, docs).
• pyproject.toml: dependency management (Flask, LangGraph, LangChain, MistralAI SDK).
Extract additional insights from the README
• Human-in-Loop feature: the graph waits for user input until all required fields are gathered.
• Persistent Storage: after each node, the state.py module checkpoints the graph to SQLite.
• Execution ENV: Flask server uses environment variables for API keys and tracing.
Components
a. Client
• HTTP client (browser or CLI) that calls the Flask API endpoints.
b. Flask Server (app.py)
• Entry point exposing /support or similar endpoints.
• Parses requests, dispatches to Graph Engine.
c. Graph Engine (support_agent/graph.py)
• Orchestrates nodes in a directed control-flow graph.
d. Node Modules (support_agent/nodes)
• verify_information: collects and validates user data.
• safe_agent: enforces safety checks.
• assistant_node: formulates LLM responses.
• …any custom steps.
e. Tools Layer (support_agent/tools)
• safe_tools: wrappers around LangChain / MistralAI calls.
f. State Persistence (support_agent/state.py + SQLite)
• After each node execution, serialize the graph state to SQLite.
g. External Services
• LangChain / MistralAI endpoints (LLM inference).
• Tracing & telemetry (if LANGCHAIN_TRACING_V2 is enabled).
Relationships and data flow
• Client → Flask API (HTTP)
• Flask API → Graph Engine
• Graph Engine → Node Modules
• Node Modules → Tools Layer
• Tools Layer → External LLM APIs → Return response
• After each Node execution → State Persistence → SQLite
• At any point, Graph Engine reads from SQLite to resume
Architectural patterns & design principles
• Modular pipeline / directed graph pattern (LangGraph).
• Separation of concerns: API layer, graph orchestration, node logic, external tool integration, persistence.
• Human-in-the-Loop flow: nodes pause for user input.
• Checkpointing: event-sourcing style state persistence.
• Blue for internal services,
• Green for persistence,
• Orange for external dependencies.