# x-93/rusty-jio architecture

> Architecture diagram of the GitHub repository x-93/rusty-jio, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/x-93/rusty-jio
- Repository: https://github.com/x-93/rusty-jio

## Overview

1. This is a Rust monorepo for a Jio full node plus adjacent libraries and clients. The main runtime is the node executable (`jiopad`), with supporting crates for consensus, P2P networking, RPC, mining, wallet functionality, WASM bindings, CLI tooling, simulation, and integration tests.

2. The central system boundary is the node core: configuration, logging/runtime support, persistence, networking, consensus, and optional services are wired together by the node/daemon layer. The repository also includes separate binaries for client tooling, simulation (`simpa`), and web/Node SDK builds.

3. Consensus is split into a domain layer and a processing pipeline. `consensus/core` defines the block, header, tx, UTXO, hashing, config, and error models. `consensus/src/pipeline` contains staged processors for headers, bodies, virtual state, and pruning, while `consensus/src/processes` implements the actual DAG/chain logic such as GHOSTDAG, reachability, pruning, difficulty, mass, and transaction validation.

4. Consensus state is backed by internal stores under `consensus/src/model/stores`. These are the authoritative read/write models for headers, selected chain, tips, UTXO diffs, virtual state, pruning data, and reachability relations. That is the main persistence boundary between algorithmic processing and durable state.

5. Networking is handled in two layers. `protocol/p2p` provides the low-level peer connection, handshake, routing, and protobuf message conversion. `protocol/flows` builds higher-level protocol behaviors on top of that, including IBD, block relay, tx relay, ping, header/locator requests, pruning-point synchronization, and transaction/orphan flow context management.

6. The node’s event and notification path is separate from the consensus and network state machines. `consensus/notify` and the general `notify` crate implement collectors, broadcasters, subscriptions, and connection abstractions so internal events can be published to external consumers such as RPC clients, wallets, or monitoring tools.

7. Read-side projections live in `indexes/`. `indexes/core` defines notification-driven index infrastructure, `indexes/processor` runs the update pipeline, and `indexes/utxoindex` maintains derived views like indexed UTXOs, supply, and tips. This is a classic “derived read model” boundary: it consumes consensus notifications rather than being part of consensus correctness.

8. Mining is its own subsystem in `mining/`. It includes a mempool, orphan handling, transaction validation, block template building, and template selection. The miner interacts with consensus state and node services to assemble candidate blocks, then submits mined blocks back through the node’s external interface.

9. RPC is layered and multi-targeted. `rpc/core` defines the API model and conversion layer; `rpc/service` adapts consensus/protocol/index data into those APIs; `rpc/grpc` provides generated gRPC server/client infrastructure; and `rpc/wrpc` provides the WebSocket-based JSON/Borsh RPC used by browsers, Node.js, and Rust clients. The README indicates wRPC is optional and the old wRPC→gRPC proxy is deprecated.

10. The wallet is a separate application domain, not just a thin key store. `wallet/core` covers accounts, key management, encrypted local storage, UTXO tracking, transaction generation, fee/mass logic, and RPC integration. `wallet/keys` and `wallet/bip32` provide derivation and key primitives, while `wallet/native` and `wallet/wasm` package the wallet for desktop and browser/Node use.

11. The CLI (`cli/`) is a user-facing shell over the node and wallet subsystems. Its many command modules and wizards suggest it orchestrates account management, network/node control, RPC operations, sending/signing, monitoring, and wallet actions rather than embedding core consensus logic itself.

12. WASM is a major distribution boundary across the repo. There are dedicated WASM crates for consensus, RPC, wallet, and top-level SDK packaging, plus generated TypeScript docs and browser/Node examples. This means the same core logic is intentionally exposed to both native Rust and JavaScript/TypeScript consumers.

13. Shared foundation crates sit underneath most subsystems: `core/` provides runtime/logging/task/signal utilities, `crypto/` contains hash/txscript/merkle/muhash/address primitives, `math/` supplies integer types, `database/` provides the storage abstraction used by node-side persistence, and `metrics/` adds performance monitoring. These are infrastructure layers rather than application flows.

14. Testing and validation are first-class. `simpa` builds an in-process virtual network and DAG for performance/simulation studies, `testing/integration` drives node/RPC/mempool/notification scenarios, and there are benches and fuzz targets across crypto and consensus crates. For an architecture diagram, these are useful as non-production feedback loops around the core node and wallet systems.

Main entry points: [`daemon/src/jiopad/mod.rs`](https://github.com/x-93/rusty-jio/blob/dev/daemon/src/jiopad/mod.rs) (Daemon), [`rpc/service/src/lib.rs`](https://github.com/x-93/rusty-jio/blob/dev/rpc/service/src/lib.rs) (RPC service), [`consensus/src/pipeline/mod.rs`](https://github.com/x-93/rusty-jio/blob/dev/consensus/src/pipeline/mod.rs) (Pipeline), [`notify/src/lib.rs`](https://github.com/x-93/rusty-jio/blob/dev/notify/src/lib.rs) (Notify)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_apps["Apps"]
  node_jiopad["JioPad<br/>node binary<br/>[main.rs]"]
  node_daemon["Daemon<br/>node runtime<br/>[mod.rs]"]
  node_cli["CLI<br/>command shell<br/>[main.rs]"]
end

subgraph group_runtime["Runtime"]
  node_core["Core<br/>runtime support<br/>[lib.rs]"]
  node_database[("Database<br/>storage layer<br/>[lib.rs]")]
end

subgraph group_consensus["Consensus"]
  node_consensus_core["Consensus core<br/>domain model<br/>[lib.rs]"]
  node_consensus_pipeline["Pipeline<br/>staged processing<br/>[mod.rs]"]
  node_consensus_processes["Processes<br/>consensus algorithms<br/>[mod.rs]"]
  node_consensus_stores[("State stores<br/>persistence models<br/>[mod.rs]")]
end

subgraph group_network["Network"]
  node_p2p["P2P<br/>peer networking<br/>[lib.rs]"]
  node_flows["Flows<br/>protocol orchestration<br/>[lib.rs]"]
end

subgraph group_api["APIs"]
  node_notify["Notify<br/>event bus<br/>[lib.rs]"]
  node_rpc_core["RPC core<br/>api model<br/>[lib.rs]"]
  node_rpc_service["RPC service<br/>api adapter<br/>[lib.rs]"]
  node_grpc["gRPC<br/>rpc server<br/>[lib.rs]"]
  node_wrpc["wRPC<br/>web rpc<br/>[lib.rs]"]
  node_indexes["Indexes<br/>derived views<br/>[lib.rs]"]
end

subgraph group_product["Product"]
  node_mining["Mining<br/>template builder<br/>[lib.rs]"]
  node_wallet["Wallet<br/>app domain<br/>[lib.rs]"]
  node_wallet_wasm["Wallet WASM<br/>sdk packaging<br/>[lib.rs]"]
  node_sdk_wasm["Jio WASM<br/>sdk packaging<br/>[lib.rs]"]
end

subgraph group_tooling["Tooling"]
  node_simpa["Simpa<br/>simulator<br/>[main.rs]"]
  node_integration["Integration<br/>test harness<br/>[lib.rs]"]
end

node_jiopad -->|"starts"| node_daemon
node_daemon -->|"uses"| node_core
node_daemon -->|"persists via"| node_database
node_daemon -->|"drives"| node_consensus_pipeline
node_daemon -->|"connects"| node_p2p
node_daemon -->|"orchestrates"| node_flows
node_daemon -->|"publishes"| node_notify
node_daemon -->|"serves"| node_rpc_service
node_daemon -->|"hosts"| node_mining
node_daemon -->|"feeds"| node_indexes
node_consensus_pipeline -->|"validates"| node_consensus_core
node_consensus_pipeline -->|"executes"| node_consensus_processes
node_consensus_processes -->|"reads/writes"| node_consensus_stores
node_consensus_stores -->|"backed by"| node_database
node_p2p -->|"feeds"| node_flows
node_flows -->|"syncs"| node_consensus_pipeline
node_notify -->|"adapts"| node_rpc_core
node_rpc_service -->|"reads"| node_consensus_core
node_rpc_service -->|"reads"| node_indexes
node_rpc_service -->|"subscribes"| node_notify
node_rpc_service -->|"implements"| node_rpc_core
node_rpc_service -->|"serves"| node_grpc
node_rpc_service -->|"serves"| node_wrpc
node_mining -->|"checks"| node_consensus_core
node_mining -->|"submits via"| node_rpc_service
node_wallet -->|"integrates"| node_rpc_core
node_wallet -->|"builds txs"| node_consensus_core
node_wallet_wasm -->|"packages"| node_wallet
node_sdk_wasm -->|"packages"| node_rpc_core
node_simpa -->|"simulates"| node_consensus_pipeline
node_integration -->|"tests"| node_daemon
node_integration -->|"tests"| node_rpc_service
node_integration -->|"tests"| node_notify

click node_jiopad "https://github.com/x-93/rusty-jio/blob/dev/jiopad/src/main.rs"
click node_daemon "https://github.com/x-93/rusty-jio/blob/dev/daemon/src/jiopad/mod.rs"
click node_cli "https://github.com/x-93/rusty-jio/blob/dev/cli/src/main.rs"
click node_core "https://github.com/x-93/rusty-jio/blob/dev/core/src/lib.rs"
click node_database "https://github.com/x-93/rusty-jio/blob/dev/database/src/lib.rs"
click node_consensus_core "https://github.com/x-93/rusty-jio/blob/dev/consensus/core/src/lib.rs"
click node_consensus_pipeline "https://github.com/x-93/rusty-jio/blob/dev/consensus/src/pipeline/mod.rs"
click node_consensus_processes "https://github.com/x-93/rusty-jio/blob/dev/consensus/src/processes/mod.rs"
click node_consensus_stores "https://github.com/x-93/rusty-jio/blob/dev/consensus/src/model/stores/mod.rs"
click node_p2p "https://github.com/x-93/rusty-jio/blob/dev/protocol/p2p/src/lib.rs"
click node_flows "https://github.com/x-93/rusty-jio/blob/dev/protocol/flows/src/lib.rs"
click node_notify "https://github.com/x-93/rusty-jio/blob/dev/notify/src/lib.rs"
click node_rpc_core "https://github.com/x-93/rusty-jio/blob/dev/rpc/core/src/lib.rs"
click node_rpc_service "https://github.com/x-93/rusty-jio/blob/dev/rpc/service/src/lib.rs"
click node_grpc "https://github.com/x-93/rusty-jio/blob/dev/rpc/grpc/server/src/lib.rs"
click node_wrpc "https://github.com/x-93/rusty-jio/blob/dev/rpc/wrpc/server/src/lib.rs"
click node_indexes "https://github.com/x-93/rusty-jio/blob/dev/indexes/processor/src/lib.rs"
click node_mining "https://github.com/x-93/rusty-jio/blob/dev/mining/src/lib.rs"
click node_wallet "https://github.com/x-93/rusty-jio/blob/dev/wallet/core/src/lib.rs"
click node_wallet_wasm "https://github.com/x-93/rusty-jio/blob/dev/wallet/wasm/src/lib.rs"
click node_sdk_wasm "https://github.com/x-93/rusty-jio/blob/dev/wasm/src/lib.rs"
click node_simpa "https://github.com/x-93/rusty-jio/blob/dev/simpa/src/main.rs"
click node_integration "https://github.com/x-93/rusty-jio/blob/dev/testing/integration/src/lib.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_jiopad,node_daemon,node_cli,node_simpa,node_integration toneBlue
class node_core,node_database toneAmber
class node_consensus_core,node_consensus_pipeline,node_consensus_processes,node_consensus_stores toneMint
class node_p2p,node_flows toneRose
class node_notify,node_rpc_core,node_rpc_service,node_grpc,node_wrpc,node_indexes toneIndigo
class node_mining,node_wallet,node_wallet_wasm,node_sdk_wasm toneTeal
```

## Components

### Apps

User-facing binaries and distribution entrypoints

- [JioPad](https://github.com/x-93/rusty-jio/blob/dev/jiopad/src/main.rs): node binary · Main full-node executable and daemon launcher · `jiopad/src/main.rs`
- [Daemon](https://github.com/x-93/rusty-jio/blob/dev/daemon/src/jiopad/mod.rs): node runtime · Wires node services for native and WASM targets · `daemon/src/jiopad/mod.rs`
- [CLI](https://github.com/x-93/rusty-jio/blob/dev/cli/src/main.rs): command shell · User command surface for node and wallet operations · `cli/src/main.rs`

### Runtime

Shared runtime, storage, and support layers

- [Core](https://github.com/x-93/rusty-jio/blob/dev/core/src/lib.rs): runtime support · Logging, tasks, signals, and process utilities · `core/src/lib.rs`
- [Database](https://github.com/x-93/rusty-jio/blob/dev/database/src/lib.rs): storage layer · Persistent storage abstraction and access primitives · `database/src/lib.rs`

### Consensus

Consensus domain, pipeline, algorithms, and state

- [Consensus core](https://github.com/x-93/rusty-jio/blob/dev/consensus/core/src/lib.rs): domain model · Blocks, headers, txs, UTXO, config, and errors · `consensus/core/src/lib.rs`
- [Pipeline](https://github.com/x-93/rusty-jio/blob/dev/consensus/src/pipeline/mod.rs): staged processing · Header, body, virtual, and pruning processors · `consensus/src/pipeline/mod.rs`
- [Processes](https://github.com/x-93/rusty-jio/blob/dev/consensus/src/processes/mod.rs): consensus algorithms · GHOSTDAG, reachability, difficulty, mass, validation, pruning · `consensus/src/processes/mod.rs`
- [State stores](https://github.com/x-93/rusty-jio/blob/dev/consensus/src/model/stores/mod.rs): persistence models · Read/write models backing consensus state and chain views · `consensus/src/model/stores/mod.rs`

### Network

Peer networking and higher-level protocol flows

- [P2P](https://github.com/x-93/rusty-jio/blob/dev/protocol/p2p/src/lib.rs): peer networking · Peer connections, handshake, routing, and protobuf conversion · `protocol/p2p/src/lib.rs`
- [Flows](https://github.com/x-93/rusty-jio/blob/dev/protocol/flows/src/lib.rs): protocol orchestration · IBD, relay, ping, requests, and flow contexts · `protocol/flows/src/lib.rs`

### APIs

Notification and RPC surfaces

- [Notify](https://github.com/x-93/rusty-jio/blob/dev/notify/src/lib.rs): event bus · Collectors, broadcasters, subscriptions, and connection APIs · `notify/src/lib.rs`
- [RPC core](https://github.com/x-93/rusty-jio/blob/dev/rpc/core/src/lib.rs): api model · Shared RPC schemas, conversions, and notification models · `rpc/core/src/lib.rs`
- [RPC service](https://github.com/x-93/rusty-jio/blob/dev/rpc/service/src/lib.rs): api adapter · Bridges consensus, protocol, and index data into RPC operations · `rpc/service/src/lib.rs`
- [gRPC](https://github.com/x-93/rusty-jio/blob/dev/rpc/grpc/server/src/lib.rs): rpc server · Generated gRPC server/client infrastructure · `rpc/grpc/server/src/lib.rs`
- [wRPC](https://github.com/x-93/rusty-jio/blob/dev/rpc/wrpc/server/src/lib.rs): web rpc · WebSocket-based JSON/Borsh RPC for browser, Node, and Rust clients · `rpc/wrpc/server/src/lib.rs`
- [Indexes](https://github.com/x-93/rusty-jio/blob/dev/indexes/processor/src/lib.rs): derived views · Notification-driven read models such as UTXO and supply · `indexes/processor/src/lib.rs`

### Product

Mining, wallet, CLI, and SDK packaging

- [Mining](https://github.com/x-93/rusty-jio/blob/dev/mining/src/lib.rs): template builder · Mempool, orphan handling, block template selection, and submission · `mining/src/lib.rs`
- [Wallet](https://github.com/x-93/rusty-jio/blob/dev/wallet/core/src/lib.rs): app domain · Accounts, keys, storage, UTXO tracking, and transaction generation · `wallet/core/src/lib.rs`
- [Wallet WASM](https://github.com/x-93/rusty-jio/blob/dev/wallet/wasm/src/lib.rs): sdk packaging · Browser and Node packaging for wallet functionality · `wallet/wasm/src/lib.rs`
- [Jio WASM](https://github.com/x-93/rusty-jio/blob/dev/wasm/src/lib.rs): sdk packaging · Top-level WASM distribution and JavaScript examples · `wasm/src/lib.rs`

### Tooling

Simulation and integration validation

- [Simpa](https://github.com/x-93/rusty-jio/blob/dev/simpa/src/main.rs): simulator · In-process network and DAG simulation runtime · `simpa/src/main.rs`
- [Integration](https://github.com/x-93/rusty-jio/blob/dev/testing/integration/src/lib.rs): test harness · End-to-end node, RPC, mempool, and notification scenarios · `testing/integration/src/lib.rs`

## Connections

- JioPad → Daemon: starts · Main executable launches the daemon/node runtime
- Daemon → Core: uses · Daemon depends on shared runtime services
- Daemon → Database: persists via · Node state is backed by the storage layer
- Daemon → Pipeline: drives · Node wires consensus processing into runtime events
- Daemon → P2P: connects · Node exposes peer networking
- Daemon → Flows: orchestrates · Higher-level protocol flows run on top of P2P
- Daemon → Notify: publishes · Internal events are forwarded to subscribers
- Daemon → RPC service: serves · Node data is exposed through RPC services
- Daemon → Mining: hosts · Mining subsystem runs against node services
- Daemon → Indexes: feeds · Consensus notifications drive derived indexes
- Pipeline → Consensus core: validates · Pipeline operates on consensus domain models
- Pipeline → Processes: executes · Processors delegate to core consensus algorithms
- Processes → State stores: reads/writes · Algorithms use durable chain state and views
- State stores → Database: backed by · Consensus state is persisted through the database abstraction
- P2P → Flows: feeds · Peer layer provides transport for protocol behaviors
- Flows → Pipeline: syncs · IBD and relay flows move data into consensus processing
- Notify → RPC core: adapts · Notification events are shaped for external APIs
- RPC service → Consensus core: reads · RPC queries consensus state and models
- RPC service → Indexes: reads · RPC exposes derived read models
- RPC service → Notify: subscribes · RPC streaming builds on the notification bus
- RPC service → RPC core: implements · Service layer realizes the shared RPC API model
- RPC service → gRPC: serves · gRPC server is one RPC transport
- RPC service → wRPC: serves · wRPC is the browser/JS-oriented transport
- Mining → Consensus core: checks · Mining validates candidates against consensus rules
- Mining → RPC service: submits via · Mining interacts with node-facing APIs for block submission
- Wallet → RPC core: integrates · Wallet exposes and consumes RPC-facing models
- Wallet → Consensus core: builds txs · Wallet transaction generation depends on consensus types
- Wallet WASM → Wallet: packages · WASM build exports the wallet domain
- Jio WASM → RPC core: packages · Top-level WASM SDK surfaces RPC and core functionality
- Simpa → Pipeline: simulates · Simulator exercises consensus behavior in-memory
- Integration → Daemon: tests · Integration harness drives the node/daemon runtime
- Integration → RPC service: tests · Integration harness covers RPC behavior
- Integration → Notify: tests · Integration harness covers event delivery and subscriptions
