# bitgesellofficial/bitgesell architecture

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

- Interactive diagram: https://gitdiagram.com/bitgesellofficial/bitgesell
- Repository: https://github.com/bitgesellofficial/bitgesell

## Overview

##### Project type and purpose
- Bitgesell (BGL) is a full-node cryptocurrency client forked from Bitcoin Core. It comprises:
- A P2P network node and consensus engine
- A chainstate & UTXO database
- A wallet subsystem
- Multiple interfaces (CLI, RPC/REST/HTTP, ZeroMQ, Qt GUI)
- Embedded cryptographic libraries (secp256k1, libunivalue, LevelDB, minisketch)

##### File structure
- Top-level binaries in src/ (BGLd daemon, BGL-cli, BGL-tx, BGL-qt GUI, BGL-wallet, BGL-util).
- src/net*, src/net_processing: P2P transport & messaging
- src/kernel & src/consensus & src/validation: block/transaction validation pipeline
- src/index & src/chainstate: persistent indexing & UTXO sets via LevelDB & flat files
- src/wallet: on-node wallet management & BDB/SQLite backends
- src/rpc, src/httprpc, src/rest, src/zmq: server interfaces over JSON-RPC, REST, ZeroMQ
- src/ipc: Cap’n Proto IPC for multi-process support
- src/qt: graphical UI depending on Qt layer
- External libs under src/secp256k1, src/leveldb, src/univalue, src/minisketch

##### README for additional insights
- Confirms it’s a digital currency full-node.
- Highlights cryptographic modules, build options, and optional modules (Schnorr, ECDH).
- Lists features: P2P, consensus, RPC, wallet, GUI, testing, CI pipelines.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User Interfaces
    subgraph "User Interfaces"
        CLI["CLI Frontends"]:::ui
        TX["BGL-tx"]:::ui
        GUI["Qt GUI"]:::ui
    end

    %% Interfaces Layer
    subgraph "Interfaces Layer"
        RPC["JSON-RPC Server"]:::interface
        REST["REST/HTTP Server"]:::interface
        ZMQ["ZeroMQ Pub/Sub"]:::interface
        IPC["Cap’n Proto IPC"]:::interface
    end

    %% Core Engine
    subgraph "Core Engine"
        subgraph "P2P Network Layer"
            NET["Net Modules"]:::core
            NP["Net Processing"]:::core
            NODECONN["Node Connection Types"]:::core
        end
        subgraph "Consensus & Validation"
            CONS["Consensus Engine"]:::core
            VAL["Validation"]:::core
            KER["Kernel"]:::core
        end
        MEM["Mempool"]:::core
        subgraph "Wallet Subsystem"
            WALLY["Wallet Subsystem"]:::core
        end
        subgraph "Storage & Indexing"
            IDX["Block Index"]:::storage
            CHAIN["Chainstate/UTXO DB"]:::storage
        end
    end

    %% Cryptography & Utilities
    subgraph "Cryptography & Utilities"
        SECP["secp256k1 Library"]:::lib
        LVL["LevelDB"]:::lib
        UV["UniValue JSON Parser"]:::lib
        MS["MiniSketch"]:::lib
        CRC["CRC32C"]:::lib
        CRYPT["Core Crypto Helpers"]:::lib
    end

    %% Connections
    CLI -->|invokes| RPC
    TX -->|invokes| RPC
    GUI -->|uses| RPC
    RPC -->|calls| CONS
    REST -->|calls| CONS
    ZMQ -->|publishes| WALLY
    IPC -->|commands| CONS

    NET -->|feeds| CONS
    NP -->|feeds| CONS
    CONS -->|validates| VAL
    VAL -->|executes| KER
    CONS -->|updates| IDX
    CONS -->|updates| CHAIN
    VAL -->|enqueues| MEM
    MEM -->|notifies| WALLY
    CONS <-->|syncs| WALLY

    %% Libraries usage
    CONS --> SECP
    CONS --> MS
    CONS --> CRC
    WALLY --> LVL
    IDX --> LVL
    CHAIN --> LVL
    RPC --> UV
    REST --> UV

    %% Click Events
    click NET "https://github.com/bitgesellofficial/bitgesell/blob/master/src/net.cpp"
    click NP "https://github.com/bitgesellofficial/bitgesell/blob/master/src/net_processing.cpp"
    click NODECONN "https://github.com/bitgesellofficial/bitgesell/blob/master/src/node/connection_types.h"
    click CONS "https://github.com/bitgesellofficial/bitgesell/blob/master/src/consensus/consensus.h"
    click VAL "https://github.com/bitgesellofficial/bitgesell/blob/master/src/validation.cpp"
    click KER "https://github.com/bitgesellofficial/bitgesell/blob/master/src/kernel/BGLkernel.cpp"
    click IDX "https://github.com/bitgesellofficial/bitgesell/blob/master/src/index/txindex.cpp"
    click CHAIN "https://github.com/bitgesellofficial/bitgesell/blob/master/src/node/chainstate.cpp"
    click WALLY "https://github.com/bitgesellofficial/bitgesell/tree/master/src/wallet/"
    click RPC "https://github.com/bitgesellofficial/bitgesell/blob/master/src/rpc/server.cpp"
    click REST "https://github.com/bitgesellofficial/bitgesell/blob/master/src/rest.cpp"
    click ZMQ "https://github.com/bitgesellofficial/bitgesell/blob/master/src/zmq/zmqnotificationinterface.cpp"
    click IPC "https://github.com/bitgesellofficial/bitgesell/blob/master/src/ipc/process.cpp"
    click GUI "https://github.com/bitgesellofficial/bitgesell/tree/master/src/qt/"
    click CLI "https://github.com/bitgesellofficial/bitgesell/blob/master/src/BGL-cli.cpp"
    click TX "https://github.com/bitgesellofficial/bitgesell/blob/master/src/BGL-tx.cpp"
    click SECP "https://github.com/bitgesellofficial/bitgesell/tree/master/src/secp256k1/"
    click LVL "https://github.com/bitgesellofficial/bitgesell/tree/master/src/leveldb/"
    click UV "https://github.com/bitgesellofficial/bitgesell/tree/master/src/univalue/"
    click MS "https://github.com/bitgesellofficial/bitgesell/tree/master/src/minisketch/"
    click CRC "https://github.com/bitgesellofficial/bitgesell/tree/master/src/crc32c/"
    click CRYPT "https://github.com/bitgesellofficial/bitgesell/blob/master/src/crypto/aes.cpp"

    %% Styles
    classDef ui fill:#f9f,stroke:#333,stroke-width:1px
    classDef interface fill:#9f9,stroke:#333,stroke-width:1px
    classDef core fill:#ff9,stroke:#333,stroke-width:1px
    classDef storage fill:#9ff,stroke:#333,stroke-width:1px
    classDef lib fill:#ccc,stroke:#333,stroke-width:1px
```
