# sumaylen/ai-support-ticket-agent architecture

> Architecture diagram of the GitHub repository sumaylen/ai-support-ticket-agent, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sumaylen/ai-support-ticket-agent
- Repository: https://github.com/sumaylen/ai-support-ticket-agent

## Overview

This is a work-in-progress AI support-ticket agent. A ticket enters the LangGraph workflow, passes prompt-injection checks and classification, may trigger order/account lookups, retrieves policy context, and receives a fact-checked draft or escalation. The graph also preserves the policy knowledge base, database-backed lookup tools, logging, and evaluation capabilities. Source excerpts show several direct calls; README workflow documentation supports the broader stages. The policy-ingestion relationship and unsampled workflow details are not fully visible, so those links are omitted or marked unverified.

Main entry points: [`src/graph.py`](https://github.com/sumaylen/ai-support-ticket-agent/blob/main/src/graph.py) (Ticket orchestration), [`src/retrieval.py`](https://github.com/sumaylen/ai-support-ticket-agent/blob/main/src/retrieval.py) (Policy retrieval), [`src/llm_client.py`](https://github.com/sumaylen/ai-support-ticket-agent/blob/main/src/llm_client.py) (LLM backend), [`src/respond.py`](https://github.com/sumaylen/ai-support-ticket-agent/blob/main/src/respond.py) (Draft and verify)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Ticket workflow"]
  node_workflow["Ticket orchestration<br/>[graph.py]"]
  node_guards["Prompt guards<br/>[guardrails.py]"]
  node_classifier["Category and urgency<br/>[classify.py]"]
  node_lookup_agent["Lookup agent<br/>[agent.py]"]
  node_response["Draft and verify<br/>[respond.py]"]
  node_escalation["Escalation decision<br/>[escalation.py]"]
end

subgraph group_knowledge["Knowledge and data"]
  node_retrieval["Policy retrieval<br/>[retrieval.py]"]
  node_policies["Support policies"]
  node_policy_ingest["Knowledge-base builder"]
  node_lookup_tools["Order and account tools<br/>[tools.py]"]
  node_company_db[("Company database<br/>[company.db]")]
end

subgraph group_models["Model services"]
  node_llm["LLM backend<br/>[llm_client.py]"]
  node_dataset["Training dataset split<br/>[dataset.py]"]
end

subgraph group_operations["Safety and evaluation"]
  node_ticket_logs["JSON event logs<br/>[JSON_logger.py]"]
  node_retrieval_eval["Retrieval evaluation"]
  node_verifier_eval["Verifier evaluation"]
end

node_customer(("Customer"))

node_customer -->|"submits ticket"| node_workflow
node_workflow -->|"checks input"| node_guards
node_workflow -->|"classifies ticket"| node_classifier
node_workflow -->|"dispatches lookup"| node_lookup_agent
node_workflow -->|"retrieves context"| node_retrieval
node_workflow -->|"creates draft"| node_response
node_workflow -->|"checks escalation"| node_escalation
node_workflow -->|"records outcome"| node_ticket_logs
node_guards -->|"checks message"| node_llm
node_guards -->|"logs flags"| node_ticket_logs
node_classifier -->|"classifies"| node_llm
node_classifier -->|"loads categories"| node_dataset
node_lookup_agent -->|"requests tool calls"| node_llm
node_lookup_agent -->|"dispatches tools"| node_lookup_tools
node_lookup_tools -->|"queries"| node_company_db
node_response -->|"drafts and verifies"| node_llm
node_response -->|"logs failures"| node_ticket_logs
node_retrieval -->|"queries policy store"| node_llm
node_retrieval_eval -->|"evaluates results"| node_retrieval
node_verifier_eval -->|"uses retrieved context"| node_retrieval
node_verifier_eval -->|"evaluates verification"| node_response
node_policies -.->|"supplies policy text"| node_policy_ingest
node_policy_ingest -->|"populates index"| node_retrieval

click node_workflow "https://github.com/sumaylen/ai-support-ticket-agent/blob/main/src/graph.py"
click node_guards "https://github.com/sumaylen/ai-support-ticket-agent/blob/main/src/guardrails.py"
click node_classifier "https://github.com/sumaylen/ai-support-ticket-agent/blob/main/src/classify.py"
click node_lookup_agent "https://github.com/sumaylen/ai-support-ticket-agent/blob/main/src/agent.py"
click node_response "https://github.com/sumaylen/ai-support-ticket-agent/blob/main/src/respond.py"
click node_escalation "https://github.com/sumaylen/ai-support-ticket-agent/blob/main/src/escalation.py"
click node_retrieval "https://github.com/sumaylen/ai-support-ticket-agent/blob/main/src/retrieval.py"
click node_policies "https://github.com/sumaylen/ai-support-ticket-agent/tree/main/data/policies"
click node_policy_ingest "https://github.com/sumaylen/ai-support-ticket-agent/blob/main/build_knowledge_base.py"
click node_lookup_tools "https://github.com/sumaylen/ai-support-ticket-agent/blob/main/src/tools.py"
click node_company_db "https://github.com/sumaylen/ai-support-ticket-agent/blob/main/data/company.db"
click node_llm "https://github.com/sumaylen/ai-support-ticket-agent/blob/main/src/llm_client.py"
click node_dataset "https://github.com/sumaylen/ai-support-ticket-agent/blob/main/src/dataset.py"
click node_ticket_logs "https://github.com/sumaylen/ai-support-ticket-agent/blob/main/src/JSON_logger.py"
click node_retrieval_eval "https://github.com/sumaylen/ai-support-ticket-agent/blob/main/src/evaluate_retrieval.py"
click node_verifier_eval "https://github.com/sumaylen/ai-support-ticket-agent/blob/main/src/evaluate_verifier.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_workflow,node_guards,node_classifier,node_lookup_agent,node_response,node_escalation toneBlue
class node_retrieval,node_policies,node_policy_ingest,node_lookup_tools,node_company_db toneAmber
class node_llm,node_dataset toneMint
class node_ticket_logs,node_retrieval_eval,node_verifier_eval toneRose
class node_customer toneIndigo
```

## Components

### Ticket workflow

- [Ticket orchestration](https://github.com/sumaylen/ai-support-ticket-agent/blob/main/src/graph.py): `src/graph.py`
- [Prompt guards](https://github.com/sumaylen/ai-support-ticket-agent/blob/main/src/guardrails.py): `src/guardrails.py`
- [Category and urgency](https://github.com/sumaylen/ai-support-ticket-agent/blob/main/src/classify.py): `src/classify.py`
- [Lookup agent](https://github.com/sumaylen/ai-support-ticket-agent/blob/main/src/agent.py): `src/agent.py`
- [Draft and verify](https://github.com/sumaylen/ai-support-ticket-agent/blob/main/src/respond.py): `src/respond.py`
- [Escalation decision](https://github.com/sumaylen/ai-support-ticket-agent/blob/main/src/escalation.py): `src/escalation.py`

### Knowledge and data

- [Policy retrieval](https://github.com/sumaylen/ai-support-ticket-agent/blob/main/src/retrieval.py): `src/retrieval.py`
- [Support policies](https://github.com/sumaylen/ai-support-ticket-agent/tree/main/data/policies): `data/policies`
- [Knowledge-base builder](https://github.com/sumaylen/ai-support-ticket-agent/blob/main/build_knowledge_base.py): `build_knowledge_base.py`
- [Order and account tools](https://github.com/sumaylen/ai-support-ticket-agent/blob/main/src/tools.py): `src/tools.py`
- [Company database](https://github.com/sumaylen/ai-support-ticket-agent/blob/main/data/company.db): `data/company.db`

### Model services

- [LLM backend](https://github.com/sumaylen/ai-support-ticket-agent/blob/main/src/llm_client.py): `src/llm_client.py`
- [Training dataset split](https://github.com/sumaylen/ai-support-ticket-agent/blob/main/src/dataset.py): `src/dataset.py`

### Safety and evaluation

- [JSON event logs](https://github.com/sumaylen/ai-support-ticket-agent/blob/main/src/JSON_logger.py): `src/JSON_logger.py`
- [Retrieval evaluation](https://github.com/sumaylen/ai-support-ticket-agent/blob/main/src/evaluate_retrieval.py): `src/evaluate_retrieval.py`
- [Verifier evaluation](https://github.com/sumaylen/ai-support-ticket-agent/blob/main/src/evaluate_verifier.py): `src/evaluate_verifier.py`

### Other components

- **Customer**

## Connections

- Customer → Ticket orchestration: submits ticket (evidence: `README.md`)
- Ticket orchestration → Prompt guards: checks input (evidence: `src/graph.py`)
- Ticket orchestration → Category and urgency: classifies ticket (evidence: `src/graph.py`)
- Ticket orchestration → Lookup agent: dispatches lookup (evidence: `src/graph.py`)
- Ticket orchestration → Policy retrieval: retrieves context (evidence: `src/graph.py`)
- Ticket orchestration → Draft and verify: creates draft (evidence: `src/graph.py`)
- Ticket orchestration → Escalation decision: checks escalation (evidence: `src/graph.py`)
- Ticket orchestration → JSON event logs: records outcome (evidence: `src/graph.py`)
- Prompt guards → LLM backend: checks message (evidence: `src/guardrails.py`)
- Prompt guards → JSON event logs: logs flags (evidence: `src/guardrails.py`)
- Category and urgency → LLM backend: classifies (evidence: `src/classify.py`)
- Category and urgency → Training dataset split: loads categories (evidence: `src/classify.py`)
- Lookup agent → LLM backend: requests tool calls (evidence: `src/agent.py`)
- Lookup agent → Order and account tools: dispatches tools (evidence: `src/agent.py`)
- Order and account tools → Company database: queries (evidence: `src/tools.py`)
- Draft and verify → LLM backend: drafts and verifies (evidence: `src/respond.py`)
- Draft and verify → JSON event logs: logs failures (evidence: `src/respond.py`)
- Policy retrieval → LLM backend: queries policy store (evidence: `src/retrieval.py`)
- Retrieval evaluation → Policy retrieval: evaluates results (evidence: `src/evaluate_retrieval.py`)
- Verifier evaluation → Policy retrieval: uses retrieved context (evidence: `src/evaluate_verifier.py`)
- Verifier evaluation → Draft and verify: evaluates verification (evidence: `src/evaluate_verifier.py`)
- Support policies → Knowledge-base builder: supplies policy text
- Knowledge-base builder → Policy retrieval: populates index (evidence: `build_knowledge_base.py`)
