# dami904/steward architecture

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

- Interactive diagram: https://gitdiagram.com/dami904/steward
- Repository: https://github.com/dami904/steward

## Overview

Steward lets an agent propose vault deposits or redemptions while deterministic policy—not the model—determines whether they are permitted; account limits can be earned or reduced through replayable conduct. The web app exposes simulation, account controls, verification, measured liquidity, and a honeypot, while the TypeScript engine implements policy, accounting, evidence, health, and tier logic. The tree omits the contracts and several page/library excerpts, so on-chain behavior is shown as an external system and uncertain wiring is omitted.

Main entry points: [`apps/web/app/api/verify-paid/route.ts`](https://github.com/dami904/steward/blob/main/apps/web/app/api/verify-paid/route.ts) (Paid verification API), [`apps/web/lib/chain.ts`](https://github.com/dami904/steward/blob/main/apps/web/lib/chain.ts) (Chain reader), [`apps/web/app/simulate/Simulator.tsx`](https://github.com/dami904/steward/blob/main/apps/web/app/simulate/Simulator.tsx) (Policy simulator), [`apps/web/lib/replay.ts`](https://github.com/dami904/steward/blob/main/apps/web/lib/replay.ts) (History replay)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web product"]
  node_landing["Product landing<br/>[page.tsx]"]
  node_simulator["Policy simulator<br/>[Simulator.tsx]"]
  node_account_ui["Account controls<br/>[page.tsx]"]
  node_verify_ui["Verifier<br/>[page.tsx]"]
  node_paid_route["Paid verification API<br/>[route.ts]"]
  node_honeypot_ui["Honeypot inbox<br/>[NoticeInbox.tsx]"]
  node_honeypot_api["Notice API<br/>[route.ts]"]
  node_store[("Notice store<br/>[honeypot-store.ts]")]
end

subgraph group_engine["Policy engine"]
  node_engine_accounting["Capacity accounting<br/>[accounting.ts]"]
  node_engine_policy["Policy checks<br/>[policy.ts]"]
  node_engine_health["Health assessment<br/>[health.ts]"]
  node_engine_tiers["Tier transitions<br/>[tiers.ts]"]
  node_engine_evidence["Evidence assessment<br/>[evidence.ts]"]
end

subgraph group_chain["Chain and replay"]
  node_chain_lib["Chain reader<br/>[chain.ts]"]
  node_replay["History replay<br/>[replay.ts]"]
  node_liquidity["Vault liquidity<br/>[vault-liquidity.ts]"]
  node_deployment["RPC configuration<br/>[deployment.ts]"]
end

subgraph group_agent["Agent and evidence"]
  node_serv_reasoner["SERV reasoner<br/>[reasoner.ts]"]
  node_serv_client["SERV transport<br/>[client.ts]"]
end

subgraph group_services["Integrations"]
  node_rpc[("BSC RPC or demo chain")]
  node_serv_service["SERV model API"]
  node_x402["x402 payment gate<br/>[proxy.ts]"]
  node_demo_proxy["Read-only chain proxy<br/>[proxy.mjs]"]
end

node_user(("User or operator"))
node_agent_actor(("AI agent"))
node_account_contract["Steward account and vault"]

node_user -->|"browses"| node_landing
node_user -->|"adjusts inputs"| node_simulator
node_simulator -->|"computes capacity"| node_engine_accounting
node_simulator -->|"checks proposal"| node_engine_policy
node_engine_accounting -->|"uses health"| node_engine_health
node_agent_actor -->|"requests proposal"| node_serv_reasoner
node_serv_reasoner -->|"sends prompt"| node_serv_client
node_serv_client -->|"requests completion"| node_serv_service
node_serv_service -->|"returns claims"| node_serv_client
node_serv_reasoner -->|"assesses claims"| node_engine_evidence
node_account_ui -->|"resolves RPC"| node_deployment
node_verify_ui -->|"reads account history"| node_chain_lib
node_paid_route -->|"resolves RPC"| node_deployment
node_paid_route -->|"reads state and events"| node_chain_lib
node_paid_route -->|"replays history"| node_replay
node_chain_lib -->|"reads chain"| node_rpc
node_chain_lib -->|"queries account"| node_account_contract
node_replay -->|"checks transitions"| node_engine_tiers
node_replay -->|"checks rules"| node_engine_policy
node_landing -->|"loads measurements"| node_liquidity
node_liquidity -->|"reads request history"| node_rpc
node_honeypot_ui -->|"submits notices"| node_honeypot_api
node_honeypot_api -->|"lists or stores"| node_store
node_user -->|"requests replay"| node_paid_route
node_x402 -->|"gates payment"| node_paid_route
node_demo_proxy -->|"forwards allowed reads"| node_rpc
node_account_ui -.->|"reads or manages account"| node_account_contract
node_account_contract -.->|"enforces policy"| node_engine_policy

click node_landing "https://github.com/dami904/steward/blob/main/apps/web/app/page.tsx"
click node_simulator "https://github.com/dami904/steward/blob/main/apps/web/app/simulate/Simulator.tsx"
click node_account_ui "https://github.com/dami904/steward/blob/main/apps/web/app/app/page.tsx"
click node_verify_ui "https://github.com/dami904/steward/blob/main/apps/web/app/verify/page.tsx"
click node_paid_route "https://github.com/dami904/steward/blob/main/apps/web/app/api/verify-paid/route.ts"
click node_honeypot_ui "https://github.com/dami904/steward/blob/main/apps/web/app/honeypot/NoticeInbox.tsx"
click node_honeypot_api "https://github.com/dami904/steward/blob/main/apps/web/app/api/honeypot/notices/route.ts"
click node_store "https://github.com/dami904/steward/blob/main/apps/web/lib/honeypot-store.ts"
click node_engine_accounting "https://github.com/dami904/steward/blob/main/packages/engine/src/accounting.ts"
click node_engine_policy "https://github.com/dami904/steward/blob/main/packages/engine/src/policy.ts"
click node_engine_health "https://github.com/dami904/steward/blob/main/packages/engine/src/health.ts"
click node_engine_tiers "https://github.com/dami904/steward/blob/main/packages/engine/src/tiers.ts"
click node_engine_evidence "https://github.com/dami904/steward/blob/main/packages/engine/src/evidence.ts"
click node_serv_reasoner "https://github.com/dami904/steward/blob/main/packages/serv-client/src/reasoner.ts"
click node_serv_client "https://github.com/dami904/steward/blob/main/packages/serv-client/src/client.ts"
click node_chain_lib "https://github.com/dami904/steward/blob/main/apps/web/lib/chain.ts"
click node_replay "https://github.com/dami904/steward/blob/main/apps/web/lib/replay.ts"
click node_liquidity "https://github.com/dami904/steward/blob/main/apps/web/lib/vault-liquidity.ts"
click node_deployment "https://github.com/dami904/steward/blob/main/apps/web/lib/deployment.ts"
click node_x402 "https://github.com/dami904/steward/blob/main/apps/web/proxy.ts"
click node_demo_proxy "https://github.com/dami904/steward/blob/main/deploy/demo-chain/proxy.mjs"

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_landing,node_simulator,node_account_ui,node_verify_ui,node_paid_route,node_honeypot_ui,node_honeypot_api,node_store,node_user toneBlue
class node_engine_accounting,node_engine_policy,node_engine_health,node_engine_tiers,node_engine_evidence toneAmber
class node_chain_lib,node_replay,node_liquidity,node_deployment toneMint
class node_serv_reasoner,node_serv_client toneRose
class node_rpc,node_serv_service,node_x402,node_demo_proxy,node_agent_actor,node_account_contract toneIndigo
```

## Components

### Web product

- [Product landing](https://github.com/dami904/steward/blob/main/apps/web/app/page.tsx): `apps/web/app/page.tsx`
- [Policy simulator](https://github.com/dami904/steward/blob/main/apps/web/app/simulate/Simulator.tsx): `apps/web/app/simulate/Simulator.tsx`
- [Account controls](https://github.com/dami904/steward/blob/main/apps/web/app/app/page.tsx): `apps/web/app/app/page.tsx`
- [Verifier](https://github.com/dami904/steward/blob/main/apps/web/app/verify/page.tsx): `apps/web/app/verify/page.tsx`
- [Paid verification API](https://github.com/dami904/steward/blob/main/apps/web/app/api/verify-paid/route.ts): `apps/web/app/api/verify-paid/route.ts`
- [Honeypot inbox](https://github.com/dami904/steward/blob/main/apps/web/app/honeypot/NoticeInbox.tsx): `apps/web/app/honeypot/NoticeInbox.tsx`
- [Notice API](https://github.com/dami904/steward/blob/main/apps/web/app/api/honeypot/notices/route.ts): `apps/web/app/api/honeypot/notices/route.ts`
- [Notice store](https://github.com/dami904/steward/blob/main/apps/web/lib/honeypot-store.ts): `apps/web/lib/honeypot-store.ts`

### Policy engine

- [Capacity accounting](https://github.com/dami904/steward/blob/main/packages/engine/src/accounting.ts): `packages/engine/src/accounting.ts`
- [Policy checks](https://github.com/dami904/steward/blob/main/packages/engine/src/policy.ts): `packages/engine/src/policy.ts`
- [Health assessment](https://github.com/dami904/steward/blob/main/packages/engine/src/health.ts): `packages/engine/src/health.ts`
- [Tier transitions](https://github.com/dami904/steward/blob/main/packages/engine/src/tiers.ts): `packages/engine/src/tiers.ts`
- [Evidence assessment](https://github.com/dami904/steward/blob/main/packages/engine/src/evidence.ts): `packages/engine/src/evidence.ts`

### Chain and replay

- [Chain reader](https://github.com/dami904/steward/blob/main/apps/web/lib/chain.ts): `apps/web/lib/chain.ts`
- [History replay](https://github.com/dami904/steward/blob/main/apps/web/lib/replay.ts): `apps/web/lib/replay.ts`
- [Vault liquidity](https://github.com/dami904/steward/blob/main/apps/web/lib/vault-liquidity.ts): `apps/web/lib/vault-liquidity.ts`
- [RPC configuration](https://github.com/dami904/steward/blob/main/apps/web/lib/deployment.ts): `apps/web/lib/deployment.ts`

### Agent and evidence

- [SERV reasoner](https://github.com/dami904/steward/blob/main/packages/serv-client/src/reasoner.ts): `packages/serv-client/src/reasoner.ts`
- [SERV transport](https://github.com/dami904/steward/blob/main/packages/serv-client/src/client.ts): `packages/serv-client/src/client.ts`

### Integrations

- **BSC RPC or demo chain**
- **SERV model API**
- [x402 payment gate](https://github.com/dami904/steward/blob/main/apps/web/proxy.ts): `apps/web/proxy.ts`
- [Read-only chain proxy](https://github.com/dami904/steward/blob/main/deploy/demo-chain/proxy.mjs): `deploy/demo-chain/proxy.mjs`

### Other components

- **User or operator**
- **AI agent**
- **Steward account and vault**

## Connections

- User or operator → Product landing: browses
- User or operator → Policy simulator: adjusts inputs
- Policy simulator → Capacity accounting: computes capacity
- Policy simulator → Policy checks: checks proposal
- Capacity accounting → Health assessment: uses health
- AI agent → SERV reasoner: requests proposal
- SERV reasoner → SERV transport: sends prompt
- SERV transport → SERV model API: requests completion
- SERV model API → SERV transport: returns claims
- SERV reasoner → Evidence assessment: assesses claims
- Account controls → RPC configuration: resolves RPC
- Verifier → Chain reader: reads account history
- Paid verification API → RPC configuration: resolves RPC
- Paid verification API → Chain reader: reads state and events
- Paid verification API → History replay: replays history
- Chain reader → BSC RPC or demo chain: reads chain
- Chain reader → Steward account and vault: queries account
- History replay → Tier transitions: checks transitions
- History replay → Policy checks: checks rules
- Product landing → Vault liquidity: loads measurements
- Vault liquidity → BSC RPC or demo chain: reads request history
- Honeypot inbox → Notice API: submits notices
- Notice API → Notice store: lists or stores
- User or operator → Paid verification API: requests replay
- x402 payment gate → Paid verification API: gates payment
- Read-only chain proxy → BSC RPC or demo chain: forwards allowed reads
- Account controls → Steward account and vault: reads or manages account
- Steward account and vault → Policy checks: enforces policy
