# yevsel/customer_support_agent_yt architecture

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

- Interactive diagram: https://gitdiagram.com/yevsel/customer_support_agent_yt
- Repository: https://github.com/yevsel/customer_support_agent_yt

## Overview

This LangGraph customer-support agent routes a customer message to FAQ, order, refund, or escalation handling, then returns a resolution or pauses for human approval. Its main graph coordinates the stages; an order sub-agent loops through tools, while FAQ answers use retrieved policy context. The README documents optional Postgres checkpointing and the RAG ingestion capability; the sampled graph code shows checkpoint setup commented out, and the ingestion code’s database write is also commented out, so those links are marked optional or documented rather than asserted as active.

Main entry points: [`graphs.py`](https://github.com/yevsel/customer_support_agent_yt/blob/main/graphs.py) (Support Graph), [`nodes.py`](https://github.com/yevsel/customer_support_agent_yt/blob/main/nodes.py) (Support Nodes), [`order_agent.py`](https://github.com/yevsel/customer_support_agent_yt/blob/main/order_agent.py) (Order Sub-agent), [`rag/retrieval.py`](https://github.com/yevsel/customer_support_agent_yt/blob/main/rag/retrieval.py) (Policy Retrieval)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Support Workflow"]
  node_main_graph["Support Graph<br/>[graphs.py]"]
  node_state["Conversation State<br/>[state.py]"]
  node_intent_router["Intent Router<br/>[edges.py]"]
  node_support_nodes["Support Nodes<br/>[nodes.py]"]
  node_escalation["Human Escalation<br/>[nodes.py]"]
  node_close["Turn Resolution<br/>[nodes.py]"]
end

subgraph group_knowledge["Policy Knowledge"]
  node_faq["FAQ Policy<br/>[faq.txt]"]
  node_ingestion["FAQ Ingestion<br/>[ingestion.py]"]
  node_retrieval["Policy Retrieval<br/>[retrieval.py]"]
  node_vector_store[("Chroma Store<br/>[chroma.sqlite3]")]
end

subgraph group_orders["Order Handling"]
  node_order_agent["Order Sub-agent<br/>[order_agent.py]"]
  node_order_tools["Order Tools<br/>[order_agent.py]"]
  node_orders_data[("Mock Orders")]
end

subgraph group_refunds["Refund and Review"]
  node_refund_review["Refund Review<br/>[nodes.py]"]
  node_refund_process["Issue Refund<br/>[nodes.py]"]
end

node_customer(("Customer"))
node_llm(("OpenAI Model"))
node_human_approver(("Human Approver"))
node_postgres[("Postgres Checkpointer")]

node_customer -->|"sends message"| node_main_graph
node_main_graph -->|"routes through"| node_intent_router
node_main_graph -->|"registers nodes"| node_support_nodes
node_main_graph -->|"uses state"| node_state
node_main_graph -->|"invokes branch"| node_order_agent
node_intent_router -->|"selects intent"| node_support_nodes
node_support_nodes -->|"classifies and answers"| node_llm
node_support_nodes -->|"searches policy"| node_retrieval
node_ingestion -->|"chunks document"| node_faq
node_ingestion -.->|"stores embeddings"| node_vector_store
node_retrieval -->|"searches"| node_vector_store
node_order_agent -->|"dispatches tools"| node_order_tools
node_order_agent -->|"invokes model"| node_llm
node_order_tools -->|"looks up orders"| node_orders_data
node_order_tools -->|"searches policy"| node_retrieval
node_main_graph -->|"routes refunds"| node_refund_review
node_refund_review -->|"checks order"| node_orders_data
node_refund_review -->|"requests approval"| node_human_approver
node_main_graph -->|"routes approved"| node_refund_process
node_main_graph -->|"routes completion"| node_close
node_main_graph -->|"routes escalation"| node_escalation
node_main_graph -.->|"checkpoints state"| node_postgres

click node_main_graph "https://github.com/yevsel/customer_support_agent_yt/blob/main/graphs.py"
click node_state "https://github.com/yevsel/customer_support_agent_yt/blob/main/state.py"
click node_intent_router "https://github.com/yevsel/customer_support_agent_yt/blob/main/edges.py"
click node_support_nodes "https://github.com/yevsel/customer_support_agent_yt/blob/main/nodes.py"
click node_escalation "https://github.com/yevsel/customer_support_agent_yt/blob/main/nodes.py"
click node_close "https://github.com/yevsel/customer_support_agent_yt/blob/main/nodes.py"
click node_faq "https://github.com/yevsel/customer_support_agent_yt/blob/main/rag/company_data/faq.txt"
click node_ingestion "https://github.com/yevsel/customer_support_agent_yt/blob/main/rag/ingestion.py"
click node_retrieval "https://github.com/yevsel/customer_support_agent_yt/blob/main/rag/retrieval.py"
click node_vector_store "https://github.com/yevsel/customer_support_agent_yt/blob/main/rag/chroma.sqlite3"
click node_order_agent "https://github.com/yevsel/customer_support_agent_yt/blob/main/order_agent.py"
click node_order_tools "https://github.com/yevsel/customer_support_agent_yt/blob/main/order_agent.py"
click node_orders_data "https://github.com/yevsel/customer_support_agent_yt/blob/main/orders_mock_data.py"
click node_refund_review "https://github.com/yevsel/customer_support_agent_yt/blob/main/nodes.py"
click node_refund_process "https://github.com/yevsel/customer_support_agent_yt/blob/main/nodes.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_main_graph,node_state,node_intent_router,node_support_nodes,node_escalation,node_close toneBlue
class node_faq,node_ingestion,node_retrieval,node_vector_store,node_postgres toneAmber
class node_order_agent,node_order_tools,node_orders_data toneMint
class node_refund_review,node_refund_process toneRose
class node_customer,node_llm,node_human_approver toneIndigo
```

## Components

### Support Workflow

- [Support Graph](https://github.com/yevsel/customer_support_agent_yt/blob/main/graphs.py): `graphs.py`
- [Conversation State](https://github.com/yevsel/customer_support_agent_yt/blob/main/state.py): `state.py`
- [Intent Router](https://github.com/yevsel/customer_support_agent_yt/blob/main/edges.py): `edges.py`
- [Support Nodes](https://github.com/yevsel/customer_support_agent_yt/blob/main/nodes.py): `nodes.py`
- [Human Escalation](https://github.com/yevsel/customer_support_agent_yt/blob/main/nodes.py): `nodes.py`
- [Turn Resolution](https://github.com/yevsel/customer_support_agent_yt/blob/main/nodes.py): `nodes.py`

### Policy Knowledge

- [FAQ Policy](https://github.com/yevsel/customer_support_agent_yt/blob/main/rag/company_data/faq.txt): `rag/company_data/faq.txt`
- [FAQ Ingestion](https://github.com/yevsel/customer_support_agent_yt/blob/main/rag/ingestion.py): `rag/ingestion.py`
- [Policy Retrieval](https://github.com/yevsel/customer_support_agent_yt/blob/main/rag/retrieval.py): `rag/retrieval.py`
- [Chroma Store](https://github.com/yevsel/customer_support_agent_yt/blob/main/rag/chroma.sqlite3): `rag/chroma.sqlite3`

### Order Handling

- [Order Sub-agent](https://github.com/yevsel/customer_support_agent_yt/blob/main/order_agent.py): `order_agent.py`
- [Order Tools](https://github.com/yevsel/customer_support_agent_yt/blob/main/order_agent.py): `order_agent.py`
- [Mock Orders](https://github.com/yevsel/customer_support_agent_yt/blob/main/orders_mock_data.py): `orders_mock_data.py`

### Refund and Review

- [Refund Review](https://github.com/yevsel/customer_support_agent_yt/blob/main/nodes.py): `nodes.py`
- [Issue Refund](https://github.com/yevsel/customer_support_agent_yt/blob/main/nodes.py): `nodes.py`

### Other components

- **Customer**
- **OpenAI Model**
- **Human Approver**
- **Postgres Checkpointer**

## Connections

- Customer → Support Graph: sends message (evidence: `README.md`)
- Support Graph → Intent Router: routes through (evidence: `graphs.py`)
- Support Graph → Support Nodes: registers nodes (evidence: `graphs.py`)
- Support Graph → Conversation State: uses state (evidence: `graphs.py`)
- Support Graph → Order Sub-agent: invokes branch (evidence: `graphs.py`)
- Intent Router → Support Nodes: selects intent (evidence: `graphs.py`)
- Support Nodes → OpenAI Model: classifies and answers (evidence: `nodes.py`)
- Support Nodes → Policy Retrieval: searches policy (evidence: `nodes.py`)
- FAQ Ingestion → FAQ Policy: chunks document (evidence: `rag/ingestion.py`)
- FAQ Ingestion → Chroma Store: stores embeddings (evidence: `README.md`)
- Policy Retrieval → Chroma Store: searches (evidence: `rag/retrieval.py`)
- Order Sub-agent → Order Tools: dispatches tools (evidence: `order_agent.py`)
- Order Sub-agent → OpenAI Model: invokes model (evidence: `order_agent.py`)
- Order Tools → Mock Orders: looks up orders (evidence: `order_agent.py`)
- Order Tools → Policy Retrieval: searches policy (evidence: `order_agent.py`)
- Support Graph → Refund Review: routes refunds (evidence: `graphs.py`)
- Refund Review → Mock Orders: checks order (evidence: `nodes.py`)
- Refund Review → Human Approver: requests approval (evidence: `README.md`)
- Support Graph → Issue Refund: routes approved (evidence: `graphs.py`)
- Support Graph → Turn Resolution: routes completion (evidence: `graphs.py`)
- Support Graph → Human Escalation: routes escalation (evidence: `graphs.py`)
- Support Graph → Postgres Checkpointer: checkpoints state (evidence: `README.md`)
