# carbon-twelve-c12/supernova architecture

> Architecture diagram of the GitHub repository carbon-twelve-c12/supernova, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/carbon-twelve-c12/supernova
- Repository: https://github.com/carbon-twelve-c12/supernova

## Overview

##### Project type and purpose
- From the file tree and README, we see a multi-crate Rust workspace implementing a production-grade Proof-of-Work blockchain called “Supernova.”
- It includes:
- A core blockchain library (btclib) with consensus, cryptography (quantum-resistant), environmental tracking, P2P, mempool, mining, storage, state management, testing.
- A node binary (node/) exposing JSON-RPC, REST and static UI, with middleware and metrics.
- A CLI client (cli/) for admin, wallet, mining commands.
- A wallet application (wallet/) with TUI support.
- A miner service (miner/) for coordinating mining work.
- Testnet orchestrations, Docker/Kubernetes deployment, Helm charts, scripts, docs.
- Purpose: Provide a scalable, carbon-negative, quantum-resistant blockchain platform with on-chain environmental accounting, Lightning layer, wallets, a node API, and production deployments.

##### File structure
- Top-level crates: btclib (core library), node (RPC server + fullnode logic), cli (user CLI), wallet (wallet UI & network), miner (mining coordinator), quantum_validation, testnet, supernova (main binary wrapper).
- Deployment: deployment/, kubernetes/, helm/, Dockerfiles, scripts/ for spinning up testnets, CI/CD workflows in .github/workflows.
- Config files: config/, config.toml, node.example.toml show the node’s runtime settings.
- Documentation under docs/ and btclib/src/docs for architectural and integration guides.
- Pattern: modular Rust crates, separation of concerns (consensus, networking, P2P, crypto, environmental layer). Micro-service style for each binary.

##### README for additional insights
- It calls out core innovations: post-quantum crypto, quantum Lightning, carbon-negative PoW, environmental treasury.

##### Elements
- Clear labels: name each crate/process/module.
- Data flow: e.g., P2P → consensus → storage → API → CLI.
- Control flow: e.g., user invokes CLI → RPC call to Node → Node uses btclib.
- API/RPC components in another (e.g., green).
- UI/CLI in a third (e.g., orange).
- Deployment infra and monitoring in a fourth (e.g., grey).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% On-Chain Core Components
    subgraph "On-Chain Components"
        direction TB
        btclib["Core Blockchain Library<br/>(btclib)"]:::core
        quantum_validation["Quantum Validation Binary<br/>(quantum_validation)"]:::core
    end

    %% Services Layer
    subgraph "Services"
        direction TB
        node_svc["Full Node Service<br/>(node)"]:::api
        miner_svc["Miner Service<br/>(miner)"]:::api
        supernova_bin["Main Binary Wrapper<br/>(supernova)"]:::api
        testnet_orch["Testnet Orchestrator<br/>(testnet)"]:::api
    end

    %% Client Applications
    subgraph "Client Apps"
        direction TB
        cli_app["CLI Client<br/>(cli)"]:::ui
        wallet_app["Wallet Application<br/>(wallet)"]:::ui
    end

    %% Infrastructure and Deployment
    subgraph "Infrastructure & Deployment"
        direction TB
        db["Storage Engine<br/>(RocksDB/Sled)"]:::infra
        oracles["External Oracles / APIs"]:::ext
        monitoring["Monitoring Stack<br/>(Prometheus/Grafana)"]:::infra
        k8s["Kubernetes Cluster"]:::infra
        lb["NGINX Load Balancer"]:::infra
        docker_imgs["Docker Images & Compose<br/>(docker)"]:::infra
        helm_charts["Helm Charts<br/>(kubernetes/helm/supernova & helm/supernova)"]:::infra
        deployment_scripts["Deployment Scripts<br/>(deployment)"]:::infra
        config_files["Config Samples<br/>(config)"]:::infra
        ci_cd["CI/CD Workflows<br/>(.github/workflows)"]:::infra
        docs["Documentation<br/>(docs & btclib/docs)"]:::infra
        testnet_deploy["Testnet Deployments<br/>(deployments/testnet)"]:::infra
    end

    %% Interactions
    cli_app -->|“RPC/REST”| node_svc
    wallet_app -->|“RPC/REST”| node_svc
    miner_svc -->|“RPC: get job / submit block”| node_svc
    node_svc -->|“calls”| btclib
    quantum_validation -->|“used by”| btclib
    node_svc -->|“reads/writes”| db
    node_svc -->|“fetches data”| oracles
    node_svc -->|“exposes metrics”| monitoring
    miner_svc -->|“exposes metrics”| monitoring
    supernova_bin -->|“wraps”| node_svc
    supernova_bin -->|“wraps”| miner_svc
    supernova_bin -->|“wraps”| cli_app
    testnet_orch -->|“orchestrates”| k8s
    k8s -->|“deploys”| node_svc
    k8s -->|“deploys”| miner_svc
    k8s -->|“deploys”| wallet_app
    lb -->|“routes to”| k8s
    docker_imgs -->|“builds for”| node_svc
    docker_imgs -->|“builds for”| miner_svc
    docker_imgs -->|“builds for”| cli_app
    helm_charts -->|“deploys with”| k8s
    deployment_scripts -->|“provisions infra”| k8s
    config_files -->|“configures”| node_svc
    config_files -->|“configures”| miner_svc
    ci_cd -->|“triggers”| docker_imgs
    ci_cd -->|“runs”| deployment_scripts
    docs -->|“describes”| btclib
    testnet_deploy -->|“provisions”| testnet_orch

    %% Click Events
    click btclib "https://github.com/carbon-twelve-c12/supernova/tree/main/btclib/"
    click quantum_validation "https://github.com/carbon-twelve-c12/supernova/tree/main/quantum_validation/"
    click node_svc "https://github.com/carbon-twelve-c12/supernova/tree/main/node/"
    click miner_svc "https://github.com/carbon-twelve-c12/supernova/tree/main/miner/"
    click cli_app "https://github.com/carbon-twelve-c12/supernova/tree/main/cli/"
    click wallet_app "https://github.com/carbon-twelve-c12/supernova/tree/main/wallet/"
    click supernova_bin "https://github.com/carbon-twelve-c12/supernova/tree/main/supernova/"
    click testnet_orch "https://github.com/carbon-twelve-c12/supernova/tree/main/testnet/"
    click deployment_scripts "https://github.com/carbon-twelve-c12/supernova/tree/main/deployment/"
    click helm_charts "https://github.com/carbon-twelve-c12/supernova/tree/main/kubernetes/helm/supernova/"
    click helm_charts "https://github.com/carbon-twelve-c12/supernova/tree/main/helm/supernova/"
    click docker_imgs "https://github.com/carbon-twelve-c12/supernova/tree/main/docker/"
    click config_files "https://github.com/carbon-twelve-c12/supernova/tree/main/config/"
    click ci_cd "https://github.com/carbon-twelve-c12/supernova/tree/main/.github/workflows/"
    click docs "https://github.com/carbon-twelve-c12/supernova/tree/main/docs/"
    click docs "https://github.com/carbon-twelve-c12/supernova/tree/main/btclib/docs/"
    click testnet_deploy "https://github.com/carbon-twelve-c12/supernova/tree/main/deployments/testnet/"

    %% Styles
    classDef core fill:#E3F2FD,stroke:#42A5F5,color:#0D47A1;
    classDef api fill:#E8F5E9,stroke:#66BB6A,color:#1B5E20;
    classDef ui fill:#FFF3E0,stroke:#FFA726,color:#E65100;
    classDef infra fill:#F5F5F5,stroke:#BDBDBD,color:#424242;
    classDef ext fill:#F3E5F5,stroke:#BA68C8,color:#4A148C;
```
