# mariusjabami/byte architecture

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

- Interactive diagram: https://gitdiagram.com/mariusjabami/byte
- Repository: https://github.com/mariusjabami/byte

## Overview

This repository implements a C proof-of-stake blockchain node and wallet workflow, though the README describes BYTE Chain while sampled runtime output calls it LibreX Chain. The principal workflow is wallet creation or loading, transaction signing and mempool admission, then validator block production and peer broadcast. The graph also preserves documented networking, synchronization, fork resolution, and slashing capabilities. Relationships are limited to sampled calls, source-index references, or README claims; some documented capabilities lack a clearly identifiable implementation path in the available evidence.

Main entry points: [`src/consensus.c`](https://github.com/mariusjabami/byte/blob/main/src/consensus.c) (Stake consensus), [`src/p2p.c`](https://github.com/mariusjabami/byte/blob/main/src/p2p.c) (P2P protocol), [`src/main.c`](https://github.com/mariusjabami/byte/blob/main/src/main.c) (Node entry), [`src/chain.c`](https://github.com/mariusjabami/byte/blob/main/src/chain.c) (Chain storage)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Wallet and client"]
  node_runtime["Node entry<br/>[main.c]"]
  node_wallet["Wallet keys<br/>[wallet.c]"]
end

subgraph group_ledger["Ledger and economics"]
  node_transaction["Transactions<br/>[transaction.c]"]
  node_mempool["Mempool<br/>[mempool.c]"]
  node_chain[("Chain storage<br/>[chain.c]")]
  node_balances[("Balances<br/>[balance.c]")]
  node_tokenomics["Tokenomics<br/>[tokenomics.c]"]
  node_block["Block structure<br/>[block.c]"]
end

subgraph group_consensus["Validation and consensus"]
  node_consensus["Stake consensus<br/>[consensus.c]"]
  node_crypto["Cryptography<br/>[crypto_utils.c]"]
  node_slashing["Slashing<br/>[consensus.c]"]
end

subgraph group_network["Peer network"]
  node_p2p["P2P protocol<br/>[p2p.c]"]
  node_gossip["Peer gossip<br/>[gossip.c]"]
end

node_user(("Wallet user"))
node_peers(("Peer nodes"))

node_user -->|"runs commands"| node_runtime
node_runtime -->|"loads or creates"| node_wallet
node_runtime -->|"creates"| node_transaction
node_runtime -->|"submits"| node_mempool
node_runtime -->|"starts validation"| node_consensus
node_runtime -->|"starts networking"| node_p2p
node_wallet -->|"derives keys"| node_crypto
node_consensus -->|"selects transactions"| node_mempool
node_consensus -->|"reads and adds blocks"| node_chain
node_consensus -->|"broadcasts blocks"| node_p2p
node_consensus -->|"uses rewards"| node_tokenomics
node_consensus -->|"uses balances"| node_balances
node_consensus -.->|"detects double-sign"| node_slashing
node_p2p -->|"exchanges messages"| node_peers
node_p2p -->|"shares peer lists"| node_gossip
node_peers -->|"sends blocks"| node_p2p
node_peers -->|"sends transactions"| node_p2p
node_p2p -.->|"requests sync blocks"| node_chain
node_chain -->|"stores blocks"| node_block

click node_runtime "https://github.com/mariusjabami/byte/blob/main/src/main.c"
click node_wallet "https://github.com/mariusjabami/byte/blob/main/src/wallet.c"
click node_transaction "https://github.com/mariusjabami/byte/blob/main/src/transaction.c"
click node_mempool "https://github.com/mariusjabami/byte/blob/main/src/mempool.c"
click node_chain "https://github.com/mariusjabami/byte/blob/main/src/chain.c"
click node_balances "https://github.com/mariusjabami/byte/blob/main/src/balance.c"
click node_tokenomics "https://github.com/mariusjabami/byte/blob/main/src/tokenomics.c"
click node_block "https://github.com/mariusjabami/byte/blob/main/src/block.c"
click node_consensus "https://github.com/mariusjabami/byte/blob/main/src/consensus.c"
click node_crypto "https://github.com/mariusjabami/byte/blob/main/src/crypto_utils.c"
click node_p2p "https://github.com/mariusjabami/byte/blob/main/src/p2p.c"
click node_gossip "https://github.com/mariusjabami/byte/blob/main/src/gossip.c"
click node_slashing "https://github.com/mariusjabami/byte/blob/main/src/consensus.c"

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_runtime,node_wallet,node_user toneBlue
class node_transaction,node_mempool,node_chain,node_balances,node_tokenomics,node_block toneAmber
class node_consensus,node_crypto,node_slashing toneMint
class node_p2p,node_gossip toneRose
class node_peers toneIndigo
```

## Components

### Wallet and client

- [Node entry](https://github.com/mariusjabami/byte/blob/main/src/main.c): `src/main.c`
- [Wallet keys](https://github.com/mariusjabami/byte/blob/main/src/wallet.c): `src/wallet.c`

### Ledger and economics

- [Transactions](https://github.com/mariusjabami/byte/blob/main/src/transaction.c): `src/transaction.c`
- [Mempool](https://github.com/mariusjabami/byte/blob/main/src/mempool.c): `src/mempool.c`
- [Chain storage](https://github.com/mariusjabami/byte/blob/main/src/chain.c): `src/chain.c`
- [Balances](https://github.com/mariusjabami/byte/blob/main/src/balance.c): `src/balance.c`
- [Tokenomics](https://github.com/mariusjabami/byte/blob/main/src/tokenomics.c): `src/tokenomics.c`
- [Block structure](https://github.com/mariusjabami/byte/blob/main/src/block.c): `src/block.c`

### Validation and consensus

- [Stake consensus](https://github.com/mariusjabami/byte/blob/main/src/consensus.c): `src/consensus.c`
- [Cryptography](https://github.com/mariusjabami/byte/blob/main/src/crypto_utils.c): `src/crypto_utils.c`
- [Slashing](https://github.com/mariusjabami/byte/blob/main/src/consensus.c): `src/consensus.c`

### Peer network

- [P2P protocol](https://github.com/mariusjabami/byte/blob/main/src/p2p.c): `src/p2p.c`
- [Peer gossip](https://github.com/mariusjabami/byte/blob/main/src/gossip.c): `src/gossip.c`

### Other components

- **Wallet user**
- **Peer nodes**

## Connections

- Wallet user → Node entry: runs commands (evidence: `src/main.c`)
- Node entry → Wallet keys: loads or creates (evidence: `src/main.c`)
- Node entry → Transactions: creates (evidence: `src/main.c`)
- Node entry → Mempool: submits (evidence: `src/main.c`)
- Node entry → Stake consensus: starts validation (evidence: `src/main.c`)
- Node entry → P2P protocol: starts networking (evidence: `src/main.c`)
- Wallet keys → Cryptography: derives keys (evidence: `src/wallet.c`)
- Stake consensus → Mempool: selects transactions (evidence: `src/consensus.c`)
- Stake consensus → Chain storage: reads and adds blocks (evidence: `src/consensus.c`)
- Stake consensus → P2P protocol: broadcasts blocks (evidence: `src/consensus.c`)
- Stake consensus → Tokenomics: uses rewards (evidence: `src/consensus.c`)
- Stake consensus → Balances: uses balances (evidence: `src/consensus.c`)
- Stake consensus → Slashing: detects double-sign (evidence: `README.md`)
- P2P protocol → Peer nodes: exchanges messages (evidence: `README.md`)
- P2P protocol → Peer gossip: shares peer lists (evidence: `src/gossip.c`)
- Peer nodes → P2P protocol: sends blocks (evidence: `README.md`)
- Peer nodes → P2P protocol: sends transactions (evidence: `README.md`)
- P2P protocol → Chain storage: requests sync blocks (evidence: `README.md`)
- Chain storage → Block structure: stores blocks
