# colakong/soterd architecture

> Architecture diagram of the GitHub repository colakong/soterd, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/colakong/soterd
- Repository: https://github.com/colakong/soterd

## Overview

##### Main Components

a. Core Components:
- BlockDAG Engine (blockdag/)
- Blockchain Legacy Support (blockchain/)
- Network Layer (peer/, wire/, netsync/)
- Memory Pool (mempool/)
- Mining Components (mining/, miningdag/)
- RPC Server (rpcclient/, rpcserver.go)
- Database Layer (database/)

b. Supporting Components:
- Address Manager (addrmgr/)
- Connection Manager (connmgr/)
- Configuration Management (config.go)
- Chain Configuration (chaincfg/)
- Transaction Scripts (txscript/)
- Utilities (soterutil/)

**[Network Layer]**
- ↑↓
**[P2P Components (peer/wire)]**
- ↑↓
**[Core Processing]**
- BlockDAG Engine
- Memory Pool
- Mining Components
- ↑↓
**[Database Layer]**
- ↑↓
**[RPC Interface]**

##### Implementation Details

- Block Processing Pipeline
- Transaction Flow
- Peer Management
- Mining Process
- Database Operations

##### Additional Elements

Annotations for:
- Configuration Options
- Security Mechanisms
- Scaling Considerations
- External Service Integration Points

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph External
        Client1[External Clients]
        Client2[Mining Clients]
    end

    subgraph "RPC Layer"
        RPC_Server["RPC Server"]:::interface
        RPC_Client["RPC Client"]:::interface
    end

    subgraph "Core Processing"
        BlockDAG["BlockDAG Engine"]:::core
        Phantom["Phantom Protocol"]:::core
        Blockchain["Blockchain Legacy"]:::core
        Mempool["Memory Pool"]:::core
        Mining["Mining Service"]:::mining
        MiningDAG["DAG Mining"]:::mining
    end

    subgraph "Network Layer"
        NetSync["Network Sync"]:::network
        Wire["Wire Protocol"]:::network
        Peer["Peer Management"]:::network
        AddrMgr["Address Manager"]:::network
        ConnMgr["Connection Manager"]:::network
    end

    subgraph "Support Components"
        Config["Configuration"]:::util
        ChainCfg["Chain Config"]:::util
        TxScript["Transaction Scripts"]:::util
        Utils["Utilities"]:::util
    end

    subgraph "Storage Layer"
        DB["Database"]:::storage
    end

    %% Connections
    Client1 --> RPC_Server
    Client2 --> RPC_Server
    RPC_Server --> RPC_Client
    RPC_Client --> BlockDAG
    RPC_Client --> Mempool

    BlockDAG --> Phantom
    BlockDAG --> DB
    Blockchain --> DB
    Mempool --> BlockDAG
    Mempool --> Blockchain
    Mining --> Mempool
    MiningDAG --> BlockDAG

    NetSync --> Wire
    Wire --> Peer
    Peer --> AddrMgr
    Peer --> ConnMgr
    Peer --> BlockDAG
    Peer --> Mempool

    Config --> ChainCfg
    TxScript --> BlockDAG
    TxScript --> Blockchain
    Utils --> BlockDAG

    %% Click Events
    click BlockDAG "https://github.com/colakong/soterd/tree/master/blockdag/"
    click Phantom "https://github.com/colakong/soterd/tree/master/blockdag/phantom/"
    click Blockchain "https://github.com/colakong/soterd/tree/master/blockchain/"
    click NetSync "https://github.com/colakong/soterd/tree/master/netsync/"
    click Wire "https://github.com/colakong/soterd/tree/master/wire/"
    click Peer "https://github.com/colakong/soterd/tree/master/peer/"
    click Mempool "https://github.com/colakong/soterd/tree/master/mempool/"
    click Mining "https://github.com/colakong/soterd/tree/master/mining/"
    click MiningDAG "https://github.com/colakong/soterd/tree/master/miningdag/"
    click RPC_Server "https://github.com/colakong/soterd/blob/master/rpcserver.go"
    click RPC_Client "https://github.com/colakong/soterd/tree/master/rpcclient/"
    click DB "https://github.com/colakong/soterd/tree/master/database/"
    click AddrMgr "https://github.com/colakong/soterd/tree/master/addrmgr/"
    click ConnMgr "https://github.com/colakong/soterd/tree/master/connmgr/"
    click Config "https://github.com/colakong/soterd/blob/master/config.go"
    click ChainCfg "https://github.com/colakong/soterd/tree/master/chaincfg/"
    click TxScript "https://github.com/colakong/soterd/tree/master/txscript/"
    click Utils "https://github.com/colakong/soterd/tree/master/soterutil/"

    %% Styles
    classDef core fill:#2374ab
    classDef network fill:#57a773
    classDef storage fill:#ff8c42
    classDef interface fill:#9b5de5
    classDef mining fill:#ef476f
    classDef util fill:#808080

    %% Legend
    subgraph Legend
        L1[Core Components]:::core
        L2[Network Components]:::network
        L3[Storage Components]:::storage
        L4[Interface Components]:::interface
        L5[Mining Components]:::mining
        L6[Utility Components]:::util
    end
```
