# rubixchain/rubixgoplatform architecture

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

- Interactive diagram: https://gitdiagram.com/rubixchain/rubixgoplatform
- Repository: https://github.com/rubixchain/rubixgoplatform

## Overview

##### Main Components and How They Interact
- Command/CLI Layer:
– Represents the entry point for all commands (e.g., run, ping, addbootstrap, createdid, transferrbt, etc.).
– This component interprets the command line parameters and routes them to the underlying modules.

- Core Business Logic:
– Found primarily under the “core” directory, which includes configuration handling, token operations, block and transaction validation, DID management, wallet functions, and storage interfaces.
– This is the heart of the Rubix node that processes transactions, performs cryptographic validations (with “crypto”), executes DID operations (“did”), and manages blockchain data.
– There are also specialized sub-modules, such as “pubsub” for handling publish/subscribe mechanisms and “service” that might be used for the explorer service or other network services.

- Blockchain/Transaction/Smart Contract Layer:
– Represented by directories like “block”, “contract”, “token”, and parts of “core” that concentrate on token chain validation, block creation, and smart contracts.
– The design must indicate how blocks and transactions are generated, verified, and stored.

- Networking and External Communication:
– Components such as “grpcserver”, “grpcclient”, “wrapper/ensweb”, and “protos” indicate that gRPC-based communication is supported.
– This layer will show interactions where the CLI and core business logic interact with external peers (adding bootstrap peers, pinging, etc.) and external services like explorer nodes.

- Auxiliary/Utility Modules:
– Packages including “crypto”, “nlss”, “util”, and “wrapper” provide supporting functionalities like cryptography routines, password handling, JSON utilities, logging, and error wrapping.
– These support many higher-level actions and are essential for operations like DID creation and token transfers.

- Testing and DevOps:
– The project also has a “tests” directory with unit and integration tests (including Docker-related testing), and a set of deployment workflows in “.github/workflows” for CI/CD.
– While not part of the runtime architecture, their existence emphasizes robust testing and deployment practices.

##### Relationships and Architectural Patterns
- The CLI interface (commands such as “run”, “ping”, etc.) are the user’s entry points. They trigger various actions in the core logic.
- The core logic acts as a central hub that coordinates with other modules (blockchain processing, DID operations, token transfers).
- Many modules use shared models and configuration from the “core/config” and “core/model” directories, indicating a design that centralizes business rules.
- The networking components (gRPC server/client, channels for peer-to-peer communication) interact with external systems and are decoupled via protocol buffers defined in “protos”.
- Patterns like separation of concerns and modularization are evident; each directory encapsulates a set of responsibilities (for instance, “client” vs “server” functionality).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% CLI/Command Interface
    subgraph "CLI/Command Interface"
        CLI1["Command (command)"]:::cli
        CLI2["Client (client)"]:::cli
        CLI3["gRPC Client (grpcclient)"]:::cli
    end

    %% Core Business Logic
    subgraph "Core Business Logic"
        CORE["Core Engine (core)"]:::core
        CORE_CONF["Config (core/config)"]:::core
        CORE_MODEL["Model (core/model)"]:::core
        CORE_PUBSUB["PubSub (core/pubsub)"]:::core
        CORE_SVC["Service (core/service)"]:::core
        CORE_WLT["Wallet (core/wallet)"]:::core
    end

    %% Blockchain Components
    subgraph "Blockchain Components"
        BC_BLOCK["Block (block)"]:::blockchain
        BC_CONTRACT["Contract (contract)"]:::blockchain
        BC_TOKEN["Token (token)"]:::blockchain
    end

    %% Networking & External Communication
    subgraph "Networking & External Communication"
        NET_SRV["gRPC Server (grpcserver)"]:::network
        NET_PROTO["Protos (protos)"]:::network
        NET_ENS["ENS Web Wrapper (wrapper/ensweb)"]:::network
    end

    %% Cryptography & Identity
    subgraph "Cryptography & Identity"
        CRYPTO["Crypto (crypto)"]:::crypto
        DID["DID (did)"]:::crypto
    end

    %% Auxiliary/Utility Modules
    subgraph "Auxiliary/Utility Modules"
        AUX_NLSS["NLSS (nlss)"]:::aux
        AUX_UTIL["Util (util)"]:::aux
        AUX_WRAPPER["Wrapper (adapter/logger etc.)"]:::aux
    end

    %% Testing & DevOps
    subgraph "Testing & DevOps"
        TESTS["Tests (tests)"]:::test
        WORKFLOWS["GitHub Workflows (.github/workflows)"]:::test
    end

    %% Connections
    %% CLI to Core Business Logic
    CLI1 -->|"triggers"| CORE
    CLI2 -->|"triggers"| CORE
    CLI3 -->|"calls"| NET_SRV

    %% Core internal connections
    CORE --> CORE_CONF
    CORE --> CORE_MODEL
    CORE --> CORE_PUBSUB
    CORE --> CORE_SVC
    CORE --> CORE_WLT

    %% Core to Blockchain Components
    CORE -->|"processes"| BC_BLOCK
    CORE -->|"processes"| BC_CONTRACT
    CORE -->|"processes"| BC_TOKEN

    %% Core to Cryptography & Identity
    CORE -->|"executes"| CRYPTO
    CORE -->|"executes"| DID

    %% Core to Networking
    CORE -->|"communicates"| NET_SRV

    %% Networking internal connection
    NET_SRV -->|"defines"| NET_PROTO
    NET_ENS -->|"integrates"| CORE

    %% Core uses Auxiliary modules
    CORE -->|"utilizes"| AUX_UTIL
    CORE -->|"logs/errors"| AUX_WRAPPER
    CORE -->|"assists"| AUX_NLSS

    %% Testing & DevOps supports all layers (illustrative)
    TESTS --- CORE
    TESTS --- NET_SRV
    WORKFLOWS --- TESTS

    %% Styles
    classDef cli fill:#B3E5FC,stroke:#0277BD,stroke-width:2px;
    classDef core fill:#C8E6C9,stroke:#2E7D32,stroke-width:2px;
    classDef blockchain fill:#F8BBD0,stroke:#880E4F,stroke-width:2px;
    classDef network fill:#FFECB3,stroke:#F57F17,stroke-width:2px;
    classDef crypto fill:#FFF9C4,stroke:#F9A825,stroke-width:2px;
    classDef aux fill:#E1BEE7,stroke:#6A1B9A,stroke-width:2px;
    classDef test fill:#CFD8DC,stroke:#37474F,stroke-width:2px;

    %% Click Events
    click CLI1 "https://github.com/rubixchain/rubixgoplatform/blob/main/command/command.go"
    click CLI2 "https://github.com/rubixchain/rubixgoplatform/blob/main/client/client.go"
    click CLI3 "https://github.com/rubixchain/rubixgoplatform/blob/main/grpcclient/main.go"
    click CORE "https://github.com/rubixchain/rubixgoplatform/tree/main/core/"
    click BC_BLOCK "https://github.com/rubixchain/rubixgoplatform/tree/main/block/"
    click BC_CONTRACT "https://github.com/rubixchain/rubixgoplatform/blob/main/contract/contract.go"
    click BC_TOKEN "https://github.com/rubixchain/rubixgoplatform/blob/main/token/token_auth.go"
    click NET_SRV "https://github.com/rubixchain/rubixgoplatform/blob/main/grpcserver/grpc.go"
    click NET_PROTO "https://github.com/rubixchain/rubixgoplatform/tree/main/protos/"
    click NET_ENS "https://github.com/rubixchain/rubixgoplatform/tree/main/wrapper/ensweb/"
    click CRYPTO "https://github.com/rubixchain/rubixgoplatform/blob/main/crypto/crypto.go"
    click DID "https://github.com/rubixchain/rubixgoplatform/blob/main/did/did.go"
    click AUX_NLSS "https://github.com/rubixchain/rubixgoplatform/tree/main/nlss/"
    click AUX_UTIL "https://github.com/rubixchain/rubixgoplatform/blob/main/util/util.go"
    click AUX_WRAPPER "https://github.com/rubixchain/rubixgoplatform/tree/main/wrapper/adapter"
    click TESTS "https://github.com/rubixchain/rubixgoplatform/tree/main/tests/"
    click WORKFLOWS "https://github.com/rubixchain/rubixgoplatform/tree/main/.github/workflows/"
```
