# devprosvn/vnprider architecture

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

- Interactive diagram: https://gitdiagram.com/devprosvn/vnprider
- Repository: https://github.com/devprosvn/vnprider

## Overview

##### Project Type and Purpose
- This is a Layer-1 blockchain implementation (“VNPrider Blockchain – Hào Khí Việt Nam”) with military-grade security, a Vietnamese-centric mnemonic system, and a novel VN-PoA consensus mechanism.
- It targets use in defense-sector contexts, exposing both RPC API endpoints and a CLI for node operators/administrators.

##### File Structure
- Top‐level modules:
- api: HTTP/gRPC handlers and server entrypoint (api/server.go)
- cli: command-line interface for interacting with the node (cli/commands.go)
- config: loading and validating config parameters (config/config.go)
- consensus: VN-PoA algorithm (validator.go, vnpoa.go)
- core: on-chain objects and blockchain management (block.go, blockchain.go, transaction.go, merkle.go)
- crypto: key derivation, hashing, signatures, Vietnamese mnemonic support (address.go, hash.go, signature.go, mnemonic.go)
- network: P2P message formats and peer communication (message.go, p2p.go)
- storage: persistence of blocks and world state (blockchain.go, worldstate.go)
- types: shared type definitions and interfaces
- wordlist: Vietnamese mnemonic word list
- There is also an “export” directory containing the same modules for packaging as a standalone library or separate binary (“export/main.go”), indicating this code can be consumed or built independently.

##### README for Additional Insights
- Confirms the modular breakdown above.
- Emphasizes “military-grade security,” “Vietnamese mnemonic,” and “VN-PoA consensus.”
- Install/run instructions point to main.go which likely initializes all modules and spins up API + P2P node.

## Diagram (Mermaid)

```mermaid
flowchart TB
  subgraph "Blockchain Node"
    direction TB
    subgraph "User Interface"
      direction TB
      CLI["CLI Tool"]:::user
      APIHandlers["API Handlers"]:::user
      APIServer["API Server"]:::user
    end

    subgraph "Configuration & Types"
      direction TB
      Config["Configuration Loader"]:::logic
      TypesBlock["Types: Block"]:::logic
      TypesInterfaces["Types: Interfaces"]:::logic
      TypesTransaction["Types: Transaction"]:::logic
    end

    subgraph "Business Logic"
      direction TB
      subgraph CoreLogic["Core Blockchain Logic"]
        direction TB
        CoreBlock["Block"]:::logic
        CoreBlockchain["Blockchain"]:::logic
        CoreTransaction["Transaction"]:::logic
        CoreMerkle["Merkle"]:::logic
      end
      subgraph CryptoMod["Cryptography Module"]
        direction TB
        CryptoAddress["Address"]:::logic
        CryptoHash["Hash"]:::logic
        CryptoSignature["Signature"]:::logic
        CryptoMnemonic["Mnemonic"]:::logic
      end
      subgraph ConsensusEng["Consensus Engine"]
        direction TB
        Validator["Validator"]:::logic
        VNPOA["VN-PoA"]:::logic
      end
    end

    subgraph "Infrastructure"
      direction TB
      StorageBlockchain["Storage: Blockchain DB"]:::infra
      StorageWorld["Storage: World State"]:::infra
      NetworkMod["Networking (P2P)"]:::infra
      Wordlist["Vietnamese Wordlist"]:::infra
    end
  end

  subgraph "P2P Network"
    direction TB
    Cloud[/"P2P Network"/]:::infra
  end

  subgraph "Export Layer"
    direction TB
    ExportMain["export/main.go"]:::packaging
  end

  %% Relationships
  CLI -->|"submit tx"| CoreTransaction
  APIHandlers -->|"routes tx"| APIServer
  APIServer -->|"calls"| CoreTransaction
  Config -->|provides settings| CryptoMod
  Config -->|provides settings| ConsensusEng
  Config -->|provides settings| NetworkMod

  TypesBlock --> CoreBlock
  TypesInterfaces --> Validator
  TypesInterfaces --> CoreBlockchain
  TypesTransaction --> CoreTransaction

  CryptoAddress --> CoreBlock
  CryptoHash --> CoreMerkle
  CryptoSignature --> Validator
  CryptoMnemonic --> CoreTransaction
  Wordlist --> CryptoMnemonic

  CoreBlock --> CoreBlockchain
  CoreTransaction --> CoreBlockchain
  CoreMerkle --> CoreBlockchain

  CoreBlockchain --> StorageBlockchain
  CoreBlockchain --> StorageWorld

  ConsensusEng -->|broadcast| NetworkMod
  NetworkMod -->|receive| Validator
  NetworkMod -->|receive tx/block| CoreBlockchain

  StorageBlockchain -->|read/write| CoreBlockchain
  StorageWorld -->|read/write| CoreBlockchain

  Cloud --> NetworkMod

  ExportMain --> CLI
  ExportMain --> APIServer
  ExportMain --> Config
  ExportMain --> CoreBlock
  ExportMain --> CryptoAddress

  %% Click Events
  click CLI "https://github.com/devprosvn/vnprider/blob/main/cli/commands.go"
  click APIHandlers "https://github.com/devprosvn/vnprider/blob/main/api/handlers.go"
  click APIServer "https://github.com/devprosvn/vnprider/blob/main/api/server.go"
  click Config "https://github.com/devprosvn/vnprider/blob/main/config/config.go"
  click Validator "https://github.com/devprosvn/vnprider/blob/main/consensus/validator.go"
  click VNPOA "https://github.com/devprosvn/vnprider/blob/main/consensus/vnpoa.go"
  click CoreBlock "https://github.com/devprosvn/vnprider/blob/main/core/block.go"
  click CoreBlockchain "https://github.com/devprosvn/vnprider/blob/main/core/blockchain.go"
  click CoreTransaction "https://github.com/devprosvn/vnprider/blob/main/core/transaction.go"
  click CoreMerkle "https://github.com/devprosvn/vnprider/blob/main/core/merkle.go"
  click CryptoAddress "https://github.com/devprosvn/vnprider/blob/main/crypto/address.go"
  click CryptoHash "https://github.com/devprosvn/vnprider/blob/main/crypto/hash.go"
  click CryptoSignature "https://github.com/devprosvn/vnprider/blob/main/crypto/signature.go"
  click CryptoMnemonic "https://github.com/devprosvn/vnprider/blob/main/crypto/mnemonic.go"
  click Wordlist "https://github.com/devprosvn/vnprider/blob/main/wordlist/vietnamese_wordlist.go"
  click NetworkMod "https://github.com/devprosvn/vnprider/blob/main/network/p2p.go"
  click StorageBlockchain "https://github.com/devprosvn/vnprider/blob/main/storage/blockchain.go"
  click StorageWorld "https://github.com/devprosvn/vnprider/blob/main/storage/worldstate.go"
  click TypesBlock "https://github.com/devprosvn/vnprider/blob/main/types/block.go"
  click TypesInterfaces "https://github.com/devprosvn/vnprider/blob/main/types/interfaces.go"
  click TypesTransaction "https://github.com/devprosvn/vnprider/blob/main/types/transaction.go"
  click ExportMain "https://github.com/devprosvn/vnprider/blob/main/export/main.go"

  %% Styles
  classDef user fill:#f9f,stroke:#333,stroke-width:1px
  classDef logic fill:#bbf,stroke:#333,stroke-width:1px
  classDef infra fill:#bfb,stroke:#333,stroke-width:1px
  classDef packaging fill:#ffd,stroke:#333,stroke-width:1px
```
