# nambrot/blockchain-in-js architecture

> Architecture diagram of the GitHub repository nambrot/blockchain-in-js, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nambrot/blockchain-in-js
- Repository: https://github.com/nambrot/blockchain-in-js

## Overview

##### Project Type Analysis
This is a full-stack educational application demonstrating blockchain concepts, consisting of:
- A React-based frontend
- A Socket.IO-based backend
- Docker containerization
- Kubernetes/Helm deployment capabilities

##### Main Components

A. Client-Side Components:
**Frontend (React Application)**
- Core Components
- Blockchain Visualization
- Block Management
- Transaction Management
- UTXO Pool Visualization
- Crypto Services
- Network Communication Layer

B. Server-Side Components:
**Backend (Socket.IO Server)**
- P2P Network Simulation
- Block/Transaction Broadcasting

C. Infrastructure Components:
**Deployment Layer**
- Docker Containers
- Client Container
- Server Container
- Kubernetes/Helm Deployment

##### Technical Details

**Component Interactions:**
- Frontend ↔ Socket.IO (Real-time updates)
- Block Creation → Network Broadcasting
- Transaction Validation → UTXO Pool Updates
- Crypto Operations → Block/Transaction Signing

##### Infrastructure Details
**Deployment Flow:**
**Docker → Kubernetes → Ingress → Client Access**

Remember to:
- Educational/demonstration aspects
- Clear separation between simulation and actual blockchain components
- Version progression capabilities (Steps 1-8)
- P2P nature of the system

## Diagram (Mermaid)

```mermaid
graph TB
    %% Style Definitions
    classDef frontend fill:#a8d1f0,stroke:#333
    classDef backend fill:#c3e6cb,stroke:#333
    classDef network fill:#d4b8e6,stroke:#333
    classDef infra fill:#e0e0e0,stroke:#333
    classDef model fill:#ffd7a8,stroke:#333
    classDef state fill:#ffc8dd,stroke:#333

    %% Frontend Layer
    subgraph Frontend
        React["React Application"]
        
        subgraph CoreComponents
            BV["Blockchain Visualization"]
            BM["Block Management"]
            TM["Transaction Management"]
            UTXO["UTXO Pool Visualization"]
            Welcome["Educational Welcome"]
            Walk["Walkthrough"]
        end

        subgraph BlockManagement
            BI["Block Info"]
            NB["New Block"]
            DB["Detail Block"]
            NBH["New Block Header"]
        end

        subgraph TransactionManagement
            NT["New Transaction"]
            TT["Transaction Table"]
            NBTL["New Block Transaction List"]
        end

        subgraph UTXOVisualization
            UPT["UTXO Pool Table"]
            WUPT["Welcome UTXO Pool Table"]
        end

        Store["State Management"]
        Crypto["Crypto Services"]
        Network["Network Layer"]
    end

    %% Backend Layer
    subgraph Backend
        Server["Socket.IO Server"]
        P2P["P2P Network Simulation"]
        
        subgraph Models
            Block["Block Model"]
            BlockChain["Blockchain Model"]
            Trans["Transaction Model"]
            UTXOModel["UTXO Model"]
            UTXOPool["UTXO Pool Model"]
        end
    end

    %% Infrastructure Layer
    subgraph Infrastructure
        subgraph Docker
            DC["Docker Client"]
            DS["Docker Server"]
        end
        
        subgraph Kubernetes
            CD["Client Deployment"]
            CS["Client Service"]
            SD["Server Deployment"]
            SS["Server Service"]
        end
    end

    %% Relationships
    React --> CoreComponents
    BM --> BlockManagement
    TM --> TransactionManagement
    UTXO --> UTXOVisualization
    Network <--> Server
    Server <--> P2P
    Store --> React
    Models --> Server

    %% Infrastructure Relationships
    DC --> CD
    DS --> SD
    CD --> CS
    SD --> SS

    %% Click Events
    click BV "https://github.com/nambrot/blockchain-in-js/blob/master/src/components/BlockchainTree.js"
    click BI "https://github.com/nambrot/blockchain-in-js/blob/master/src/components/BlockInfo.js"
    click NB "https://github.com/nambrot/blockchain-in-js/blob/master/src/components/NewBlock.js"
    click DB "https://github.com/nambrot/blockchain-in-js/blob/master/src/components/DetailBlock.js"
    click NBH "https://github.com/nambrot/blockchain-in-js/blob/master/src/components/NewBlockHeader.js"
    click NT "https://github.com/nambrot/blockchain-in-js/blob/master/src/components/NewTransaction.js"
    click TT "https://github.com/nambrot/blockchain-in-js/blob/master/src/components/TransactionTable.js"
    click NBTL "https://github.com/nambrot/blockchain-in-js/blob/master/src/components/NewBlockTransactionList.js"
    click UPT "https://github.com/nambrot/blockchain-in-js/blob/master/src/components/UTXOPoolTable.js"
    click WUPT "https://github.com/nambrot/blockchain-in-js/blob/master/src/components/WelcomeUTXOPoolTable.js"
    click Crypto "https://github.com/nambrot/blockchain-in-js/blob/master/src/crypto.js"
    click Network "https://github.com/nambrot/blockchain-in-js/blob/master/src/network.js"
    click Server "https://github.com/nambrot/blockchain-in-js/blob/master/src/server.js"
    click Block "https://github.com/nambrot/blockchain-in-js/blob/master/src/models/Block.js"
    click BlockChain "https://github.com/nambrot/blockchain-in-js/blob/master/src/models/Blockchain.js"
    click Trans "https://github.com/nambrot/blockchain-in-js/blob/master/src/models/Transaction.js"
    click UTXOModel "https://github.com/nambrot/blockchain-in-js/blob/master/src/models/UTXO.js"
    click UTXOPool "https://github.com/nambrot/blockchain-in-js/blob/master/src/models/UTXOPool.js"
    click Store "https://github.com/nambrot/blockchain-in-js/blob/master/src/store.js"
    click DC "https://github.com/nambrot/blockchain-in-js/blob/master/Dockerfile.client"
    click DS "https://github.com/nambrot/blockchain-in-js/blob/master/Dockerfile.server"
    click CD "https://github.com/nambrot/blockchain-in-js/blob/master/helm-chart/templates/client-deployment.yaml"
    click SD "https://github.com/nambrot/blockchain-in-js/blob/master/helm-chart/templates/server-deployment.yaml"
    click CS "https://github.com/nambrot/blockchain-in-js/blob/master/helm-chart/templates/client-service.yaml"
    click SS "https://github.com/nambrot/blockchain-in-js/blob/master/helm-chart/templates/server-service.yaml"
    click Welcome "https://github.com/nambrot/blockchain-in-js/blob/master/src/components/BlockchainWelcome.js"
    click Walk "https://github.com/nambrot/blockchain-in-js/blob/master/src/components/walkthrough.js"

    %% Style Applications
    class React,CoreComponents,BlockManagement,TransactionManagement,UTXOVisualization frontend
    class Server,P2P backend
    class Network network
    class DC,DS,CD,CS,SD,SS infra
    class Block,BlockChain,Trans,UTXOModel,UTXOPool model
    class Store state
```
