# orion-ai-engineering/production-grade-python-langchain-langgraph architecture

> Architecture diagram of the GitHub repository orion-ai-engineering/production-grade-python-langchain-langgraph, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/orion-ai-engineering/production-grade-python-langchain-langgraph
- Repository: https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph

## Overview

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: [`src/support_agent/agent/graph.py`](https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/agent/graph.py) (Graph runtime), [`src/support_agent/api/routes.py`](https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/api/routes.py) (FastAPI routes), [`src/support_agent/services/refunds.py`](https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/services/refunds.py) (Refund service), [`src/support_agent/agent/model.py`](https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/agent/model.py) (Support model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_service["API and service"]
  node_api["FastAPI routes<br/>[routes.py]"]
  node_auth["Authentication<br/>[security.py]"]
  node_observability["Telemetry<br/>[telemetry.py]"]
end

subgraph group_workflow["Agent workflow"]
  node_graph["Graph runtime<br/>[graph.py]"]
  node_ticket_load["Ticket loading<br/>[nodes.py]"]
  node_classification["Ticket classification<br/>[nodes.py]"]
  node_customer_context["Customer context<br/>[nodes.py]"]
  node_retrieval["Knowledge retrieval<br/>[nodes.py]"]
  node_drafting["Response drafting<br/>[nodes.py]"]
  node_policy["Policy checks<br/>[nodes.py]"]
  node_approval["Human approval<br/>[nodes.py]"]
  node_quality["Quality check<br/>[nodes.py]"]
  node_revision["Draft revision<br/>[nodes.py]"]
  node_finalize["Response finalization<br/>[nodes.py]"]
end

subgraph group_integrations["Integrations"]
  node_crm["CRM client<br/>[crm.py]"]
  node_knowledge["Knowledge base<br/>[knowledge.py]"]
  node_model["Support model<br/>[model.py]"]
  node_refund_execution["Refund execution<br/>[nodes.py]"]
  node_refund_service["Refund service<br/>[refunds.py]"]
  node_billing["Billing client<br/>[billing.py]"]
end

subgraph group_persistence["Persistence and runtime"]
  node_thread_access["Thread access<br/>[repositories.py]"]
  node_refund_repository["Refund repository<br/>[repositories.py]"]
  node_database[("Application database<br/>[models.py]")]
  node_configuration["Settings<br/>[config.py]"]
end

node_caller(("API caller"))
node_openai["OpenAI model service"]

node_caller -->|"submits request"| node_api
node_api -->|"authenticates via"| node_auth
node_api -->|"checks ownership"| node_thread_access
node_api -->|"invokes workflow"| node_graph
node_graph -->|"dispatches"| node_ticket_load
node_graph -->|"dispatches"| node_classification
node_graph -->|"dispatches"| node_customer_context
node_graph -->|"dispatches"| node_retrieval
node_graph -->|"dispatches"| node_drafting
node_graph -->|"dispatches"| node_policy
node_graph -->|"dispatches"| node_approval
node_graph -->|"dispatches"| node_quality
node_graph -->|"dispatches"| node_revision
node_graph -->|"dispatches"| node_finalize
node_graph -->|"dispatches"| node_refund_execution
node_customer_context -->|"loads context"| node_crm
node_retrieval -->|"searches"| node_knowledge
node_drafting -->|"drafts with"| node_model
node_quality -->|"scores with"| node_model
node_refund_execution -->|"executes via"| node_refund_service
node_refund_service -->|"checks invoice"| node_billing
node_refund_service -->|"records once"| node_refund_repository
node_refund_repository -->|"stores execution"| node_database
node_configuration -->|"configures service"| node_api
node_configuration -->|"configures graph"| node_graph
node_model -.->|"calls when enabled"| node_openai
node_caller -->|"resumes approval"| node_api
node_api -.->|"configures optionally"| node_observability

click node_api "https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/api/routes.py"
click node_auth "https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/core/security.py"
click node_thread_access "https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/db/repositories.py"
click node_graph "https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/agent/graph.py"
click node_ticket_load "https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/agent/nodes.py"
click node_classification "https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/agent/nodes.py"
click node_customer_context "https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/agent/nodes.py"
click node_crm "https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/clients/crm.py"
click node_retrieval "https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/agent/nodes.py"
click node_knowledge "https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/services/knowledge.py"
click node_drafting "https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/agent/nodes.py"
click node_model "https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/agent/model.py"
click node_policy "https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/agent/nodes.py"
click node_approval "https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/agent/nodes.py"
click node_quality "https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/agent/nodes.py"
click node_revision "https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/agent/nodes.py"
click node_finalize "https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/agent/nodes.py"
click node_refund_execution "https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/agent/nodes.py"
click node_refund_service "https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/services/refunds.py"
click node_billing "https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/clients/billing.py"
click node_refund_repository "https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/db/repositories.py"
click node_database "https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/db/models.py"
click node_configuration "https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/core/config.py"
click node_observability "https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/core/telemetry.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_api,node_auth,node_observability toneBlue
class node_graph,node_ticket_load,node_classification,node_customer_context,node_retrieval,node_drafting,node_policy,node_approval,node_quality,node_revision,node_finalize toneAmber
class node_crm,node_knowledge,node_model,node_refund_execution,node_refund_service,node_billing,node_caller toneMint
class node_thread_access,node_refund_repository,node_database,node_configuration toneRose
class node_openai toneIndigo
```

## Components

### API and service

- [FastAPI routes](https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/api/routes.py): `src/support_agent/api/routes.py`
- [Authentication](https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/core/security.py): `src/support_agent/core/security.py`
- [Telemetry](https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/core/telemetry.py): `src/support_agent/core/telemetry.py`

### Agent workflow

- [Graph runtime](https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/agent/graph.py): `src/support_agent/agent/graph.py`
- [Ticket loading](https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/agent/nodes.py): `src/support_agent/agent/nodes.py`
- [Ticket classification](https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/agent/nodes.py): `src/support_agent/agent/nodes.py`
- [Customer context](https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/agent/nodes.py): `src/support_agent/agent/nodes.py`
- [Knowledge retrieval](https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/agent/nodes.py): `src/support_agent/agent/nodes.py`
- [Response drafting](https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/agent/nodes.py): `src/support_agent/agent/nodes.py`
- [Policy checks](https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/agent/nodes.py): `src/support_agent/agent/nodes.py`
- [Human approval](https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/agent/nodes.py): `src/support_agent/agent/nodes.py`
- [Quality check](https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/agent/nodes.py): `src/support_agent/agent/nodes.py`
- [Draft revision](https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/agent/nodes.py): `src/support_agent/agent/nodes.py`
- [Response finalization](https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/agent/nodes.py): `src/support_agent/agent/nodes.py`

### Integrations

- [CRM client](https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/clients/crm.py): `src/support_agent/clients/crm.py`
- [Knowledge base](https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/services/knowledge.py): `src/support_agent/services/knowledge.py`
- [Support model](https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/agent/model.py): `src/support_agent/agent/model.py`
- [Refund execution](https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/agent/nodes.py): `src/support_agent/agent/nodes.py`
- [Refund service](https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/services/refunds.py): `src/support_agent/services/refunds.py`
- [Billing client](https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/clients/billing.py): `src/support_agent/clients/billing.py`

### Persistence and runtime

- [Thread access](https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/db/repositories.py): `src/support_agent/db/repositories.py`
- [Refund repository](https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/db/repositories.py): `src/support_agent/db/repositories.py`
- [Application database](https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/db/models.py): `src/support_agent/db/models.py`
- [Settings](https://github.com/orion-ai-engineering/production-grade-python-langchain-langgraph/blob/main/src/support_agent/core/config.py): `src/support_agent/core/config.py`

### Other components

- **API caller**
- **OpenAI model service**

## Connections

- API caller → FastAPI routes: submits request (evidence: `README.md`)
- FastAPI routes → Authentication: authenticates via (evidence: `src/support_agent/api/routes.py`)
- FastAPI routes → Thread access: checks ownership (evidence: `src/support_agent/api/routes.py`)
- FastAPI routes → Graph runtime: invokes workflow (evidence: `src/support_agent/api/routes.py`)
- Graph runtime → Ticket loading: dispatches (evidence: `src/support_agent/agent/graph.py`)
- Graph runtime → Ticket classification: dispatches (evidence: `src/support_agent/agent/graph.py`)
- Graph runtime → Customer context: dispatches (evidence: `src/support_agent/agent/graph.py`)
- Graph runtime → Knowledge retrieval: dispatches (evidence: `src/support_agent/agent/graph.py`)
- Graph runtime → Response drafting: dispatches (evidence: `src/support_agent/agent/graph.py`)
- Graph runtime → Policy checks: dispatches (evidence: `src/support_agent/agent/graph.py`)
- Graph runtime → Human approval: dispatches (evidence: `src/support_agent/agent/graph.py`)
- Graph runtime → Quality check: dispatches (evidence: `src/support_agent/agent/graph.py`)
- Graph runtime → Draft revision: dispatches (evidence: `src/support_agent/agent/graph.py`)
- Graph runtime → Response finalization: dispatches (evidence: `src/support_agent/agent/graph.py`)
- Graph runtime → Refund execution: dispatches (evidence: `src/support_agent/agent/graph.py`)
- Customer context → CRM client: loads context (evidence: `src/support_agent/agent/nodes.py`)
- Knowledge retrieval → Knowledge base: searches (evidence: `src/support_agent/agent/nodes.py`)
- Response drafting → Support model: drafts with (evidence: `src/support_agent/agent/nodes.py`)
- Quality check → Support model: scores with (evidence: `src/support_agent/agent/nodes.py`)
- Refund execution → Refund service: executes via (evidence: `src/support_agent/agent/nodes.py`)
- Refund service → Billing client: checks invoice (evidence: `src/support_agent/services/refunds.py`)
- Refund service → Refund repository: records once (evidence: `src/support_agent/services/refunds.py`)
- Refund repository → Application database: stores execution (evidence: `src/support_agent/db/repositories.py`)
- Settings → FastAPI routes: configures service (evidence: `src/support_agent/main.py`)
- Settings → Graph runtime: configures graph (evidence: `src/support_agent/agent/graph.py`)
- Support model → OpenAI model service: calls when enabled (evidence: `README.md`)
- API caller → FastAPI routes: resumes approval (evidence: `README.md`)
- FastAPI routes → Telemetry: configures optionally (evidence: `src/support_agent/main.py`)
