# xparq-labs/xparq architecture

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

- Interactive diagram: https://gitdiagram.com/xparq-labs/xparq
- Repository: https://github.com/xparq-labs/xparq

## Overview

XPARQ is a post-quantum Layer 1 blockchain. Its principal workflow is wallet-authored transaction or program intent, node submission and propagation, kernel validation and state transition, then persistence and synchronization of canonical chain data. The README also describes mining, RPC, shielded capabilities, and the unified coin/asset application. Arrows are limited to caller relationships visible in excerpts or README statements; several runtime internals and some wallet commands are indexed but not sampled, so their links are not inferred.

Main entry points: [`runtime/src/node/mod.rs`](https://github.com/xparq-labs/xparq/blob/main/runtime/src/node/mod.rs) (Node Runtime), [`kernel/src/program/vm_app/engine.rs`](https://github.com/xparq-labs/xparq/blob/main/kernel/src/program/vm_app/engine.rs) (VM Engine), [`kernel/src/ledger`](https://github.com/xparq-labs/xparq/tree/main/kernel/src/ledger) (Ledger State), [`wallet/src/native/program.rs`](https://github.com/xparq-labs/xparq/blob/main/wallet/src/native/program.rs) (Program Commands)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_wallet["Wallet"]
  node_wallet_cli["Wallet CLI<br/>[cli.rs]"]
  node_wallet_program["Program Commands<br/>[program.rs]"]
  node_wallet_transaction["Transaction Builder<br/>[transaction.rs]"]
  node_wallet_main["Wallet Entry<br/>[main.rs]"]
end

subgraph group_node["Node Runtime"]
  node_node_entry["Node Entry<br/>[main.rs]"]
  node_node_run["Node Runtime<br/>[mod.rs]"]
  node_peer["Peer Networking<br/>[peer.rs]"]
  node_sync["Chain Sync<br/>[sync.rs]"]
  node_miner["Mining<br/>[miner.rs]"]
  node_rpc["RPC Service"]
  node_storage[("Chain Storage<br/>[storage.rs]")]
  node_snapshot["Snapshots<br/>[snapshot.rs]"]
end

subgraph group_kernel["Consensus Ledger"]
  node_kernel_blockchain["Block Validation"]
  node_consensus["Consensus"]
  node_ledger[("Ledger State")]
  node_utxo["UTXO State<br/>[utxo.rs]"]
  node_monetary["Coin and Assets"]
  node_shielded["Shielded Transfers<br/>[shielded.rs]"]
end

subgraph group_program["Program Execution"]
  node_applications["Monetary Application<br/>[applications.rs]"]
  node_programs["Program Authorization"]
  node_engine["VM Engine<br/>[engine.rs]"]
  node_vm_storage["Program Storage<br/>[storage.rs]"]
end

subgraph group_crypto["Cryptography"]
  node_crypto_api["Crypto Primitives<br/>[lib.rs]"]
  node_signatures["Signature Schemes<br/>[signature.rs]"]
  node_program_id["Program Identity<br/>[program_id.rs]"]
end

node_user(("User"))

node_user -->|"invokes"| node_wallet_main
node_wallet_main -->|"dispatches"| node_wallet_cli
node_wallet_cli -.->|"routes commands"| node_wallet_program
node_wallet_program -->|"builds transactions"| node_wallet_transaction
node_wallet_main -->|"loads command module"| node_wallet_program
node_node_entry -->|"starts"| node_node_run
node_node_run -.->|"uses networking"| node_peer
node_node_run -.->|"uses synchronization"| node_sync
node_node_run -.->|"configures mining"| node_miner
node_node_run -.->|"uses storage"| node_storage
node_node_run -.->|"uses snapshots"| node_snapshot
node_node_run -.->|"serves RPC"| node_rpc
node_node_run -.->|"validates chain data"| node_kernel_blockchain
node_peer -.->|"exchanges blocks"| node_node_run
node_sync -.->|"updates chain data"| node_storage
node_miner -.->|"submits mined blocks"| node_node_run
node_storage -.->|"persists canonical state"| node_ledger
node_kernel_blockchain -.->|"checks consensus"| node_consensus
node_kernel_blockchain -.->|"applies blocks"| node_ledger
node_ledger -.->|"tracks outputs"| node_utxo
node_ledger -.->|"accounts balances"| node_monetary
node_programs -.->|"invokes VM"| node_engine
node_engine -->|"uses storage decoding"| node_vm_storage
node_engine -->|"mutates invocation state"| node_ledger
node_engine -->|"uses asset journal"| node_utxo
node_applications -->|"executes coin and asset calls"| node_monetary
node_wallet_program -.->|"prepares program actions"| node_programs
node_crypto_api -->|"exports"| node_signatures
node_crypto_api -->|"exports"| node_program_id
node_programs -.->|"authorizes execution"| node_engine

click node_wallet_cli "https://github.com/xparq-labs/xparq/blob/main/wallet/src/native/cli.rs"
click node_wallet_program "https://github.com/xparq-labs/xparq/blob/main/wallet/src/native/program.rs"
click node_wallet_transaction "https://github.com/xparq-labs/xparq/blob/main/wallet/src/native/transaction.rs"
click node_wallet_main "https://github.com/xparq-labs/xparq/blob/main/wallet/src/main.rs"
click node_node_entry "https://github.com/xparq-labs/xparq/blob/main/runtime/src/main.rs"
click node_node_run "https://github.com/xparq-labs/xparq/blob/main/runtime/src/node/mod.rs"
click node_peer "https://github.com/xparq-labs/xparq/blob/main/runtime/src/peer.rs"
click node_sync "https://github.com/xparq-labs/xparq/blob/main/runtime/src/sync.rs"
click node_miner "https://github.com/xparq-labs/xparq/blob/main/runtime/src/miner.rs"
click node_rpc "https://github.com/xparq-labs/xparq/tree/main/runtime/src/node"
click node_storage "https://github.com/xparq-labs/xparq/blob/main/runtime/src/storage.rs"
click node_snapshot "https://github.com/xparq-labs/xparq/blob/main/runtime/src/snapshot.rs"
click node_kernel_blockchain "https://github.com/xparq-labs/xparq/tree/main/kernel/src/blockchain"
click node_consensus "https://github.com/xparq-labs/xparq/tree/main/kernel/src/consensus"
click node_ledger "https://github.com/xparq-labs/xparq/tree/main/kernel/src/ledger"
click node_utxo "https://github.com/xparq-labs/xparq/blob/main/kernel/src/ledger/utxo.rs"
click node_monetary "https://github.com/xparq-labs/xparq/tree/main/kernel/src/monetary"
click node_shielded "https://github.com/xparq-labs/xparq/blob/main/kernel/src/shielded.rs"
click node_applications "https://github.com/xparq-labs/xparq/blob/main/extension/src/applications.rs"
click node_programs "https://github.com/xparq-labs/xparq/tree/main/kernel/src/program"
click node_engine "https://github.com/xparq-labs/xparq/blob/main/kernel/src/program/vm_app/engine.rs"
click node_vm_storage "https://github.com/xparq-labs/xparq/blob/main/kernel/src/program/vm_app/storage.rs"
click node_crypto_api "https://github.com/xparq-labs/xparq/blob/main/crypto/src/lib.rs"
click node_signatures "https://github.com/xparq-labs/xparq/blob/main/crypto/src/signature.rs"
click node_program_id "https://github.com/xparq-labs/xparq/blob/main/crypto/src/program_id.rs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_wallet_cli,node_wallet_program,node_wallet_transaction,node_wallet_main,node_user toneBlue
class node_node_entry,node_node_run,node_peer,node_sync,node_miner,node_rpc,node_storage,node_snapshot toneAmber
class node_kernel_blockchain,node_consensus,node_ledger,node_utxo,node_monetary,node_shielded toneMint
class node_applications,node_programs,node_engine,node_vm_storage toneRose
class node_crypto_api,node_signatures,node_program_id toneIndigo
```

## Components

### Wallet

- [Wallet CLI](https://github.com/xparq-labs/xparq/blob/main/wallet/src/native/cli.rs): `wallet/src/native/cli.rs`
- [Program Commands](https://github.com/xparq-labs/xparq/blob/main/wallet/src/native/program.rs): `wallet/src/native/program.rs`
- [Transaction Builder](https://github.com/xparq-labs/xparq/blob/main/wallet/src/native/transaction.rs): `wallet/src/native/transaction.rs`
- [Wallet Entry](https://github.com/xparq-labs/xparq/blob/main/wallet/src/main.rs): `wallet/src/main.rs`

### Node Runtime

- [Node Entry](https://github.com/xparq-labs/xparq/blob/main/runtime/src/main.rs): `runtime/src/main.rs`
- [Node Runtime](https://github.com/xparq-labs/xparq/blob/main/runtime/src/node/mod.rs): `runtime/src/node/mod.rs`
- [Peer Networking](https://github.com/xparq-labs/xparq/blob/main/runtime/src/peer.rs): `runtime/src/peer.rs`
- [Chain Sync](https://github.com/xparq-labs/xparq/blob/main/runtime/src/sync.rs): `runtime/src/sync.rs`
- [Mining](https://github.com/xparq-labs/xparq/blob/main/runtime/src/miner.rs): `runtime/src/miner.rs`
- [RPC Service](https://github.com/xparq-labs/xparq/tree/main/runtime/src/node): `runtime/src/node`
- [Chain Storage](https://github.com/xparq-labs/xparq/blob/main/runtime/src/storage.rs): `runtime/src/storage.rs`
- [Snapshots](https://github.com/xparq-labs/xparq/blob/main/runtime/src/snapshot.rs): `runtime/src/snapshot.rs`

### Consensus Ledger

- [Block Validation](https://github.com/xparq-labs/xparq/tree/main/kernel/src/blockchain): `kernel/src/blockchain`
- [Consensus](https://github.com/xparq-labs/xparq/tree/main/kernel/src/consensus): `kernel/src/consensus`
- [Ledger State](https://github.com/xparq-labs/xparq/tree/main/kernel/src/ledger): `kernel/src/ledger`
- [UTXO State](https://github.com/xparq-labs/xparq/blob/main/kernel/src/ledger/utxo.rs): `kernel/src/ledger/utxo.rs`
- [Coin and Assets](https://github.com/xparq-labs/xparq/tree/main/kernel/src/monetary): `kernel/src/monetary`
- [Shielded Transfers](https://github.com/xparq-labs/xparq/blob/main/kernel/src/shielded.rs): `kernel/src/shielded.rs`

### Program Execution

- [Monetary Application](https://github.com/xparq-labs/xparq/blob/main/extension/src/applications.rs): `extension/src/applications.rs`
- [Program Authorization](https://github.com/xparq-labs/xparq/tree/main/kernel/src/program): `kernel/src/program`
- [VM Engine](https://github.com/xparq-labs/xparq/blob/main/kernel/src/program/vm_app/engine.rs): `kernel/src/program/vm_app/engine.rs`
- [Program Storage](https://github.com/xparq-labs/xparq/blob/main/kernel/src/program/vm_app/storage.rs): `kernel/src/program/vm_app/storage.rs`

### Cryptography

- [Crypto Primitives](https://github.com/xparq-labs/xparq/blob/main/crypto/src/lib.rs): `crypto/src/lib.rs`
- [Signature Schemes](https://github.com/xparq-labs/xparq/blob/main/crypto/src/signature.rs): `crypto/src/signature.rs`
- [Program Identity](https://github.com/xparq-labs/xparq/blob/main/crypto/src/program_id.rs): `crypto/src/program_id.rs`

### Other components

- **User**

## Connections

- User → Wallet Entry: invokes (evidence: `wallet/src/main.rs`)
- Wallet Entry → Wallet CLI: dispatches (evidence: `wallet/src/main.rs`)
- Wallet CLI → Program Commands: routes commands (evidence: `wallet/src/native/program.rs`)
- Program Commands → Transaction Builder: builds transactions (evidence: `wallet/src/native/program.rs`)
- Wallet Entry → Program Commands: loads command module (evidence: `wallet/src/main.rs`)
- Node Entry → Node Runtime: starts (evidence: `runtime/src/main.rs`)
- Node Runtime → Peer Networking: uses networking
- Node Runtime → Chain Sync: uses synchronization
- Node Runtime → Mining: configures mining
- Node Runtime → Chain Storage: uses storage
- Node Runtime → Snapshots: uses snapshots
- Node Runtime → RPC Service: serves RPC
- Node Runtime → Block Validation: validates chain data
- Peer Networking → Node Runtime: exchanges blocks
- Chain Sync → Chain Storage: updates chain data
- Mining → Node Runtime: submits mined blocks
- Chain Storage → Ledger State: persists canonical state
- Block Validation → Consensus: checks consensus
- Block Validation → Ledger State: applies blocks (evidence: `kernel/src/ledger/mod.rs`)
- Ledger State → UTXO State: tracks outputs (evidence: `kernel/src/ledger/mod.rs`)
- Ledger State → Coin and Assets: accounts balances
- Program Authorization → VM Engine: invokes VM (evidence: `kernel/src/program/vm_app/engine.rs`)
- VM Engine → Program Storage: uses storage decoding (evidence: `kernel/src/program/vm_app/engine.rs`)
- VM Engine → Ledger State: mutates invocation state (evidence: `kernel/src/program/vm_app/engine.rs`)
- VM Engine → UTXO State: uses asset journal (evidence: `kernel/src/program/vm_app/engine.rs`)
- Monetary Application → Coin and Assets: executes coin and asset calls
- Program Commands → Program Authorization: prepares program actions
- Crypto Primitives → Signature Schemes: exports (evidence: `crypto/src/lib.rs`)
- Crypto Primitives → Program Identity: exports (evidence: `crypto/src/lib.rs`)
- Program Authorization → VM Engine: authorizes execution (evidence: `kernel/src/program/vm_app/engine.rs`)
