# nhudoannana/trustmebro-blockchain architecture

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

- Interactive diagram: https://gitdiagram.com/nhudoannana/trustmebro-blockchain
- Repository: https://github.com/nhudoannana/trustmebro-blockchain

## Overview

TrustProfile is an educational Streamlit application for issuing, revoking, and verifying credentials on an in-memory blockchain simulation. Its primary workflow runs from issuer wallet and signed credential transaction through node validation and mempool, mining into a Merkle-rooted block, and network consensus; a verifier then checks the credential, while the attack simulator demonstrates tamper detection. The graph includes the documented demo pages and core engine. Network internals and several page implementations were not sampled, so those relationships rely on README documentation rather than source-level inspection.

Main entry points: [`blockchain/blockchain.py`](https://github.com/nhudoannana/trustmebro-blockchain/blob/main/blockchain/blockchain.py) (Credential ledger), [`blockchain/transaction.py`](https://github.com/nhudoannana/trustmebro-blockchain/blob/main/blockchain/transaction.py) (Credential transactions), [`blockchain/node.py`](https://github.com/nhudoannana/trustmebro-blockchain/blob/main/blockchain/node.py) (Three-node network), [`blockchain/mempool.py`](https://github.com/nhudoannana/trustmebro-blockchain/blob/main/blockchain/mempool.py) (Transaction mempool)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Streamlit experience"]
  node_app["Dashboard and navigation<br/>[app.py]"]
  node_state["Shared session state<br/>[state.py]"]
  node_wallet_page["Wallet demo<br/>[2_Wallet.py]"]
  node_transaction_page["Transaction demo<br/>[3_Transaction.py]"]
  node_mempool_page["Mempool demo<br/>[4_Mempool.py]"]
  node_merkle_page["Merkle visualization<br/>[5_Merkle.py]"]
  node_explorer_page["Blockchain explorer<br/>[6_Explorer.py]"]
  node_mining_page["Mining demo<br/>[7_Mining.py]"]
  node_network_page["Network demo<br/>[8_Network.py]"]
  node_flow_page["Mining and consensus<br/>[9_Mining_Flow.py]"]
  node_verify_page["Credential verification<br/>[10_Verify.py]"]
  node_attacks_page["Attack simulator<br/>[11_Attacks.py]"]
end

subgraph group_credentials["Credential security"]
  node_hash["SHA-256<br/>[hash.py]"]
  node_wallet["ECDSA wallet<br/>[wallet.py]"]
  node_transaction["Credential transactions<br/>[transaction.py]"]
  node_mempool["Transaction mempool<br/>[mempool.py]"]
end

subgraph group_ledger["Chain and mining"]
  node_merkle["Merkle tree and proofs<br/>[merkle.py]"]
  node_block["Block and header<br/>[block.py]"]
  node_mining["Proof of Work<br/>[mining.py]"]
  node_blockchain[("Credential ledger<br/>[blockchain.py]")]
end

subgraph group_network["Node network"]
  node_network["Three-node network<br/>[node.py]"]
end

node_issuer(("Issuer"))
node_holder(("Holder"))
node_verifier(("Verifier"))

node_app -->|"initializes state"| node_state
node_state -->|"creates shared network"| node_network
node_issuer -->|"creates signing wallet"| node_wallet_page
node_holder -->|"receives credential"| node_transaction_page
node_wallet_page -->|"demonstrates keys"| node_wallet
node_transaction_page -->|"creates and signs"| node_transaction
node_transaction -->|"signs via"| node_wallet
node_transaction -->|"hashes canonical data"| node_hash
node_wallet -->|"derives address"| node_hash
node_transaction -->|"submitted for validation"| node_mempool
node_mempool -->|"verifies transaction"| node_transaction
node_mempool_page -->|"demonstrates management"| node_mempool
node_network -->|"maintains per-node pools"| node_mempool
node_flow_page -->|"submits and broadcasts"| node_network
node_network_page -->|"shows node status"| node_network
node_network -->|"maintains node chains"| node_blockchain
node_flow_page -->|"demonstrates consensus flow"| node_blockchain
node_blockchain -->|"manages blocks"| node_block
node_blockchain -->|"validates credentials"| node_transaction
node_blockchain -->|"verifies Merkle proofs"| node_merkle
node_block -->|"calculates root"| node_merkle
node_block -->|"hashes header"| node_hash
node_blockchain -->|"checks proof of work"| node_mining
node_mining_page -->|"demonstrates mining"| node_mining
node_merkle_page -->|"visualizes proofs"| node_merkle
node_explorer_page -->|"explores and validates"| node_blockchain
node_verifier -->|"requests credential check"| node_verify_page
node_verify_page -->|"runs 12-step verification"| node_blockchain
node_attacks_page -->|"demonstrates tampering"| node_blockchain
node_attacks_page -->|"demonstrates validation attacks"| node_mempool
node_attacks_page -->|"demonstrates PoW tampering"| node_mining
node_attacks_page -->|"demonstrates root tampering"| node_merkle
node_hash -->|"hashes tree pairs"| node_merkle

click node_app "https://github.com/nhudoannana/trustmebro-blockchain/blob/main/app.py"
click node_state "https://github.com/nhudoannana/trustmebro-blockchain/blob/main/state.py"
click node_wallet_page "https://github.com/nhudoannana/trustmebro-blockchain/blob/main/pages/2_Wallet.py"
click node_transaction_page "https://github.com/nhudoannana/trustmebro-blockchain/blob/main/pages/3_Transaction.py"
click node_mempool_page "https://github.com/nhudoannana/trustmebro-blockchain/blob/main/pages/4_Mempool.py"
click node_merkle_page "https://github.com/nhudoannana/trustmebro-blockchain/blob/main/pages/5_Merkle.py"
click node_explorer_page "https://github.com/nhudoannana/trustmebro-blockchain/blob/main/pages/6_Explorer.py"
click node_mining_page "https://github.com/nhudoannana/trustmebro-blockchain/blob/main/pages/7_Mining.py"
click node_network_page "https://github.com/nhudoannana/trustmebro-blockchain/blob/main/pages/8_Network.py"
click node_flow_page "https://github.com/nhudoannana/trustmebro-blockchain/blob/main/pages/9_Mining_Flow.py"
click node_verify_page "https://github.com/nhudoannana/trustmebro-blockchain/blob/main/pages/10_Verify.py"
click node_attacks_page "https://github.com/nhudoannana/trustmebro-blockchain/blob/main/pages/11_Attacks.py"
click node_hash "https://github.com/nhudoannana/trustmebro-blockchain/blob/main/blockchain/hash.py"
click node_wallet "https://github.com/nhudoannana/trustmebro-blockchain/blob/main/blockchain/wallet.py"
click node_transaction "https://github.com/nhudoannana/trustmebro-blockchain/blob/main/blockchain/transaction.py"
click node_mempool "https://github.com/nhudoannana/trustmebro-blockchain/blob/main/blockchain/mempool.py"
click node_merkle "https://github.com/nhudoannana/trustmebro-blockchain/blob/main/blockchain/merkle.py"
click node_block "https://github.com/nhudoannana/trustmebro-blockchain/blob/main/blockchain/block.py"
click node_mining "https://github.com/nhudoannana/trustmebro-blockchain/blob/main/blockchain/mining.py"
click node_blockchain "https://github.com/nhudoannana/trustmebro-blockchain/blob/main/blockchain/blockchain.py"
click node_network "https://github.com/nhudoannana/trustmebro-blockchain/blob/main/blockchain/node.py"

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_app,node_state,node_wallet_page,node_transaction_page,node_mempool_page,node_merkle_page,node_explorer_page,node_mining_page,node_network_page,node_flow_page,node_verify_page,node_attacks_page toneBlue
class node_hash,node_wallet,node_transaction,node_mempool toneAmber
class node_merkle,node_block,node_mining,node_blockchain toneMint
class node_network toneRose
class node_issuer,node_holder,node_verifier toneIndigo
```

## Components

### Streamlit experience

- [Dashboard and navigation](https://github.com/nhudoannana/trustmebro-blockchain/blob/main/app.py): `app.py`
- [Shared session state](https://github.com/nhudoannana/trustmebro-blockchain/blob/main/state.py): `state.py`
- [Wallet demo](https://github.com/nhudoannana/trustmebro-blockchain/blob/main/pages/2_Wallet.py): `pages/2_Wallet.py`
- [Transaction demo](https://github.com/nhudoannana/trustmebro-blockchain/blob/main/pages/3_Transaction.py): `pages/3_Transaction.py`
- [Mempool demo](https://github.com/nhudoannana/trustmebro-blockchain/blob/main/pages/4_Mempool.py): `pages/4_Mempool.py`
- [Merkle visualization](https://github.com/nhudoannana/trustmebro-blockchain/blob/main/pages/5_Merkle.py): `pages/5_Merkle.py`
- [Blockchain explorer](https://github.com/nhudoannana/trustmebro-blockchain/blob/main/pages/6_Explorer.py): `pages/6_Explorer.py`
- [Mining demo](https://github.com/nhudoannana/trustmebro-blockchain/blob/main/pages/7_Mining.py): `pages/7_Mining.py`
- [Network demo](https://github.com/nhudoannana/trustmebro-blockchain/blob/main/pages/8_Network.py): `pages/8_Network.py`
- [Mining and consensus](https://github.com/nhudoannana/trustmebro-blockchain/blob/main/pages/9_Mining_Flow.py): `pages/9_Mining_Flow.py`
- [Credential verification](https://github.com/nhudoannana/trustmebro-blockchain/blob/main/pages/10_Verify.py): `pages/10_Verify.py`
- [Attack simulator](https://github.com/nhudoannana/trustmebro-blockchain/blob/main/pages/11_Attacks.py): `pages/11_Attacks.py`

### Credential security

- [SHA-256](https://github.com/nhudoannana/trustmebro-blockchain/blob/main/blockchain/hash.py): `blockchain/hash.py`
- [ECDSA wallet](https://github.com/nhudoannana/trustmebro-blockchain/blob/main/blockchain/wallet.py): `blockchain/wallet.py`
- [Credential transactions](https://github.com/nhudoannana/trustmebro-blockchain/blob/main/blockchain/transaction.py): `blockchain/transaction.py`
- [Transaction mempool](https://github.com/nhudoannana/trustmebro-blockchain/blob/main/blockchain/mempool.py): `blockchain/mempool.py`

### Chain and mining

- [Merkle tree and proofs](https://github.com/nhudoannana/trustmebro-blockchain/blob/main/blockchain/merkle.py): `blockchain/merkle.py`
- [Block and header](https://github.com/nhudoannana/trustmebro-blockchain/blob/main/blockchain/block.py): `blockchain/block.py`
- [Proof of Work](https://github.com/nhudoannana/trustmebro-blockchain/blob/main/blockchain/mining.py): `blockchain/mining.py`
- [Credential ledger](https://github.com/nhudoannana/trustmebro-blockchain/blob/main/blockchain/blockchain.py): `blockchain/blockchain.py`

### Node network

- [Three-node network](https://github.com/nhudoannana/trustmebro-blockchain/blob/main/blockchain/node.py): `blockchain/node.py`

### Other components

- **Issuer**
- **Holder**
- **Verifier**

## Connections

- Dashboard and navigation → Shared session state: initializes state (evidence: `app.py`)
- Shared session state → Three-node network: creates shared network (evidence: `state.py`)
- Issuer → Wallet demo: creates signing wallet (evidence: `README.md`)
- Holder → Transaction demo: receives credential (evidence: `README.md`)
- Wallet demo → ECDSA wallet: demonstrates keys (evidence: `README.md`)
- Transaction demo → Credential transactions: creates and signs (evidence: `README.md`)
- Credential transactions → ECDSA wallet: signs via (evidence: `blockchain/transaction.py`)
- Credential transactions → SHA-256: hashes canonical data (evidence: `blockchain/transaction.py`)
- ECDSA wallet → SHA-256: derives address (evidence: `blockchain/wallet.py`)
- Credential transactions → Transaction mempool: submitted for validation (evidence: `README.md`)
- Transaction mempool → Credential transactions: verifies transaction (evidence: `blockchain/mempool.py`)
- Mempool demo → Transaction mempool: demonstrates management (evidence: `README.md`)
- Three-node network → Transaction mempool: maintains per-node pools (evidence: `README.md`)
- Mining and consensus → Three-node network: submits and broadcasts (evidence: `README.md`)
- Network demo → Three-node network: shows node status (evidence: `README.md`)
- Three-node network → Credential ledger: maintains node chains (evidence: `README.md`)
- Mining and consensus → Credential ledger: demonstrates consensus flow (evidence: `README.md`)
- Credential ledger → Block and header: manages blocks (evidence: `blockchain/blockchain.py`)
- Credential ledger → Credential transactions: validates credentials (evidence: `blockchain/blockchain.py`)
- Credential ledger → Merkle tree and proofs: verifies Merkle proofs (evidence: `blockchain/blockchain.py`)
- Block and header → Merkle tree and proofs: calculates root (evidence: `blockchain/block.py`)
- Block and header → SHA-256: hashes header (evidence: `blockchain/block.py`)
- Credential ledger → Proof of Work: checks proof of work (evidence: `blockchain/blockchain.py`)
- Mining demo → Proof of Work: demonstrates mining (evidence: `README.md`)
- Merkle visualization → Merkle tree and proofs: visualizes proofs (evidence: `pages/5_Merkle.py`)
- Blockchain explorer → Credential ledger: explores and validates (evidence: `pages/6_Explorer.py`)
- Verifier → Credential verification: requests credential check (evidence: `README.md`)
- Credential verification → Credential ledger: runs 12-step verification (evidence: `README.md`)
- Attack simulator → Credential ledger: demonstrates tampering (evidence: `pages/11_Attacks.py`)
- Attack simulator → Transaction mempool: demonstrates validation attacks (evidence: `pages/11_Attacks.py`)
- Attack simulator → Proof of Work: demonstrates PoW tampering (evidence: `pages/11_Attacks.py`)
- Attack simulator → Merkle tree and proofs: demonstrates root tampering (evidence: `pages/11_Attacks.py`)
- SHA-256 → Merkle tree and proofs: hashes tree pairs (evidence: `blockchain/merkle.py`)
