# 2-5-foundation/vane_web3 architecture

> Architecture diagram of the GitHub repository 2-5-foundation/vane_web3, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/2-5-foundation/vane_web3
- Repository: https://github.com/2-5-foundation/vane_web3

## Overview

##### Project type and purpose
- This is a Rust-based, full-stack “sovereign custodian” for Web3 users (“vane_web3”), acting as a local safety layer around any wallet to confirm addresses, simulate transactions, verify ownership, then route transactions to blockchains.
- It comprises multiple Rust crates (app, node, db, db-wasm, primitives, tests) plus a minimal JS/TS front-end MVP (vane_web3_mvp).

##### File structure
- Top-level crates:
- app: binary that kicks off the MainServiceWorker
- node: core workers (P2P, RPC, Telemetry, TxProcessing, Cryptography)
- db: local storage via Prisma + native code
- db-wasm: same DB logic compiled to WASM for browser/WASI targets
- primitives: shared data structures
- integration-test: end-to-end tests
- scripts: DB codegen (Prisma)
- vane_web3_mvp: front-end (Node.js + Bun) to drive the core wasm in browsers
- Config files: Cargo.toml, Dockerfile, .env, .dockerignore

##### README for additional insights
- Technical components = workers inside the MainServiceWorker orchestrator:
1. DbWorker
2. P2PWorker
3. TxProcessingWorker
4. RpcWorker
5. TelemetryWorker
6. MainServiceWorker
7. Remote Db (Airtable) peer discovery

##### Elements
- Labels: name each crate/worker and external system
- External networks in a third (e.g., clouds for P2P & blockchains)

##### Detailed capture of essential architectural elements
- Link TxProcessingWorker to “Blockchain JSON-RPC endpoints” cloud.
- Link RpcWorker bidirectionally to “Front-end client (JS/WASM)”.
- Link TelemetryWorker back to the Local DB.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend
    subgraph "Frontend/WASM Client"
        direction TB
        FE["Front-end Client (JS/WASM)"]:::frontend
        FE -->|"JSON-RPC API"| RPCW
        FE -->|"WASM DB"| DBWasm
    end

    %% Rust Core Services
    subgraph "Rust Core Services"
        direction TB
        MSW["MainServiceWorker"]:::core
        MSW --> DbW
        MSW --> P2P
        MSW --> TxW
        MSW --> RPCW
        MSW --> TelW
        MSW --> Crypto
    end

    %% Workers
    subgraph "Workers"
        direction TB
        DbW["DbWorker"]:::worker
        P2P["P2PWorker"]:::worker
        TxW["TxProcessingWorker"]:::worker
        RPCW["RpcWorker"]:::worker
        TelW["TelemetryWorker"]:::worker
        Crypto["Cryptography"]:::worker
    end

    %% Data Stores
    DB(["Local DB\n(Prisma + SQLite/Postgres)"]):::db
    DbW --> DB
    TelW --> DB

    %% Remote Services
    PeerNet(["P2P Network\n(libp2p peers)"]):::external
    Airtable(["Airtable\n(peer registry)"]):::external
    P2P --> PeerNet
    P2P --> Airtable

    RPCNode(["Blockchain JSON-RPC\nendpoints"]):::external
    Chain(["Blockchain Network"]):::external
    TxW --> RPCNode
    TxW --> Chain

    %% Core Library & Tools
    subgraph "Rust Core Library & Tools"
        direction TB
        Prims["primitives"]:::library
        DBWasm["db-wasm"]:::library
        Integration["integration-test"]:::external
        Script["DB Codegen Script"]:::script
    end

    %% Click Events
    click FE "https://github.com/2-5-foundation/vane_web3/tree/native/vane_web3_mvp/"
    click MSW "https://github.com/2-5-foundation/vane_web3/blob/native/app/src/main.rs"
    click DbW "https://github.com/2-5-foundation/vane_web3/blob/native/db/src/lib.rs"
    click DB "https://github.com/2-5-foundation/vane_web3/tree/native/db/prisma/"
    click DBWasm "https://github.com/2-5-foundation/vane_web3/blob/native/db-wasm/src/lib.rs"
    click P2P "https://github.com/2-5-foundation/vane_web3/blob/native/node/src/p2p.rs"
    click TxW "https://github.com/2-5-foundation/vane_web3/blob/native/node/src/tx_processing.rs"
    click RPCW "https://github.com/2-5-foundation/vane_web3/blob/native/node/src/rpc.rs"
    click TelW "https://github.com/2-5-foundation/vane_web3/blob/native/node/src/telemetry.rs"
    click Crypto "https://github.com/2-5-foundation/vane_web3/blob/native/node/src/cryptography.rs"
    click Prims "https://github.com/2-5-foundation/vane_web3/blob/native/primitives/src/lib.rs"
    click Integration "https://github.com/2-5-foundation/vane_web3/tree/native/integration-test/"
    click Script "https://github.com/2-5-foundation/vane_web3/blob/native/scripts/db_tests.sh"

    %% Styles
    classDef frontend fill:#fdfd96,stroke:#f0c420,color:#000;
    classDef core fill:#a2cffe,stroke:#3399ff,color:#000;
    classDef worker fill:#cfe2ff,stroke:#6c9eeb,color:#000;
    classDef db fill:#b9f6ca,stroke:#00c853,color:#000;
    classDef external fill:#ffd1dc,stroke:#ff2271,color:#000;
    classDef library fill:#e0e0e0,stroke:#9e9e9e,color:#000;
    classDef script fill:#ffcc80,stroke:#ff6f00,color:#000;
```
