# flav1e21/monad-agent-trust architecture

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

- Interactive diagram: https://gitdiagram.com/flav1e21/monad-agent-trust
- Repository: https://github.com/flav1e21/monad-agent-trust

## Overview

Agent Trust Layer combines on-chain agent identity and escrow payments with an Envio event indexer that derives reputation and network statistics for a live dapp. The main workflow is: users inspect indexed agent/task data and initiate escrow actions; contracts emit lifecycle events; handlers update queryable aggregates; the dapp polls those aggregates for its leaderboard and task feed. README documents the unsampled contract and dapp capabilities; handler-to-entity updates are visible in the excerpt. Contract event wiring to the indexer is documented, but the detailed implementation of the dapp and contracts was not sampled.

Main entry points: [`src/handlers.ts`](https://github.com/flav1e21/monad-agent-trust/blob/main/src/handlers.ts) (Event handlers), [`config.yaml`](https://github.com/flav1e21/monad-agent-trust/blob/main/config.yaml) (HyperIndex GraphQL), [`contracts/AgentEscrow.sol`](https://github.com/flav1e21/monad-agent-trust/blob/main/contracts/AgentEscrow.sol) (Payment escrow), [`web/index.html`](https://github.com/flav1e21/monad-agent-trust/blob/main/web/index.html) (Escrow actions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_chain["On-chain trust and escrow"]
  node_registry["Agent registry<br/>[AgentRegistry.sol]"]
  node_escrow["Payment escrow<br/>[AgentEscrow.sol]"]
end

subgraph group_indexer["Event indexing"]
  node_handlers["Event handlers<br/>[handlers.ts]"]
  node_graphql["HyperIndex GraphQL<br/>[config.yaml]"]
end

subgraph group_data["Trust data"]
  node_agent[("Agent aggregates<br/>[schema.graphql]")]
  node_attestation[("Attestations<br/>[schema.graphql]")]
  node_task[("Task lifecycle<br/>[schema.graphql]")]
  node_network[("Network statistics<br/>[schema.graphql]")]
end

subgraph group_app["Dapp experience"]
  node_leaderboard["Leaderboard and feed<br/>[index.html]"]
  node_actions["Escrow actions<br/>[index.html]"]
end

node_user(("Agent economy user"))

node_user -->|"views"| node_leaderboard
node_user -->|"initiates"| node_actions
node_actions -->|"registers agents"| node_registry
node_actions -->|"manages tasks"| node_escrow
node_escrow -->|"checks identity"| node_registry
node_registry -->|"emits events"| node_handlers
node_escrow -->|"emits events"| node_handlers
node_handlers -->|"updates aggregates"| node_agent
node_handlers -->|"records verdicts"| node_attestation
node_handlers -->|"mirrors lifecycle"| node_task
node_handlers -->|"updates totals"| node_network
node_leaderboard -->|"polls queries"| node_graphql
node_graphql -->|"serves aggregates"| node_agent
node_graphql -->|"serves task feed"| node_task
node_graphql -->|"serves statistics"| node_network

click node_registry "https://github.com/flav1e21/monad-agent-trust/blob/main/contracts/AgentRegistry.sol"
click node_escrow "https://github.com/flav1e21/monad-agent-trust/blob/main/contracts/AgentEscrow.sol"
click node_handlers "https://github.com/flav1e21/monad-agent-trust/blob/main/src/handlers.ts"
click node_agent "https://github.com/flav1e21/monad-agent-trust/blob/main/schema.graphql"
click node_attestation "https://github.com/flav1e21/monad-agent-trust/blob/main/schema.graphql"
click node_task "https://github.com/flav1e21/monad-agent-trust/blob/main/schema.graphql"
click node_network "https://github.com/flav1e21/monad-agent-trust/blob/main/schema.graphql"
click node_graphql "https://github.com/flav1e21/monad-agent-trust/blob/main/config.yaml"
click node_leaderboard "https://github.com/flav1e21/monad-agent-trust/blob/main/web/index.html"
click node_actions "https://github.com/flav1e21/monad-agent-trust/blob/main/web/index.html"

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_registry,node_escrow,node_user toneBlue
class node_handlers,node_graphql toneAmber
class node_agent,node_attestation,node_task,node_network toneMint
class node_leaderboard,node_actions toneRose
```

## Components

### On-chain trust and escrow

- [Agent registry](https://github.com/flav1e21/monad-agent-trust/blob/main/contracts/AgentRegistry.sol): `contracts/AgentRegistry.sol`
- [Payment escrow](https://github.com/flav1e21/monad-agent-trust/blob/main/contracts/AgentEscrow.sol): `contracts/AgentEscrow.sol`

### Event indexing

- [Event handlers](https://github.com/flav1e21/monad-agent-trust/blob/main/src/handlers.ts): `src/handlers.ts`
- [HyperIndex GraphQL](https://github.com/flav1e21/monad-agent-trust/blob/main/config.yaml): `config.yaml`

### Trust data

- [Agent aggregates](https://github.com/flav1e21/monad-agent-trust/blob/main/schema.graphql): `schema.graphql`
- [Attestations](https://github.com/flav1e21/monad-agent-trust/blob/main/schema.graphql): `schema.graphql`
- [Task lifecycle](https://github.com/flav1e21/monad-agent-trust/blob/main/schema.graphql): `schema.graphql`
- [Network statistics](https://github.com/flav1e21/monad-agent-trust/blob/main/schema.graphql): `schema.graphql`

### Dapp experience

- [Leaderboard and feed](https://github.com/flav1e21/monad-agent-trust/blob/main/web/index.html): `web/index.html`
- [Escrow actions](https://github.com/flav1e21/monad-agent-trust/blob/main/web/index.html): `web/index.html`

### Other components

- **Agent economy user**

## Connections

- Agent economy user → Leaderboard and feed: views (evidence: `README.md`)
- Agent economy user → Escrow actions: initiates (evidence: `README.md`)
- Escrow actions → Agent registry: registers agents (evidence: `README.md`)
- Escrow actions → Payment escrow: manages tasks (evidence: `README.md`)
- Payment escrow → Agent registry: checks identity (evidence: `README.md`)
- Agent registry → Event handlers: emits events (evidence: `README.md`)
- Payment escrow → Event handlers: emits events (evidence: `README.md`)
- Event handlers → Agent aggregates: updates aggregates (evidence: `src/handlers.ts`)
- Event handlers → Attestations: records verdicts (evidence: `src/handlers.ts`)
- Event handlers → Task lifecycle: mirrors lifecycle (evidence: `src/handlers.ts`)
- Event handlers → Network statistics: updates totals (evidence: `src/handlers.ts`)
- Leaderboard and feed → HyperIndex GraphQL: polls queries (evidence: `README.md`)
- HyperIndex GraphQL → Agent aggregates: serves aggregates (evidence: `README.md`)
- HyperIndex GraphQL → Task lifecycle: serves task feed (evidence: `README.md`)
- HyperIndex GraphQL → Network statistics: serves statistics (evidence: `README.md`)
