# troyer-perfectstorm/hblockchain architecture

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

- Interactive diagram: https://gitdiagram.com/troyer-perfectstorm/hblockchain
- Repository: https://github.com/troyer-perfectstorm/hblockchain

## Overview

##### Main Components

A. Core Blockchain Components:
- Blockchain Manager (Blockchain.cs)
- Block Structure (Block.cs)
- Transaction System (Transaction.cs)
- Account Management (Account.cs)

B. Cryptographic Components:
- Signing System (ISigner.cs, ECSigner.cs)
- Verification System (IVerifier.cs, ECVerifier.cs)
- Hashing Utilities (Hash256.cs, Hash512.cs)

**┌─ Application Layer ─────────────────────┐**
- Program.cs (Entry Point)      │
- ┬────────────────────┘
- ↓
**┌─ Core Layer ──────────────────────────┐**
- ┌─────────────┐      ┌────────────┐  │
- Blockchain  │←────→│   Block    │  │
- ┘      └────────────┘  │
- ↑                   ↑          │

- ┌─────────────┐      ┌────────────┐  │
- Transaction │      │  Account   │  │
- ┘      └────────────┘  │
- ┬────────────────────┘
- ↓
**┌─ Cryptographic Layer ──────────────────┐**
- ┌─────────────┐      ┌────────────┐  │
- ISigner   │      │ IVerifier  │  │
- (ECSigner) │      │(ECVerifier)│  │
- ┘      └────────────┘  │
- ┌─────────────┐      ┌────────────┐  │
- Hash256    │      │  Hash512   │  │
- ┘      └────────────┘  │
- ┘

##### Important Elements to Highlight

a. Data Flow:
- Transaction creation and signing process
- Block mining and validation flow
- Account balance verification path

b. Key Processes:
- Proof of work mechanism
- Transaction validation
- Block creation and chaining

##### Implementation Details to Note

- Single-token system
- Pending transaction pool
- Account balance query path
- Proof of work validation flow

##### Limitations to Document

A small note section mentioning:
- No network layer implementation
- Single-threaded operation
- Local-only execution

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef application fill:#f9f,stroke:#333,stroke-width:2px
    classDef core fill:#9cf,stroke:#333,stroke-width:2px
    classDef crypto fill:#9f9,stroke:#333,stroke-width:2px
    classDef interface fill:#ff9,stroke:#333,stroke-width:2px
    
    %% Application Layer
    subgraph Application
        Program["Program (Entry Point)"]
    end
    
    %% Core Layer
    subgraph Core
        Blockchain["Blockchain Manager"]
        Block["Block Structure"]
        Transaction["Transaction System"]
        Account["Account Management"]
        
        Blockchain <--> Block
        Block --> Transaction
        Transaction --> Account
        Blockchain --> Account
    end
    
    %% Cryptographic Layer
    subgraph Crypto
        ISigner["ISigner Interface"]
        ECSigner["ECSigner (NIST P-256)"]
        IVerifier["IVerifier Interface"]
        ECVerifier["ECVerifier"]
        Hash256["SHA256 Hashing"]
        Hash512["SHA512 Hashing"]
        
        ISigner --> ECSigner
        IVerifier --> ECVerifier
    end
    
    %% Inter-layer connections
    Program --> Blockchain
    Block --> Hash256
    Transaction --> ISigner
    Transaction --> IVerifier
    Account --> Hash512
    
    %% Notes
    subgraph Notes
        L1["Single-token system"]
        L2["Local execution only"]
        L3["Single-threaded operation"]
    end
    
    %% Click events for component mapping
    click Program "https://github.com/troyer-perfectstorm/hblockchain/blob/main/Program.cs"
    click Blockchain "https://github.com/troyer-perfectstorm/hblockchain/blob/main/Blockchain.cs"
    click Block "https://github.com/troyer-perfectstorm/hblockchain/blob/main/Block.cs"
    click Transaction "https://github.com/troyer-perfectstorm/hblockchain/blob/main/Transaction.cs"
    click Account "https://github.com/troyer-perfectstorm/hblockchain/blob/main/Account.cs"
    click ISigner "https://github.com/troyer-perfectstorm/hblockchain/blob/main/ISigner.cs"
    click ECSigner "https://github.com/troyer-perfectstorm/hblockchain/blob/main/ECSigner.cs"
    click IVerifier "https://github.com/troyer-perfectstorm/hblockchain/blob/main/IVerifier.cs"
    click ECVerifier "https://github.com/troyer-perfectstorm/hblockchain/blob/main/ECVerifier.cs"
    click Hash256 "https://github.com/troyer-perfectstorm/hblockchain/blob/main/Hash256.cs"
    click Hash512 "https://github.com/troyer-perfectstorm/hblockchain/blob/main/Hash512.cs"
    
    %% Style applications
    class Program application
    class Blockchain,Block,Transaction,Account core
    class ISigner,IVerifier interface
    class ECSigner,ECVerifier,Hash256,Hash512 crypto
```
