How orion-ai-engineering/production-grade-python-langchain-langgraph works
This repository is a production-shaped support-agent service, alongside separate runnable chapter examples. Its main workflow authenticates a caller, checks thread ownership, invokes a stateful LangGraph workflow, and returns a response or approval request. The workflow classifies the ticket, retrieves customer context and knowledge, drafts and checks a response, and may pause for approval before executing a refund. The graph covers documented major service capabilities; some startup wiring is evidenced by the source index, while unsampled implementation details are omitted.
Main entry points: graph.py Graph runtime · routes.py FastAPI routes · refunds.py Refund service · model.py Support model
Components 26
API and service
- FastAPI routes
src/support_agent/api/routes.py - Authentication
src/support_agent/core/security.py - Telemetry
src/support_agent/core/telemetry.py
Agent workflow
- Graph runtime
src/support_agent/agent/graph.py - Ticket loading
src/support_agent/agent/nodes.py - Ticket classification
src/support_agent/agent/nodes.py - Customer context
src/support_agent/agent/nodes.py - Knowledge retrieval
src/support_agent/agent/nodes.py - Response drafting
src/support_agent/agent/nodes.py - Policy checks
src/support_agent/agent/nodes.py - Human approval
src/support_agent/agent/nodes.py - Quality check
src/support_agent/agent/nodes.py - Draft revision
src/support_agent/agent/nodes.py - Response finalization
src/support_agent/agent/nodes.py
Integrations
- CRM client
src/support_agent/clients/crm.py - Knowledge base
src/support_agent/services/knowledge.py - Support model
src/support_agent/agent/model.py - Refund execution
src/support_agent/agent/nodes.py - Refund service
src/support_agent/services/refunds.py - Billing client
src/support_agent/clients/billing.py
Persistence and runtime
- Thread access
src/support_agent/db/repositories.py - Refund repository
src/support_agent/db/repositories.py - Application database
src/support_agent/db/models.py - Settings
src/support_agent/core/config.py
Other components
- API caller
- OpenAI model service
Connections 28
- API caller → FastAPI routes: submits request
README.md - FastAPI routes → Authentication: authenticates via
src/support_agent/api/routes.py - FastAPI routes → Thread access: checks ownership
src/support_agent/api/routes.py - FastAPI routes → Graph runtime: invokes workflow
src/support_agent/api/routes.py - Graph runtime → Ticket loading: dispatches
src/support_agent/agent/graph.py - Graph runtime → Ticket classification: dispatches
src/support_agent/agent/graph.py - Graph runtime → Customer context: dispatches
src/support_agent/agent/graph.py - Graph runtime → Knowledge retrieval: dispatches
src/support_agent/agent/graph.py - Graph runtime → Response drafting: dispatches
src/support_agent/agent/graph.py - Graph runtime → Policy checks: dispatches
src/support_agent/agent/graph.py - Graph runtime → Human approval: dispatches
src/support_agent/agent/graph.py - Graph runtime → Quality check: dispatches
src/support_agent/agent/graph.py - Graph runtime → Draft revision: dispatches
src/support_agent/agent/graph.py - Graph runtime → Response finalization: dispatches
src/support_agent/agent/graph.py - Graph runtime → Refund execution: dispatches
src/support_agent/agent/graph.py - Customer context → CRM client: loads context
src/support_agent/agent/nodes.py - Knowledge retrieval → Knowledge base: searches
src/support_agent/agent/nodes.py - Response drafting → Support model: drafts with
src/support_agent/agent/nodes.py - Quality check → Support model: scores with
src/support_agent/agent/nodes.py - Refund execution → Refund service: executes via
src/support_agent/agent/nodes.py - Refund service → Billing client: checks invoice
src/support_agent/services/refunds.py - Refund service → Refund repository: records once
src/support_agent/services/refunds.py - Refund repository → Application database: stores execution
src/support_agent/db/repositories.py - Settings → FastAPI routes: configures service
src/support_agent/main.py - Settings → Graph runtime: configures graph
src/support_agent/agent/graph.py - Support model → OpenAI model service: calls when enabled
README.md - API caller → FastAPI routes: resumes approval
README.md - FastAPI routes → Telemetry: configures optionally
src/support_agent/main.py