# kalvaharshith/agent-checkout architecture

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

- Interactive diagram: https://gitdiagram.com/kalvaharshith/agent-checkout
- Repository: https://github.com/kalvaharshith/agent-checkout

## Overview

Agent Checkout lets a buyer agent propose a catalog-based purchase, while a deterministic guard gates payment and an append-only audit trail records events for a timeline viewer. The documented flow also includes a human payment confirmation and signed payment webhooks. The graph preserves these stages and the checkout runner; source excerpts show the principal calls, while some integrations—such as Razorpay’s webhook dispatch—are documented in the README rather than sampled source.

Main entry points: [`audit/audit.py`](https://github.com/kalvaharshith/agent-checkout/blob/main/audit/audit.py) (Audit writer), [`agent/buyer.py`](https://github.com/kalvaharshith/agent-checkout/blob/main/agent/buyer.py) (Buyer agent), [`merchant/app.py`](https://github.com/kalvaharshith/agent-checkout/blob/main/merchant/app.py) (Merchant API), [`scripts/run_checkout.py`](https://github.com/kalvaharshith/agent-checkout/blob/main/scripts/run_checkout.py) (Checkout runner)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_shopping["Shopping"]
  node_buyer["Buyer agent<br/>[buyer.py]"]
  node_merchant["Merchant API<br/>[app.py]"]
  node_catalog["Product catalog<br/>[catalog.json]"]
end

subgraph group_controls["Guarded Checkout"]
  node_runner["Checkout runner<br/>[run_checkout.py]"]
  node_guard["Deterministic guard<br/>[guard.py]"]
  node_checkout["Payment checkout<br/>[checkout.py]"]
end

subgraph group_payments["Payment and Trust"]
  node_webhook["Webhook receiver<br/>[app.py]"]
end

subgraph group_audit["Audit and Timeline"]
  node_audit_module["Audit writer<br/>[audit.py]"]
  node_database[("SQLite audit trail<br/>[audit.db]")]
  node_viewer["Timeline viewer<br/>[app.py]"]
end

node_operator(("Mission operator"))
node_groq{{"Groq LLM"}}
node_payer(("Human payer"))
node_razorpay{{"Razorpay"}}

node_operator -->|"starts mission"| node_buyer
node_buyer -->|"fetches catalog"| node_merchant
node_merchant -->|"reads catalog"| node_catalog
node_buyer -->|"requests proposal"| node_groq
node_operator -->|"runs checkout"| node_runner
node_runner -->|"evaluates cart"| node_guard
node_guard -.->|"checks prices"| node_catalog
node_runner -->|"attempts approved payment"| node_checkout
node_checkout -->|"creates payment link"| node_razorpay
node_payer -->|"confirms payment"| node_razorpay
node_razorpay -.->|"sends payment event"| node_webhook
node_buyer -->|"logs events"| node_audit_module
node_merchant -->|"logs catalog service"| node_audit_module
node_guard -->|"logs decision"| node_audit_module
node_checkout -->|"logs payment steps"| node_audit_module
node_webhook -->|"logs verified event"| node_audit_module
node_audit_module -->|"appends events"| node_database
node_viewer -->|"reads timeline"| node_database

click node_buyer "https://github.com/kalvaharshith/agent-checkout/blob/main/agent/buyer.py"
click node_merchant "https://github.com/kalvaharshith/agent-checkout/blob/main/merchant/app.py"
click node_catalog "https://github.com/kalvaharshith/agent-checkout/blob/main/merchant/catalog.json"
click node_runner "https://github.com/kalvaharshith/agent-checkout/blob/main/scripts/run_checkout.py"
click node_guard "https://github.com/kalvaharshith/agent-checkout/blob/main/guard/guard.py"
click node_checkout "https://github.com/kalvaharshith/agent-checkout/blob/main/guard/checkout.py"
click node_webhook "https://github.com/kalvaharshith/agent-checkout/blob/main/webhooks/app.py"
click node_audit_module "https://github.com/kalvaharshith/agent-checkout/blob/main/audit/audit.py"
click node_database "https://github.com/kalvaharshith/agent-checkout/blob/main/db/audit.db"
click node_viewer "https://github.com/kalvaharshith/agent-checkout/blob/main/viewer/app.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_buyer,node_merchant,node_catalog toneBlue
class node_runner,node_guard,node_checkout toneAmber
class node_webhook toneMint
class node_audit_module,node_database,node_viewer toneRose
class node_operator,node_groq,node_payer,node_razorpay toneIndigo
```

## Components

### Shopping

- [Buyer agent](https://github.com/kalvaharshith/agent-checkout/blob/main/agent/buyer.py): `agent/buyer.py`
- [Merchant API](https://github.com/kalvaharshith/agent-checkout/blob/main/merchant/app.py): `merchant/app.py`
- [Product catalog](https://github.com/kalvaharshith/agent-checkout/blob/main/merchant/catalog.json): `merchant/catalog.json`

### Guarded Checkout

- [Checkout runner](https://github.com/kalvaharshith/agent-checkout/blob/main/scripts/run_checkout.py): `scripts/run_checkout.py`
- [Deterministic guard](https://github.com/kalvaharshith/agent-checkout/blob/main/guard/guard.py): `guard/guard.py`
- [Payment checkout](https://github.com/kalvaharshith/agent-checkout/blob/main/guard/checkout.py): `guard/checkout.py`

### Payment and Trust

- [Webhook receiver](https://github.com/kalvaharshith/agent-checkout/blob/main/webhooks/app.py): `webhooks/app.py`

### Audit and Timeline

- [Audit writer](https://github.com/kalvaharshith/agent-checkout/blob/main/audit/audit.py): `audit/audit.py`
- [SQLite audit trail](https://github.com/kalvaharshith/agent-checkout/blob/main/db/audit.db): `db/audit.db`
- [Timeline viewer](https://github.com/kalvaharshith/agent-checkout/blob/main/viewer/app.py): `viewer/app.py`

### Other components

- **Mission operator**
- **Groq LLM**
- **Human payer**
- **Razorpay**

## Connections

- Mission operator → Buyer agent: starts mission (evidence: `agent/buyer.py`)
- Buyer agent → Merchant API: fetches catalog (evidence: `agent/buyer.py`)
- Merchant API → Product catalog: reads catalog (evidence: `merchant/app.py`)
- Buyer agent → Groq LLM: requests proposal (evidence: `agent/buyer.py`)
- Mission operator → Checkout runner: runs checkout (evidence: `README.md`)
- Checkout runner → Deterministic guard: evaluates cart (evidence: `scripts/run_checkout.py`)
- Deterministic guard → Product catalog: checks prices (evidence: `README.md`)
- Checkout runner → Payment checkout: attempts approved payment (evidence: `scripts/run_checkout.py`)
- Payment checkout → Razorpay: creates payment link (evidence: `guard/checkout.py`)
- Human payer → Razorpay: confirms payment (evidence: `README.md`)
- Razorpay → Webhook receiver: sends payment event (evidence: `README.md`)
- Buyer agent → Audit writer: logs events (evidence: `agent/buyer.py`)
- Merchant API → Audit writer: logs catalog service (evidence: `merchant/app.py`)
- Deterministic guard → Audit writer: logs decision (evidence: `guard/guard.py`)
- Payment checkout → Audit writer: logs payment steps (evidence: `guard/checkout.py`)
- Webhook receiver → Audit writer: logs verified event (evidence: `webhooks/app.py`)
- Audit writer → SQLite audit trail: appends events (evidence: `audit/audit.py`)
- Timeline viewer → SQLite audit trail: reads timeline (evidence: `viewer/app.py`)
