# gsc-lab/course-aiagent-lab-refund architecture

> Architecture diagram of the GitHub repository gsc-lab/course-aiagent-lab-refund, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gsc-lab/course-aiagent-lab-refund
- Repository: https://github.com/gsc-lab/course-aiagent-lab-refund

## Overview

This repository is a Korean-language order and refund support agent: it analyzes a customer request with Claude, verifies orders and refund eligibility in Python, performs idempotent simulated refunds, and returns a customer response. The main CLI assembles State, policy, and tools, then runs the workflow through a Python execution loop or an optional LangGraph adapter. Runtime applies limits and retries and persists traces and checkpoints; SQLite stores refund records. The README documents scenarios, input-waiting and resume, escalation, and a smaller in-memory teaching example. Source excerpts establish core calls; some persistence and workflow links are documented in the README rather than fully excerpted.

Main entry points: [`src/refund_agent/runtime.py`](https://github.com/gsc-lab/course-aiagent-lab-refund/blob/main/src/refund_agent/runtime.py) (Runtime loop), [`src/refund_agent/main.py`](https://github.com/gsc-lab/course-aiagent-lab-refund/blob/main/src/refund_agent/main.py) (Agent CLI), [`src/refund_agent/state.py`](https://github.com/gsc-lab/course-aiagent-lab-refund/blob/main/src/refund_agent/state.py) (Workflow state), [`src/refund_agent/llm.py`](https://github.com/gsc-lab/course-aiagent-lab-refund/blob/main/src/refund_agent/llm.py) (Claude adapter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry and engines"]
  node_cli["Agent CLI<br/>[main.py]"]
  node_langgraph["LangGraph engine"]
  node_basic["Basic example<br/>[basic.py]"]
end

subgraph group_workflow["Request workflow"]
  node_analysis["Request analysis<br/>[nodes.py]"]
  node_lookup["Order lookup<br/>[nodes.py]"]
  node_assessment["Refund assessment<br/>[nodes.py]"]
  node_refund["Refund processing<br/>[nodes.py]"]
  node_response["Customer response<br/>[nodes.py]"]
  node_routing["Workflow routing<br/>[nodes.py]"]
end

subgraph group_execution["Execution controls"]
  node_runtime["Runtime loop<br/>[runtime.py]"]
  node_state["Workflow state<br/>[state.py]"]
  node_policy["Execution policy<br/>[state.py]"]
  node_trace["Trace logging<br/>[runtime.py]"]
  node_checkpoint["Checkpoint resume<br/>[runtime.py]"]
end

subgraph group_services["Models and order service"]
  node_llm["Claude adapter<br/>[llm.py]"]
  node_mockapi["Mock order API<br/>[tools.py]"]
  node_refunddb[("Refund records<br/>[tools.py]")]
end

node_customer(("Customer"))
node_claude{{"Claude API"}}

node_customer -->|"submits request"| node_cli
node_cli -->|"creates or restores"| node_state
node_cli -->|"configures"| node_policy
node_cli -->|"starts"| node_runtime
node_cli -->|"configures"| node_mockapi
node_cli -.->|"selects optionally"| node_langgraph
node_cli -->|"runs Python engine"| node_runtime
node_runtime -->|"executes node"| node_analysis
node_runtime -->|"updates and checkpoints"| node_state
node_runtime -->|"enforces limits"| node_policy
node_runtime -->|"records events"| node_trace
node_runtime -->|"saves and loads"| node_checkpoint
node_analysis -->|"requests analysis"| node_llm
node_llm -->|"sends messages"| node_claude
node_runtime -->|"calls with limits"| node_llm
node_runtime -->|"dispatches tool calls"| node_mockapi
node_lookup -->|"requests order data"| node_runtime
node_assessment -->|"reads order"| node_state
node_refund -->|"requests refund tools"| node_runtime
node_mockapi -->|"reads and writes"| node_refunddb
node_routing -->|"reads workflow status"| node_state
node_runtime -->|"chooses next node"| node_routing
node_response -->|"stores response"| node_state
node_langgraph -->|"invokes runtime step"| node_runtime
node_langgraph -->|"uses route"| node_routing
node_basic -->|"uses analyzer"| node_llm
node_customer -->|"runs example"| node_basic

click node_cli "https://github.com/gsc-lab/course-aiagent-lab-refund/blob/main/src/refund_agent/main.py"
click node_runtime "https://github.com/gsc-lab/course-aiagent-lab-refund/blob/main/src/refund_agent/runtime.py"
click node_state "https://github.com/gsc-lab/course-aiagent-lab-refund/blob/main/src/refund_agent/state.py"
click node_policy "https://github.com/gsc-lab/course-aiagent-lab-refund/blob/main/src/refund_agent/state.py"
click node_trace "https://github.com/gsc-lab/course-aiagent-lab-refund/blob/main/src/refund_agent/runtime.py"
click node_checkpoint "https://github.com/gsc-lab/course-aiagent-lab-refund/blob/main/src/refund_agent/runtime.py"
click node_analysis "https://github.com/gsc-lab/course-aiagent-lab-refund/blob/main/src/refund_agent/nodes.py"
click node_llm "https://github.com/gsc-lab/course-aiagent-lab-refund/blob/main/src/refund_agent/llm.py"
click node_lookup "https://github.com/gsc-lab/course-aiagent-lab-refund/blob/main/src/refund_agent/nodes.py"
click node_assessment "https://github.com/gsc-lab/course-aiagent-lab-refund/blob/main/src/refund_agent/nodes.py"
click node_refund "https://github.com/gsc-lab/course-aiagent-lab-refund/blob/main/src/refund_agent/nodes.py"
click node_response "https://github.com/gsc-lab/course-aiagent-lab-refund/blob/main/src/refund_agent/nodes.py"
click node_routing "https://github.com/gsc-lab/course-aiagent-lab-refund/blob/main/src/refund_agent/nodes.py"
click node_mockapi "https://github.com/gsc-lab/course-aiagent-lab-refund/blob/main/src/refund_agent/tools.py"
click node_refunddb "https://github.com/gsc-lab/course-aiagent-lab-refund/blob/main/src/refund_agent/tools.py"
click node_langgraph "https://github.com/gsc-lab/course-aiagent-lab-refund/blob/main/src/refund_agent/langgraph_version.py"
click node_basic "https://github.com/gsc-lab/course-aiagent-lab-refund/blob/main/src/refund_agent/basic.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_cli,node_langgraph,node_basic toneBlue
class node_analysis,node_lookup,node_assessment,node_refund,node_response,node_routing toneAmber
class node_runtime,node_state,node_policy,node_trace,node_checkpoint,node_claude toneMint
class node_llm,node_mockapi,node_refunddb toneRose
class node_customer toneIndigo
```

## Components

### Entry and engines

- [Agent CLI](https://github.com/gsc-lab/course-aiagent-lab-refund/blob/main/src/refund_agent/main.py): `src/refund_agent/main.py`
- [LangGraph engine](https://github.com/gsc-lab/course-aiagent-lab-refund/blob/main/src/refund_agent/langgraph_version.py): `src/refund_agent/langgraph_version.py`
- [Basic example](https://github.com/gsc-lab/course-aiagent-lab-refund/blob/main/src/refund_agent/basic.py): `src/refund_agent/basic.py`

### Request workflow

- [Request analysis](https://github.com/gsc-lab/course-aiagent-lab-refund/blob/main/src/refund_agent/nodes.py): `src/refund_agent/nodes.py`
- [Order lookup](https://github.com/gsc-lab/course-aiagent-lab-refund/blob/main/src/refund_agent/nodes.py): `src/refund_agent/nodes.py`
- [Refund assessment](https://github.com/gsc-lab/course-aiagent-lab-refund/blob/main/src/refund_agent/nodes.py): `src/refund_agent/nodes.py`
- [Refund processing](https://github.com/gsc-lab/course-aiagent-lab-refund/blob/main/src/refund_agent/nodes.py): `src/refund_agent/nodes.py`
- [Customer response](https://github.com/gsc-lab/course-aiagent-lab-refund/blob/main/src/refund_agent/nodes.py): `src/refund_agent/nodes.py`
- [Workflow routing](https://github.com/gsc-lab/course-aiagent-lab-refund/blob/main/src/refund_agent/nodes.py): `src/refund_agent/nodes.py`

### Execution controls

- [Runtime loop](https://github.com/gsc-lab/course-aiagent-lab-refund/blob/main/src/refund_agent/runtime.py): `src/refund_agent/runtime.py`
- [Workflow state](https://github.com/gsc-lab/course-aiagent-lab-refund/blob/main/src/refund_agent/state.py): `src/refund_agent/state.py`
- [Execution policy](https://github.com/gsc-lab/course-aiagent-lab-refund/blob/main/src/refund_agent/state.py): `src/refund_agent/state.py`
- [Trace logging](https://github.com/gsc-lab/course-aiagent-lab-refund/blob/main/src/refund_agent/runtime.py): `src/refund_agent/runtime.py`
- [Checkpoint resume](https://github.com/gsc-lab/course-aiagent-lab-refund/blob/main/src/refund_agent/runtime.py): `src/refund_agent/runtime.py`

### Models and order service

- [Claude adapter](https://github.com/gsc-lab/course-aiagent-lab-refund/blob/main/src/refund_agent/llm.py): `src/refund_agent/llm.py`
- [Mock order API](https://github.com/gsc-lab/course-aiagent-lab-refund/blob/main/src/refund_agent/tools.py): `src/refund_agent/tools.py`
- [Refund records](https://github.com/gsc-lab/course-aiagent-lab-refund/blob/main/src/refund_agent/tools.py): `src/refund_agent/tools.py`

### Other components

- **Customer**
- **Claude API**

## Connections

- Customer → Agent CLI: submits request (evidence: `README.md`)
- Agent CLI → Workflow state: creates or restores (evidence: `src/refund_agent/main.py`)
- Agent CLI → Execution policy: configures (evidence: `src/refund_agent/main.py`)
- Agent CLI → Runtime loop: starts (evidence: `src/refund_agent/main.py`)
- Agent CLI → Mock order API: configures (evidence: `src/refund_agent/main.py`)
- Agent CLI → LangGraph engine: selects optionally (evidence: `src/refund_agent/main.py`)
- Agent CLI → Runtime loop: runs Python engine (evidence: `src/refund_agent/main.py`)
- Runtime loop → Request analysis: executes node (evidence: `src/refund_agent/runtime.py`)
- Runtime loop → Workflow state: updates and checkpoints (evidence: `src/refund_agent/runtime.py`)
- Runtime loop → Execution policy: enforces limits (evidence: `src/refund_agent/runtime.py`)
- Runtime loop → Trace logging: records events (evidence: `README.md`)
- Runtime loop → Checkpoint resume: saves and loads (evidence: `README.md`)
- Request analysis → Claude adapter: requests analysis (evidence: `README.md`)
- Claude adapter → Claude API: sends messages (evidence: `src/refund_agent/llm.py`)
- Runtime loop → Claude adapter: calls with limits (evidence: `src/refund_agent/runtime.py`)
- Runtime loop → Mock order API: dispatches tool calls (evidence: `src/refund_agent/runtime.py`)
- Order lookup → Runtime loop: requests order data (evidence: `src/refund_agent/nodes.py`)
- Refund assessment → Workflow state: reads order (evidence: `src/refund_agent/nodes.py`)
- Refund processing → Runtime loop: requests refund tools (evidence: `src/refund_agent/nodes.py`)
- Mock order API → Refund records: reads and writes (evidence: `src/refund_agent/tools.py`)
- Workflow routing → Workflow state: reads workflow status (evidence: `src/refund_agent/nodes.py`)
- Runtime loop → Workflow routing: chooses next node (evidence: `src/refund_agent/runtime.py`)
- Customer response → Workflow state: stores response (evidence: `src/refund_agent/nodes.py`)
- LangGraph engine → Runtime loop: invokes runtime step (evidence: `src/refund_agent/langgraph_version.py`)
- LangGraph engine → Workflow routing: uses route (evidence: `src/refund_agent/langgraph_version.py`)
- Basic example → Claude adapter: uses analyzer (evidence: `src/refund_agent/basic.py`)
- Customer → Basic example: runs example (evidence: `README.md`)
