# zenmuhamadx/nexchain-new architecture

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

- Interactive diagram: https://gitdiagram.com/zenmuhamadx/nexchain-new
- Repository: https://github.com/zenmuhamadx/nexchain-new

## Overview

Nexchain is a proof-of-work blockchain node with optional P2P synchronization, external mining, a browser wallet, and a blockchain explorer. The principal flow is a user or miner requesting node data or submitting a transaction/work solution through RPC; the node validates and records chain activity, then serves it to clients. README statements and the supplied excerpts support the high-level flow; unsampled internals are shown as capabilities without speculative call chains.

Main entry points: [`wallet/src/App.tsx`](https://github.com/zenmuhamadx/nexchain-new/blob/main/wallet/src/App.tsx) (Wallet Application), [`src/rpc/app/app.ts`](https://github.com/zenmuhamadx/nexchain-new/blob/main/src/rpc/app/app.ts) (RPC Service), [`src/p2p/sync/syncManager.ts`](https://github.com/zenmuhamadx/nexchain-new/blob/main/src/p2p/sync/syncManager.ts) (Chain Synchronization), [`explorer/src/App.tsx`](https://github.com/zenmuhamadx/nexchain-new/blob/main/explorer/src/App.tsx) (Explorer Application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_chain["Chain Runtime"]
  node_node["Node Server<br/>[server.ts]"]
  node_rpc["RPC Service<br/>[app.ts]"]
  node_transactions["Transaction Processing"]
  node_validation["Transaction Validation<br/>[txValidator.v.ts]"]
  node_blockchain["Chain Management<br/>[blockchain.ts]"]
  node_consensus["Consensus Verification<br/>[verifyIntegrity.ts]"]
  node_reorg["Fork Choice<br/>[forkChoice.ts]"]
  node_state[("Persistent State<br/>[init.ts]")]
  node_genesis["Genesis Configuration<br/>[genesis.ts]"]
  node_rpcclient["RPC Client<br/>[rpcClient.ts]"]
end

subgraph group_network["P2P Network"]
  node_peer["Peer Manager<br/>[peerManager.ts]"]
  node_transport["TCP Transport<br/>[server.ts]"]
  node_protocol["P2P Messages<br/>[messages.ts]"]
  node_sync["Chain Synchronization<br/>[syncManager.ts]"]
end

subgraph group_mining["Mining"]
  node_work["Mining Work<br/>[work.ts]"]
  node_minerui["Miner Interface<br/>[useMiner.ts]"]
end

subgraph group_wallet["Wallet"]
  node_walletapp["Wallet Application<br/>[App.tsx]"]
  node_vault[("Wallet Vault<br/>[walletVault.ts]")]
  node_send["Send Flow<br/>[sendFlow.ts]"]
  node_crypto["Wallet Cryptography<br/>[crypto.worker.ts]"]
end

subgraph group_explorer["Explorer"]
  node_explorerapp["Explorer Application<br/>[App.tsx]"]
  node_explorerpages["Explorer Pages<br/>[DashboardPage.tsx]"]
  node_explorerrpc["Explorer RPC Client<br/>[rpcClient.ts]"]
  node_explorerstate["Chain State Polling<br/>[useChainState.ts]"]
end

node_user(("User"))
node_miner(("External Miner"))

node_user -->|"manages assets"| node_walletapp
node_user -->|"views chain"| node_explorerapp
node_miner -->|"submits work"| node_rpc
node_node -->|"serves RPC"| node_rpc
node_rpc -->|"provides work"| node_work
node_rpc -.->|"accepts transactions"| node_transactions
node_transactions -.->|"validates"| node_validation
node_blockchain -->|"checks integrity"| node_consensus
node_blockchain -.->|"selects branch"| node_reorg
node_genesis -->|"initializes chain"| node_node
node_walletapp -->|"loads vault"| node_vault
node_walletapp -.->|"routes sending"| node_send
node_walletapp -.->|"uses worker"| node_crypto
node_walletapp -.->|"requests account data"| node_rpcclient
node_explorerapp -->|"routes pages"| node_explorerpages
node_explorerapp -->|"shares chain state"| node_explorerstate
node_explorerstate -->|"fetches chain data"| node_explorerrpc
node_explorerpages -->|"requests records"| node_explorerrpc
node_explorerrpc -.->|"calls node"| node_rpc
node_peer -->|"opens connections"| node_transport
node_peer -->|"handles handshake"| node_protocol
node_sync -->|"exchanges messages"| node_protocol
node_sync -->|"loads mempool"| node_state
node_sync -.->|"broadcasts inventory"| node_peer

click node_node "https://github.com/zenmuhamadx/nexchain-new/blob/main/apps/node/server.ts"
click node_rpc "https://github.com/zenmuhamadx/nexchain-new/blob/main/src/rpc/app/app.ts"
click node_transactions "https://github.com/zenmuhamadx/nexchain-new/blob/main/src/core/transaction/processTransaction.ts"
click node_validation "https://github.com/zenmuhamadx/nexchain-new/blob/main/src/core/validation/txValidator.v.ts"
click node_blockchain "https://github.com/zenmuhamadx/nexchain-new/blob/main/src/core/blockchain/blockchain.ts"
click node_consensus "https://github.com/zenmuhamadx/nexchain-new/blob/main/src/core/consensus/verify/verifyIntegrity.ts"
click node_reorg "https://github.com/zenmuhamadx/nexchain-new/blob/main/src/core/consensus/reorg/forkChoice.ts"
click node_state "https://github.com/zenmuhamadx/nexchain-new/blob/main/src/core/state/db/init.ts"
click node_genesis "https://github.com/zenmuhamadx/nexchain-new/blob/main/src/core/block/genesis.ts"
click node_rpcclient "https://github.com/zenmuhamadx/nexchain-new/blob/main/src/client/rpc-client/lib/rpcClient.ts"
click node_peer "https://github.com/zenmuhamadx/nexchain-new/blob/main/src/p2p/peers/peerManager.ts"
click node_transport "https://github.com/zenmuhamadx/nexchain-new/blob/main/src/p2p/transport/server.ts"
click node_protocol "https://github.com/zenmuhamadx/nexchain-new/blob/main/src/p2p/protocol/messages.ts"
click node_sync "https://github.com/zenmuhamadx/nexchain-new/blob/main/src/p2p/sync/syncManager.ts"
click node_work "https://github.com/zenmuhamadx/nexchain-new/blob/main/src/core/consensus/work.ts"
click node_minerui "https://github.com/zenmuhamadx/nexchain-new/blob/main/miner-ui/src/hooks/useMiner.ts"
click node_walletapp "https://github.com/zenmuhamadx/nexchain-new/blob/main/wallet/src/App.tsx"
click node_vault "https://github.com/zenmuhamadx/nexchain-new/blob/main/src/client/wallet/walletVault.ts"
click node_send "https://github.com/zenmuhamadx/nexchain-new/blob/main/wallet/src/lib/sendFlow.ts"
click node_crypto "https://github.com/zenmuhamadx/nexchain-new/blob/main/wallet/src/workers/crypto.worker.ts"
click node_explorerapp "https://github.com/zenmuhamadx/nexchain-new/blob/main/explorer/src/App.tsx"
click node_explorerpages "https://github.com/zenmuhamadx/nexchain-new/blob/main/explorer/src/pages/DashboardPage.tsx"
click node_explorerrpc "https://github.com/zenmuhamadx/nexchain-new/blob/main/explorer/src/api/rpcClient.ts"
click node_explorerstate "https://github.com/zenmuhamadx/nexchain-new/blob/main/explorer/src/hooks/useChainState.ts"

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_node,node_rpc,node_transactions,node_validation,node_blockchain,node_consensus,node_reorg,node_state,node_genesis,node_rpcclient,node_user toneBlue
class node_peer,node_transport,node_protocol,node_sync toneAmber
class node_work,node_minerui toneMint
class node_walletapp,node_vault,node_send,node_crypto toneRose
class node_explorerapp,node_explorerpages,node_explorerrpc,node_explorerstate,node_miner toneIndigo
```

## Components

### Chain Runtime

- [Node Server](https://github.com/zenmuhamadx/nexchain-new/blob/main/apps/node/server.ts): `apps/node/server.ts`
- [RPC Service](https://github.com/zenmuhamadx/nexchain-new/blob/main/src/rpc/app/app.ts): `src/rpc/app/app.ts`
- [Transaction Processing](https://github.com/zenmuhamadx/nexchain-new/blob/main/src/core/transaction/processTransaction.ts): `src/core/transaction/processTransaction.ts`
- [Transaction Validation](https://github.com/zenmuhamadx/nexchain-new/blob/main/src/core/validation/txValidator.v.ts): `src/core/validation/txValidator.v.ts`
- [Chain Management](https://github.com/zenmuhamadx/nexchain-new/blob/main/src/core/blockchain/blockchain.ts): `src/core/blockchain/blockchain.ts`
- [Consensus Verification](https://github.com/zenmuhamadx/nexchain-new/blob/main/src/core/consensus/verify/verifyIntegrity.ts): `src/core/consensus/verify/verifyIntegrity.ts`
- [Fork Choice](https://github.com/zenmuhamadx/nexchain-new/blob/main/src/core/consensus/reorg/forkChoice.ts): `src/core/consensus/reorg/forkChoice.ts`
- [Persistent State](https://github.com/zenmuhamadx/nexchain-new/blob/main/src/core/state/db/init.ts): `src/core/state/db/init.ts`
- [Genesis Configuration](https://github.com/zenmuhamadx/nexchain-new/blob/main/src/core/block/genesis.ts): `src/core/block/genesis.ts`
- [RPC Client](https://github.com/zenmuhamadx/nexchain-new/blob/main/src/client/rpc-client/lib/rpcClient.ts): `src/client/rpc-client/lib/rpcClient.ts`

### P2P Network

- [Peer Manager](https://github.com/zenmuhamadx/nexchain-new/blob/main/src/p2p/peers/peerManager.ts): `src/p2p/peers/peerManager.ts`
- [TCP Transport](https://github.com/zenmuhamadx/nexchain-new/blob/main/src/p2p/transport/server.ts): `src/p2p/transport/server.ts`
- [P2P Messages](https://github.com/zenmuhamadx/nexchain-new/blob/main/src/p2p/protocol/messages.ts): `src/p2p/protocol/messages.ts`
- [Chain Synchronization](https://github.com/zenmuhamadx/nexchain-new/blob/main/src/p2p/sync/syncManager.ts): `src/p2p/sync/syncManager.ts`

### Mining

- [Mining Work](https://github.com/zenmuhamadx/nexchain-new/blob/main/src/core/consensus/work.ts): `src/core/consensus/work.ts`
- [Miner Interface](https://github.com/zenmuhamadx/nexchain-new/blob/main/miner-ui/src/hooks/useMiner.ts): `miner-ui/src/hooks/useMiner.ts`

### Wallet

- [Wallet Application](https://github.com/zenmuhamadx/nexchain-new/blob/main/wallet/src/App.tsx): `wallet/src/App.tsx`
- [Wallet Vault](https://github.com/zenmuhamadx/nexchain-new/blob/main/src/client/wallet/walletVault.ts): `src/client/wallet/walletVault.ts`
- [Send Flow](https://github.com/zenmuhamadx/nexchain-new/blob/main/wallet/src/lib/sendFlow.ts): `wallet/src/lib/sendFlow.ts`
- [Wallet Cryptography](https://github.com/zenmuhamadx/nexchain-new/blob/main/wallet/src/workers/crypto.worker.ts): `wallet/src/workers/crypto.worker.ts`

### Explorer

- [Explorer Application](https://github.com/zenmuhamadx/nexchain-new/blob/main/explorer/src/App.tsx): `explorer/src/App.tsx`
- [Explorer Pages](https://github.com/zenmuhamadx/nexchain-new/blob/main/explorer/src/pages/DashboardPage.tsx): `explorer/src/pages/DashboardPage.tsx`
- [Explorer RPC Client](https://github.com/zenmuhamadx/nexchain-new/blob/main/explorer/src/api/rpcClient.ts): `explorer/src/api/rpcClient.ts`
- [Chain State Polling](https://github.com/zenmuhamadx/nexchain-new/blob/main/explorer/src/hooks/useChainState.ts): `explorer/src/hooks/useChainState.ts`

### Other components

- **User**
- **External Miner**

## Connections

- User → Wallet Application: manages assets (evidence: `README.md`)
- User → Explorer Application: views chain (evidence: `README.md`)
- External Miner → RPC Service: submits work (evidence: `README.md`)
- Node Server → RPC Service: serves RPC (evidence: `README.md`)
- RPC Service → Mining Work: provides work (evidence: `README.md`)
- RPC Service → Transaction Processing: accepts transactions
- Transaction Processing → Transaction Validation: validates
- Chain Management → Consensus Verification: checks integrity (evidence: `README.md`)
- Chain Management → Fork Choice: selects branch
- Genesis Configuration → Node Server: initializes chain (evidence: `README.md`)
- Wallet Application → Wallet Vault: loads vault (evidence: `wallet/src/App.tsx`)
- Wallet Application → Send Flow: routes sending
- Wallet Application → Wallet Cryptography: uses worker
- Wallet Application → RPC Client: requests account data
- Explorer Application → Explorer Pages: routes pages (evidence: `explorer/src/App.tsx`)
- Explorer Application → Chain State Polling: shares chain state (evidence: `explorer/src/App.tsx`)
- Chain State Polling → Explorer RPC Client: fetches chain data (evidence: `explorer/src/hooks/useChainState.ts`)
- Explorer Pages → Explorer RPC Client: requests records (evidence: `explorer/src/pages/DashboardPage.tsx`)
- Explorer RPC Client → RPC Service: calls node
- Peer Manager → TCP Transport: opens connections (evidence: `src/p2p/peers/peerManager.ts`)
- Peer Manager → P2P Messages: handles handshake (evidence: `src/p2p/peers/peerManager.ts`)
- Chain Synchronization → P2P Messages: exchanges messages (evidence: `src/p2p/sync/syncManager.ts`)
- Chain Synchronization → Persistent State: loads mempool (evidence: `src/p2p/sync/syncManager.ts`)
- Chain Synchronization → Peer Manager: broadcasts inventory
