# ravendevteam/betanet architecture

> Architecture diagram of the GitHub repository ravendevteam/betanet, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ravendevteam/betanet
- Repository: https://github.com/ravendevteam/betanet

## Overview

##### Project type and purpose
- This repository contains only a normative specification (README.md) for “Betanet v1.1,” a fully decentralized, censorship-resistant network replacing the public Internet.
- There is no code here—this is a protocol specification detailing seven layers (L0–L7), cryptographic requirements, transport protocols, mesh overlay, privacy, naming, payments, and governance.

##### Specification’s structure
- Top-level sections mirror the layered network model:
- Layer 0 (Access media)
- Layer 1 (Path selection & routing via SCION + HTX-tunnel)
- Layer 2 (Cover transport “HTX” over TLS+QUIC)
- Layer 3 (Overlay mesh with libp2p-v2, DHT, bitswap)
- Layer 4 (Optional mixnet privacy hop)
- Layer 5 (Naming & trust via self-certifying IDs and 2-of-3 alias ledger)
- Layer 6 (Payments via federated Cashu & Lightning)
- Layer 7 (Applications + governance)
- Each section describes subcomponents (e.g., TLS handshake, Noise XK inner handshake, bootstrap discovery, mixnode selection, alias finalization on 3 blockchains, voucher format, governance quorum).

##### README for additional insights
- Cryptographic primitives and exact handshake/frame formats are specified in §§2,4,5.

##### Essential architectural elements
- Do not decompose into trivial low-level details—use the seven layers as primary components.
- Within each layer, show key subcomponents (e.g., TLS + Noise XK in L2, DHT + bitswap in L3).
- Cross-layer interactions (e.g., governance metrics feed from HTX uptime, payment vouchers flow through HTX and overlay).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Specification Reference
    Spec["Betanet v1.1 Protocol Specification"]:::spec
    click Spec "https://github.com/ravendevteam/betanet/blob/main/README.md"

    %% Client and Server
    Client["Client/Peer Node"]:::endpoint
    Server["Server/Peer Node"]:::endpoint

    %% Layer 0
    subgraph "L0: Access Media"
        direction TB
        L0["Access Media"]:::transport
    end

    %% Layer 1
    subgraph "L1: Path Selection & Routing" 
        direction TB
        SCION["SCION Path Selection"]:::transport
        HTXGW["HTX Gateway"]:::transport
    end

    %% Layer 2
    subgraph "L2: HTX Transport"
        direction TB
        TLS["Outer TLS 1.3 Handshake"]:::transport
        Noise["Inner Noise XK Channel"]:::transport
        QUIC["QUIC Fallback"]:::transport
    end

    %% Layer 3
    subgraph "L3: Overlay Mesh"
        direction TB
        DHT["libp2p DHT Bootstrap"]:::overlay
        Bitswap["Bitswap Block Exchange"]:::overlay
        WebRTC["WebRTC Transport"]:::overlay
    end

    %% Layer 4
    subgraph "L4: Optional Mixnet Privacy Hop"
        direction TB
        Mixnet["Nym Mixnet Hops"]:::overlay
    end

    %% Layer 5
    subgraph "L5: Naming & Trust"
        direction TB
        Alias["Alias Ledger Validator"]:::trust
        subgraph "Blockchains"
            direction TB
            SCIONChain["SCION Ledger"]:::trust
            Filecoin["Filecoin FVM"]:::trust
            Raven["Raven-Names (Ethereum L2)"]:::trust
        end
    end

    %% Layer 6
    subgraph "L6: Payments"
        direction TB
        Cashu["Federated Cashu Mint Cluster"]:::payments
        Lightning["Lightning Network Relay"]:::payments
    end

    %% Layer 7
    subgraph "L7: Applications & Governance"
        direction TB
        Governance["Governance Service"]:::governance
        Apps["Applications"]:::governance
    end

    %% Data Flow Arrows
    Spec --> Client
    Client --> L0 --> SCION --> HTXGW --> TLS --> Noise --> QUIC
    QUIC --> DHT --> Bitswap --> WebRTC --> Mixnet --> Alias --> Cashu --> Governance --> Apps --> Server

    %% Class Definitions
    classDef transport fill:#cce5ff,stroke:#3399ff,color:#000;
    classDef overlay fill:#d4edda,stroke:#28a745,color:#000;
    classDef trust fill:#ffe5b4,stroke:#ff9933,color:#000;
    classDef payments fill:#e2d6f3,stroke:#800080,color:#000;
    classDef governance fill:#f0f0f0,stroke:#6c757d,color:#000;
    classDef endpoint fill:#ffffff,stroke:#343a40,color:#000;
    classDef spec fill:#f8f9fa,stroke:#6c757d,color:#000;
```
