# toorcn/rebind architecture

> Architecture diagram of the GitHub repository toorcn/rebind, 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/toorcn/rebind
- Repository: https://github.com/toorcn/rebind

## Overview

Rebind is a dual-mode job escrow product: wallet jobs settle on World Chain, while a separate credit sandbox demonstrates the same two-human rule without transactions. Its secondary revoke desk shows agent-key registration, revocation, and World ID rebind behavior. The README documents these capabilities; sampled source confirms the server, wallet/chain, page, and World ID entry points, but not every route-level call, so uncertain wiring is omitted.

Main entry points: [`src/paygate.ts`](https://github.com/toorcn/rebind/blob/main/src/paygate.ts) (Route controller), [`src/chain.ts`](https://github.com/toorcn/rebind/blob/main/src/chain.ts) (Chain API), [`src/server.ts`](https://github.com/toorcn/rebind/blob/main/src/server.ts) (HTTP server), [`src/wallet-browser.js`](https://github.com/toorcn/rebind/blob/main/src/wallet-browser.js) (Wallet controls)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_wallet["Wallet settlement"]
  node_walletpage["Wallet jobs UI<br/>[wallet-page.ts]"]
  node_walletbrowser["Wallet controls<br/>[wallet-browser.js]"]
  node_walletapi["Chain API<br/>[chain.ts]"]
  node_chainlogic["Chain operations<br/>[wallet-chain.ts]"]
  node_worldoidc["World ID checks<br/>[world-oidc.ts]"]
  node_contracts["Escrow contracts<br/>[ACPCore.sol]"]
  node_humanregistry[("Human registry<br/>[HumanRegistry.sol]")]
  node_twohook["Two-human hook<br/>[TwoHumansHook.sol]"]
end

subgraph group_sandbox["Credit sandbox"]
  node_jobroutes["Job routes<br/>[jobs.ts]"]
  node_jobpage["Job views<br/>[job-page.ts]"]
  node_pool[("Credit pool<br/>[pool.ts]")]
end

subgraph group_revoke["Revoke desk"]
  node_registry[("Agent registry<br/>[registry.ts]")]
  node_rebind["Rebind flow<br/>[rebind.ts]"]
end

subgraph group_explain["Product explainers"]
  node_spatial["Payment explainer<br/>[spatial-view.ts]"]
  node_scene["Interactive scenes<br/>[spatial-scene.js]"]
  node_film["Revoke film<br/>[film-run.ts]"]
  node_flow["Settlement animation<br/>[flow-page.ts]"]
end

node_buyerworker(("Buyer and worker"))
node_chain[("World Chain")]
node_metamask(("MetaMask"))
node_worldapp(("World App"))
node_server["HTTP server<br/>[server.ts]"]
node_paygate["Route controller<br/>[paygate.ts]"]
node_hosted["Hosted wallet backend"]

node_buyerworker -->|"use wallet jobs"| node_walletpage
node_walletpage -->|"embeds controls"| node_walletbrowser
node_walletbrowser -->|"sign transactions"| node_metamask
node_walletbrowser -->|"requests chain data"| node_walletapi
node_walletapi -->|"calls operations"| node_chainlogic
node_chainlogic -->|"reads and settles"| node_chain
node_chain -->|"executes calls"| node_contracts
node_contracts -->|"checks settlement"| node_twohook
node_twohook -->|"reads subjects"| node_humanregistry
node_walletapi -->|"starts and checks proofs"| node_worldoidc
node_worldapp -->|"approves verification"| node_worldoidc
node_buyerworker -->|"use credit sandbox"| node_server
node_server -->|"creates app"| node_paygate
node_paygate -->|"mounts routes"| node_jobroutes
node_jobroutes -->|"manages credit jobs"| node_pool
node_jobroutes -->|"renders job views"| node_jobpage
node_jobpage -->|"embeds payment view"| node_spatial
node_paygate -->|"handles registry routes"| node_registry
node_paygate -->|"handles rebind flow"| node_rebind
node_buyerworker -.->|"open desk or film"| node_server
node_server -.->|"runs film"| node_film
node_paygate -.->|"serves flow page"| node_flow
node_spatial -.->|"loads scene"| node_scene
node_walletapi -.->|"optional hosted mode"| node_hosted

click node_walletpage "https://github.com/toorcn/rebind/blob/main/src/wallet-page.ts"
click node_walletbrowser "https://github.com/toorcn/rebind/blob/main/src/wallet-browser.js"
click node_walletapi "https://github.com/toorcn/rebind/blob/main/src/chain.ts"
click node_chainlogic "https://github.com/toorcn/rebind/blob/main/src/wallet-chain.ts"
click node_worldoidc "https://github.com/toorcn/rebind/blob/main/src/world-oidc.ts"
click node_contracts "https://github.com/toorcn/rebind/blob/main/contracts/src/erc8183/ACPCore.sol"
click node_humanregistry "https://github.com/toorcn/rebind/blob/main/contracts/src/HumanRegistry.sol"
click node_twohook "https://github.com/toorcn/rebind/blob/main/contracts/src/TwoHumansHook.sol"
click node_server "https://github.com/toorcn/rebind/blob/main/src/server.ts"
click node_paygate "https://github.com/toorcn/rebind/blob/main/src/paygate.ts"
click node_jobroutes "https://github.com/toorcn/rebind/blob/main/src/jobs.ts"
click node_jobpage "https://github.com/toorcn/rebind/blob/main/src/job-page.ts"
click node_pool "https://github.com/toorcn/rebind/blob/main/src/pool.ts"
click node_registry "https://github.com/toorcn/rebind/blob/main/src/registry.ts"
click node_rebind "https://github.com/toorcn/rebind/blob/main/src/rebind.ts"
click node_spatial "https://github.com/toorcn/rebind/blob/main/src/spatial-view.ts"
click node_scene "https://github.com/toorcn/rebind/blob/main/src/spatial-scene.js"
click node_film "https://github.com/toorcn/rebind/blob/main/src/film-run.ts"
click node_flow "https://github.com/toorcn/rebind/blob/main/src/flow-page.ts"

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_walletpage,node_walletbrowser,node_walletapi,node_chainlogic,node_worldoidc,node_contracts,node_humanregistry,node_twohook toneBlue
class node_jobroutes,node_jobpage,node_pool,node_chain toneAmber
class node_registry,node_rebind,node_server,node_paygate toneMint
class node_spatial,node_scene,node_film,node_flow,node_buyerworker toneRose
class node_metamask,node_worldapp,node_hosted toneIndigo
```

## Components

### Wallet settlement

- [Wallet jobs UI](https://github.com/toorcn/rebind/blob/main/src/wallet-page.ts): `src/wallet-page.ts`
- [Wallet controls](https://github.com/toorcn/rebind/blob/main/src/wallet-browser.js): `src/wallet-browser.js`
- [Chain API](https://github.com/toorcn/rebind/blob/main/src/chain.ts): `src/chain.ts`
- [Chain operations](https://github.com/toorcn/rebind/blob/main/src/wallet-chain.ts): `src/wallet-chain.ts`
- [World ID checks](https://github.com/toorcn/rebind/blob/main/src/world-oidc.ts): `src/world-oidc.ts`
- [Escrow contracts](https://github.com/toorcn/rebind/blob/main/contracts/src/erc8183/ACPCore.sol): `contracts/src/erc8183/ACPCore.sol`
- [Human registry](https://github.com/toorcn/rebind/blob/main/contracts/src/HumanRegistry.sol): `contracts/src/HumanRegistry.sol`
- [Two-human hook](https://github.com/toorcn/rebind/blob/main/contracts/src/TwoHumansHook.sol): `contracts/src/TwoHumansHook.sol`

### Credit sandbox

- [Job routes](https://github.com/toorcn/rebind/blob/main/src/jobs.ts): `src/jobs.ts`
- [Job views](https://github.com/toorcn/rebind/blob/main/src/job-page.ts): `src/job-page.ts`
- [Credit pool](https://github.com/toorcn/rebind/blob/main/src/pool.ts): `src/pool.ts`

### Revoke desk

- [Agent registry](https://github.com/toorcn/rebind/blob/main/src/registry.ts): `src/registry.ts`
- [Rebind flow](https://github.com/toorcn/rebind/blob/main/src/rebind.ts): `src/rebind.ts`

### Product explainers

- [Payment explainer](https://github.com/toorcn/rebind/blob/main/src/spatial-view.ts): `src/spatial-view.ts`
- [Interactive scenes](https://github.com/toorcn/rebind/blob/main/src/spatial-scene.js): `src/spatial-scene.js`
- [Revoke film](https://github.com/toorcn/rebind/blob/main/src/film-run.ts): `src/film-run.ts`
- [Settlement animation](https://github.com/toorcn/rebind/blob/main/src/flow-page.ts): `src/flow-page.ts`

### Other components

- **Buyer and worker**
- **World Chain**
- **MetaMask**
- **World App**
- [HTTP server](https://github.com/toorcn/rebind/blob/main/src/server.ts): `src/server.ts`
- [Route controller](https://github.com/toorcn/rebind/blob/main/src/paygate.ts): `src/paygate.ts`
- **Hosted wallet backend**

## Connections

- Buyer and worker → Wallet jobs UI: use wallet jobs
- Wallet jobs UI → Wallet controls: embeds controls
- Wallet controls → MetaMask: sign transactions
- Wallet controls → Chain API: requests chain data
- Chain API → Chain operations: calls operations
- Chain operations → World Chain: reads and settles
- World Chain → Escrow contracts: executes calls
- Escrow contracts → Two-human hook: checks settlement
- Two-human hook → Human registry: reads subjects
- Chain API → World ID checks: starts and checks proofs
- World App → World ID checks: approves verification
- Buyer and worker → HTTP server: use credit sandbox
- HTTP server → Route controller: creates app
- Route controller → Job routes: mounts routes
- Job routes → Credit pool: manages credit jobs
- Job routes → Job views: renders job views
- Job views → Payment explainer: embeds payment view
- Route controller → Agent registry: handles registry routes
- Route controller → Rebind flow: handles rebind flow
- Buyer and worker → HTTP server: open desk or film
- HTTP server → Revoke film: runs film
- Route controller → Settlement animation: serves flow page
- Payment explainer → Interactive scenes: loads scene
- Chain API → Hosted wallet backend: optional hosted mode
