# alphaprimetrader/alpha-prime-avs-protocol-public architecture

> Architecture diagram of the GitHub repository alphaprimetrader/alpha-prime-avs-protocol-public, 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/alphaprimetrader/alpha-prime-avs-protocol-public
- Repository: https://github.com/alphaprimetrader/alpha-prime-avs-protocol-public

## Overview

Alpha Prime AVS Protocol is an experimental on-chain Smart Account and Passkey authorization foundation, with a canonical browser demo and BSC Testnet access/economic milestones. The main user workflow runs from browser Passkey setup through account preparation, relay-backed creation or UserOperation, and local Recovery Kit creation and root rotation. README-described Evolution, Gateway, Marketplace, Settlement, Ledger, Token, Vault, and migration capabilities are retained; their implementation sources are absent from this tree, so those subsystem paths and internal links remain broad or unverified.

Main entry points: [`apps/passkey-demo/src/App.tsx`](https://github.com/alphaprimetrader/alpha-prime-avs-protocol-public/blob/main/apps/passkey-demo/src/App.tsx) (Demo interface), [`apps/passkey-demo/src/lib/phase3b.ts`](https://github.com/alphaprimetrader/alpha-prime-avs-protocol-public/blob/main/apps/passkey-demo/src/lib/phase3b.ts) (Recovery rotation), [`scripts/src/phase3b-bsc-common.ts`](https://github.com/alphaprimetrader/alpha-prime-avs-protocol-public/blob/main/scripts/src/phase3b-bsc-common.ts) (Testnet preflight and evidence), [`apps/passkey-demo/src/lib/phase3a.ts`](https://github.com/alphaprimetrader/alpha-prime-avs-protocol-public/blob/main/apps/passkey-demo/src/lib/phase3a.ts) (Account operations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Passkey browser"]
  node_app["Demo interface<br/>[App.tsx]"]
  node_entry["Browser mount<br/>[main.tsx]"]
end

subgraph group_account["Account authorization"]
  node_passkeys["Passkey flows<br/>[phase3a.ts]"]
  node_accountflow["Account operations<br/>[phase3a.ts]"]
  node_rotation["Recovery rotation<br/>[phase3b.ts]"]
  node_kit["Encrypted Recovery Kit<br/>[recovery-kit.ts]"]
  node_relayclient["Relay client"]
  node_relay["Testnet relay<br/>[phase3b-relay.ts]"]
  node_evolution["Evolution authority"]
end

subgraph group_access["Protocol access"]
  node_gateway["Access Gateway and Lens"]
end

subgraph group_economic["Economic lifecycle"]
  node_marketplace["Marketplace lifecycle"]
  node_settlement["Trading Settlement"]
  node_ledger[("AVS Ledger")]
  node_token["AVS Token"]
  node_vault["AVS Vault"]
  node_migration["Legacy migration"]
end

subgraph group_ops["Testnet operations"]
  node_deploy["Deployment scripts"]
  node_common["Testnet preflight and evidence"]
  node_lifecycle["Marketplace execution"]
  node_settleexec["Settlement execution"]
  node_migrateexec["Migration execution"]
  node_verification["Source verification<br/>[sourcify-v2.ts]"]
end

node_user(("Account user"))
node_chain(("BSC Testnet"))

node_user -->|"uses"| node_app
node_entry -->|"renders"| node_app
node_app -->|"creates credentials"| node_passkeys
node_app -->|"prepares account"| node_accountflow
node_app -->|"starts recovery"| node_rotation
node_app -.->|"encrypts kit"| node_kit
node_accountflow -->|"requests relay"| node_relayclient
node_rotation -->|"submits rotation"| node_relayclient
node_relayclient -->|"HTTP requests"| node_relay
node_relay -.->|"relays transactions"| node_chain
node_accountflow -.->|"uses provider"| node_chain
node_rotation -->|"signs digests"| node_passkeys
node_rotation -.->|"uses recovery data"| node_kit
node_user -.->|"integrates via API"| node_gateway
node_gateway -.->|"discovers modules"| node_marketplace
node_marketplace -.->|"settles trades"| node_settlement
node_settlement -.->|"records activity"| node_ledger
node_vault -.->|"binds asset"| node_token
node_migration -.->|"executes migration"| node_chain
node_deploy -->|"checks network"| node_common
node_lifecycle -->|"runs preflight"| node_common
node_settleexec -->|"uses shared checks"| node_common
node_migrateexec -->|"uses shared checks"| node_common
node_deploy -.->|"verifies sources"| node_verification
node_lifecycle -.->|"executes lifecycle"| node_marketplace
node_settleexec -.->|"submits settlement"| node_settlement
node_migrateexec -.->|"executes migration"| node_migration

click node_app "https://github.com/alphaprimetrader/alpha-prime-avs-protocol-public/blob/main/apps/passkey-demo/src/App.tsx"
click node_entry "https://github.com/alphaprimetrader/alpha-prime-avs-protocol-public/blob/main/apps/passkey-demo/src/main.tsx"
click node_passkeys "https://github.com/alphaprimetrader/alpha-prime-avs-protocol-public/blob/main/apps/passkey-demo/src/lib/phase3a.ts"
click node_accountflow "https://github.com/alphaprimetrader/alpha-prime-avs-protocol-public/blob/main/apps/passkey-demo/src/lib/phase3a.ts"
click node_rotation "https://github.com/alphaprimetrader/alpha-prime-avs-protocol-public/blob/main/apps/passkey-demo/src/lib/phase3b.ts"
click node_kit "https://github.com/alphaprimetrader/alpha-prime-avs-protocol-public/blob/main/apps/passkey-demo/src/lib/recovery-kit.ts"
click node_relayclient "https://github.com/alphaprimetrader/alpha-prime-avs-protocol-public/blob/main/apps/passkey-demo/src/lib/phase3b-relay-client.ts"
click node_relay "https://github.com/alphaprimetrader/alpha-prime-avs-protocol-public/blob/main/apps/passkey-demo/test-harness/phase3b-relay.ts"
click node_evolution "https://github.com/alphaprimetrader/alpha-prime-avs-protocol-public/tree/main/contracts"
click node_gateway "https://github.com/alphaprimetrader/alpha-prime-avs-protocol-public/tree/main/contracts"
click node_marketplace "https://github.com/alphaprimetrader/alpha-prime-avs-protocol-public/tree/main/contracts"
click node_settlement "https://github.com/alphaprimetrader/alpha-prime-avs-protocol-public/tree/main/contracts"
click node_ledger "https://github.com/alphaprimetrader/alpha-prime-avs-protocol-public/tree/main/contracts"
click node_token "https://github.com/alphaprimetrader/alpha-prime-avs-protocol-public/tree/main/contracts"
click node_vault "https://github.com/alphaprimetrader/alpha-prime-avs-protocol-public/tree/main/contracts"
click node_migration "https://github.com/alphaprimetrader/alpha-prime-avs-protocol-public/tree/main/contracts"
click node_deploy "https://github.com/alphaprimetrader/alpha-prime-avs-protocol-public/blob/main/scripts/src/deploy-phase3b-bsc.ts"
click node_common "https://github.com/alphaprimetrader/alpha-prime-avs-protocol-public/blob/main/scripts/src/phase3b-bsc-common.ts"
click node_lifecycle "https://github.com/alphaprimetrader/alpha-prime-avs-protocol-public/blob/main/scripts/src/execute-phase3b-gateway-marketplace-lifecycle-bsc.ts"
click node_settleexec "https://github.com/alphaprimetrader/alpha-prime-avs-protocol-public/blob/main/scripts/src/execute-phase3c-first-trading-settlement-bsc.ts"
click node_migrateexec "https://github.com/alphaprimetrader/alpha-prime-avs-protocol-public/blob/main/scripts/src/execute-phase4d-bsc.ts"
click node_verification "https://github.com/alphaprimetrader/alpha-prime-avs-protocol-public/blob/main/scripts/src/sourcify-v2.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_app,node_entry,node_user toneBlue
class node_passkeys,node_accountflow,node_rotation,node_kit,node_relayclient,node_relay,node_evolution toneAmber
class node_gateway toneMint
class node_marketplace,node_settlement,node_ledger,node_token,node_vault,node_migration toneRose
class node_deploy,node_common,node_lifecycle,node_settleexec,node_migrateexec,node_verification,node_chain toneIndigo
```

## Components

### Passkey browser

- [Demo interface](https://github.com/alphaprimetrader/alpha-prime-avs-protocol-public/blob/main/apps/passkey-demo/src/App.tsx): `apps/passkey-demo/src/App.tsx`
- [Browser mount](https://github.com/alphaprimetrader/alpha-prime-avs-protocol-public/blob/main/apps/passkey-demo/src/main.tsx): `apps/passkey-demo/src/main.tsx`

### Account authorization

- [Passkey flows](https://github.com/alphaprimetrader/alpha-prime-avs-protocol-public/blob/main/apps/passkey-demo/src/lib/phase3a.ts): `apps/passkey-demo/src/lib/phase3a.ts`
- [Account operations](https://github.com/alphaprimetrader/alpha-prime-avs-protocol-public/blob/main/apps/passkey-demo/src/lib/phase3a.ts): `apps/passkey-demo/src/lib/phase3a.ts`
- [Recovery rotation](https://github.com/alphaprimetrader/alpha-prime-avs-protocol-public/blob/main/apps/passkey-demo/src/lib/phase3b.ts): `apps/passkey-demo/src/lib/phase3b.ts`
- [Encrypted Recovery Kit](https://github.com/alphaprimetrader/alpha-prime-avs-protocol-public/blob/main/apps/passkey-demo/src/lib/recovery-kit.ts): `apps/passkey-demo/src/lib/recovery-kit.ts`
- [Relay client](https://github.com/alphaprimetrader/alpha-prime-avs-protocol-public/blob/main/apps/passkey-demo/src/lib/phase3b-relay-client.ts): `apps/passkey-demo/src/lib/phase3b-relay-client.ts`
- [Testnet relay](https://github.com/alphaprimetrader/alpha-prime-avs-protocol-public/blob/main/apps/passkey-demo/test-harness/phase3b-relay.ts): `apps/passkey-demo/test-harness/phase3b-relay.ts`
- [Evolution authority](https://github.com/alphaprimetrader/alpha-prime-avs-protocol-public/tree/main/contracts): `contracts`

### Protocol access

- [Access Gateway and Lens](https://github.com/alphaprimetrader/alpha-prime-avs-protocol-public/tree/main/contracts): `contracts`

### Economic lifecycle

- [Marketplace lifecycle](https://github.com/alphaprimetrader/alpha-prime-avs-protocol-public/tree/main/contracts): `contracts`
- [Trading Settlement](https://github.com/alphaprimetrader/alpha-prime-avs-protocol-public/tree/main/contracts): `contracts`
- [AVS Ledger](https://github.com/alphaprimetrader/alpha-prime-avs-protocol-public/tree/main/contracts): `contracts`
- [AVS Token](https://github.com/alphaprimetrader/alpha-prime-avs-protocol-public/tree/main/contracts): `contracts`
- [AVS Vault](https://github.com/alphaprimetrader/alpha-prime-avs-protocol-public/tree/main/contracts): `contracts`
- [Legacy migration](https://github.com/alphaprimetrader/alpha-prime-avs-protocol-public/tree/main/contracts): `contracts`

### Testnet operations

- [Deployment scripts](https://github.com/alphaprimetrader/alpha-prime-avs-protocol-public/blob/main/scripts/src/deploy-phase3b-bsc.ts): `scripts/src/deploy-phase3b-bsc.ts`
- [Testnet preflight and evidence](https://github.com/alphaprimetrader/alpha-prime-avs-protocol-public/blob/main/scripts/src/phase3b-bsc-common.ts): `scripts/src/phase3b-bsc-common.ts`
- [Marketplace execution](https://github.com/alphaprimetrader/alpha-prime-avs-protocol-public/blob/main/scripts/src/execute-phase3b-gateway-marketplace-lifecycle-bsc.ts): `scripts/src/execute-phase3b-gateway-marketplace-lifecycle-bsc.ts`
- [Settlement execution](https://github.com/alphaprimetrader/alpha-prime-avs-protocol-public/blob/main/scripts/src/execute-phase3c-first-trading-settlement-bsc.ts): `scripts/src/execute-phase3c-first-trading-settlement-bsc.ts`
- [Migration execution](https://github.com/alphaprimetrader/alpha-prime-avs-protocol-public/blob/main/scripts/src/execute-phase4d-bsc.ts): `scripts/src/execute-phase4d-bsc.ts`
- [Source verification](https://github.com/alphaprimetrader/alpha-prime-avs-protocol-public/blob/main/scripts/src/sourcify-v2.ts): `scripts/src/sourcify-v2.ts`

### Other components

- **Account user**
- **BSC Testnet**

## Connections

- Account user → Demo interface: uses (evidence: `README.md`)
- Browser mount → Demo interface: renders (evidence: `apps/passkey-demo/src/main.tsx`)
- Demo interface → Passkey flows: creates credentials (evidence: `apps/passkey-demo/src/App.tsx`)
- Demo interface → Account operations: prepares account (evidence: `apps/passkey-demo/src/App.tsx`)
- Demo interface → Recovery rotation: starts recovery (evidence: `apps/passkey-demo/src/App.tsx`)
- Demo interface → Encrypted Recovery Kit: encrypts kit (evidence: `apps/passkey-demo/src/App.tsx`)
- Account operations → Relay client: requests relay (evidence: `apps/passkey-demo/src/lib/phase3a.ts`)
- Recovery rotation → Relay client: submits rotation (evidence: `apps/passkey-demo/src/lib/phase3b.ts`)
- Relay client → Testnet relay: HTTP requests (evidence: `apps/passkey-demo/src/lib/phase3b-relay-client.ts`)
- Testnet relay → BSC Testnet: relays transactions
- Account operations → BSC Testnet: uses provider
- Recovery rotation → Passkey flows: signs digests (evidence: `apps/passkey-demo/src/lib/phase3b.ts`)
- Recovery rotation → Encrypted Recovery Kit: uses recovery data (evidence: `apps/passkey-demo/src/lib/phase3b.ts`)
- Account user → Access Gateway and Lens: integrates via API (evidence: `README.md`)
- Access Gateway and Lens → Marketplace lifecycle: discovers modules (evidence: `README.md`)
- Marketplace lifecycle → Trading Settlement: settles trades (evidence: `README.md`)
- Trading Settlement → AVS Ledger: records activity
- AVS Vault → AVS Token: binds asset (evidence: `README.md`)
- Legacy migration → BSC Testnet: executes migration (evidence: `README.md`)
- Deployment scripts → Testnet preflight and evidence: checks network (evidence: `scripts/src/deploy-phase3b-bsc.ts`)
- Marketplace execution → Testnet preflight and evidence: runs preflight (evidence: `scripts/src/execute-phase3b-gateway-marketplace-lifecycle-bsc.ts`)
- Settlement execution → Testnet preflight and evidence: uses shared checks (evidence: `scripts/src/execute-phase3c-first-trading-settlement-bsc.ts`)
- Migration execution → Testnet preflight and evidence: uses shared checks (evidence: `scripts/src/execute-phase4d-bsc.ts`)
- Deployment scripts → Source verification: verifies sources
- Marketplace execution → Marketplace lifecycle: executes lifecycle (evidence: `README.md`)
- Settlement execution → Trading Settlement: submits settlement (evidence: `README.md`)
- Migration execution → Legacy migration: executes migration (evidence: `README.md`)
