# blv-labs/whitelist-wallet architecture

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

- Interactive diagram: https://gitdiagram.com/blv-labs/whitelist-wallet
- Repository: https://github.com/blv-labs/whitelist-wallet

## Overview

##### Project Type & Purpose
- This is a blockchain protocol implementation (the reference implementation for the Terra protocol) which serves as a node daemon (terrad) for interacting with the blockchain network.
- It includes a variety of modules for handling accounts, governance, staking, market functions, oracle updates, treasury, upgrade mechanisms, and smart contracts (through WASM integrations).

##### Top-Level Architectural Layers/Components
- Client / CLI: The “cmd/terrad” directory defines the entry point for the node and includes commands for initialization, key management, querying, transaction submission, and other chain operations.
- Application Layer: The “app” directory holds the main Terra application logic (app.go, modules.go, encoding, and upgrade support). This layer aggregates the various modules and governs the chain’s state transitions.
- Modules: These are the core components implementing blockchain functionalities:
- Custom modules in “custom/” (e.g., auth, bank, gov, distribution, staking, wasm, etc.)
- Standard modules often found under “x/” (e.g., market, oracle, treasury, vesting, etc.)
- Each module contains its own keeper, types, and simulation tests for state management.
- Consensus & Networking:
- Integration with Tendermint (as per the README for launching “terrad start” and the various configuration files for P2P/RPC ports).
- Configuration files and Docker scripts (such as Dockerfile, docker-compose.yml, and scripts) support deployment, monitoring, and scalability.
- Proto Definitions: The “proto” directory holds protocol buffer files that define the APIs and data structures used in inter-module and network communications.
- Testing and Simulation: Unit test files, simulation test scripts (present in directories like “app/sim_test.go”, “contrib/localnet”, “tests”, “scripts”) demonstrate how components interact during network operations.
- Build/Deployment & DevOps: Files including Makefile, Docker-related files, GitHub workflows, and CI configuration indicate the build, linting, release, test, and deployment pipelines.

##### Relationships & Data Flow
- The terrad binary (from “cmd/terrad”) launches the application. It initializes the blockchain’s state (via “app/app.go”) and then registers various modules.
- Modules interact with each other through well-defined interfaces (keepers, routers) and data flow through transactions and queries.
- Consensus is handled by Tendermint. Show how state transitions trigger consensus rounds and then update the state maintained in the application.
- RPC and REST interfaces (exposed on ports like 26657 for RPC, 1317 for LCD) that serve as external communication channels to interact with your node.
- The Docker and compose configurations demonstrate how container orchestration and deployment integrate with the blockchain node.

##### Design Patterns & Technologies
- Modular architecture: The clear separation of blockchain modules (accounts, banking, staking, governance) follows a typical Cosmos SDK pattern.
- Client-Server model: The terrad CLI communicates with the node’s local daemons.
- Protobuf/gRPC communication: The “proto” directory and generated code (e.g., in “custom/auth/tx”, “x/dyncomm”, etc.) underline the usage of protocol buffers to ensure robust data serialization across modules.
- DevOps Pipelines: CI/CD workflows and Docker configurations facilitate automated testing, linting, and deployment.

##### Putting It All Together
– Attach the CLI and API endpoints to the node to represent external interactions.
– Inside the node, compartmentalize the Application Layer into individual modules (list them explicitly: auth, bank, governance, market, oracle, treasury, staking, wasm, etc.).
– Show the Tendermint component on the side to illustrate consensus operations.
– Optionally, include a section for “Build & Deployment” showing Docker, CI/CD pipelines, and scripts that help in building, testing, and deploying the node.
– Make sure to use directional flow symbols to represent the sequence from transaction submission, module processing, block formation, and network consensus.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Terra Node Subgraph
    subgraph "Terra Node"
        direction TB
        NodeCLI["Node Daemon (terrad) & CLI"] 
        AppLayer["Application Layer (Terra Core)"]
        Consensus["Consensus Engine (Tendermint)"]
        RPC["RPC/REST API Interface"]
        Proto["Proto Definitions"]
        
        %% Custom Modules Subgraph
        subgraph "Custom Modules"
            direction TB
            CustomAuth["Auth Module"]
            CustomBank["Bank Module"]
            CustomGov["Gov Module"]
            CustomStaking["Staking Module"]
            CustomWASM["WASM Module"]
        end

        %% Standard Modules Subgraph
        subgraph "Standard Modules"
            direction TB
            StandardMarket["Market Module"]
            StandardOracle["Oracle Module"]
            StandardTreasury["Treasury Module"]
            StandardVesting["Vesting Module"]
        end
    end

    %% Build & Deployment & DevOps Subgraph
    subgraph "Build & Deployment & DevOps"
        direction TB
        CI_CD["CI/CD Pipelines"]
        Docker["Docker & Compose"]
    end

    %% Testing & Simulation Subgraph
    subgraph "Testing & Simulation"
        direction TB
        TestSim["Unit & Simulation Tests"]
    end

    %% Connections among Terra Node components
    NodeCLI -->|"launches"| AppLayer
    AppLayer -->|"triggers"| Consensus
    Consensus -->|"updates"| AppLayer
    NodeCLI -->|"handles"| RPC

    %% Registering Modules from Application Layer
    AppLayer -->|"registers"| CustomAuth
    AppLayer -->|"registers"| CustomBank
    AppLayer -->|"registers"| CustomGov
    AppLayer -->|"registers"| CustomStaking
    AppLayer -->|"registers"| CustomWASM
    AppLayer -->|"integrates"| StandardMarket
    AppLayer -->|"integrates"| StandardOracle
    AppLayer -->|"integrates"| StandardTreasury
    AppLayer -->|"integrates"| StandardVesting

    %% Modules interface with Proto Definitions
    CustomAuth -->|"defines"| Proto
    StandardMarket -->|"defines"| Proto

    %% External Build & Deployment and Testing integrations
    CI_CD -->|"deploys"| NodeCLI
    Docker -->|"orchestrates"| NodeCLI
    TestSim -->|"validates"| NodeCLI

    %% Click Events
    click NodeCLI "https://github.com/blv-labs/whitelist-wallet/tree/main/cmd/terrad"
    click AppLayer "https://github.com/blv-labs/whitelist-wallet/tree/main/app"
    click CustomAuth "https://github.com/blv-labs/whitelist-wallet/blob/main/custom/auth/module.go"
    click CustomBank "https://github.com/blv-labs/whitelist-wallet/blob/main/custom/bank/module.go"
    click CustomGov "https://github.com/blv-labs/whitelist-wallet/blob/main/custom/gov/module.go"
    click CustomStaking "https://github.com/blv-labs/whitelist-wallet/blob/main/custom/staking/module.go"
    click CustomWASM "https://github.com/blv-labs/whitelist-wallet/blob/main/custom/wasm/module.go"
    click StandardMarket "https://github.com/blv-labs/whitelist-wallet/tree/main/x/market"
    click StandardOracle "https://github.com/blv-labs/whitelist-wallet/tree/main/x/oracle"
    click StandardTreasury "https://github.com/blv-labs/whitelist-wallet/tree/main/x/treasury"
    click StandardVesting "https://github.com/blv-labs/whitelist-wallet/tree/main/x/vesting"
    click Consensus "https://github.com/blv-labs/whitelist-wallet/blob/main/scripts/run-node.sh"
    click RPC "https://github.com/blv-labs/whitelist-wallet/tree/main/client/docs"
    click Proto "https://github.com/blv-labs/whitelist-wallet/tree/main/proto"
    click CI_CD "https://github.com/blv-labs/whitelist-wallet/tree/main/.github/workflows"
    click Docker "https://github.com/blv-labs/whitelist-wallet/tree/main/Dockerfile"
    click TestSim "https://github.com/blv-labs/whitelist-wallet/tree/main/tests"

    %% Styling
    class NodeCLI,AppLayer,Consensus,RPC,Proto fill:#f9f,stroke:#333,stroke-width:2px;
    class CustomAuth,CustomBank,CustomGov,CustomStaking,CustomWASM fill:#bbf,stroke:#333,stroke-width:2px;
    class StandardMarket,StandardOracle,StandardTreasury,StandardVesting fill:#bbf,stroke:#333,stroke-width:2px;
    class CI_CD,Docker fill:#cfc,stroke:#333,stroke-width:2px;
    class TestSim fill:#fc9,stroke:#333,stroke-width:2px;
```
