# iseddik/blockchain architecture

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

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

## Overview

##### Project Type and Purpose
- This is an academic Java application that simulates a simple, decentralized blockchain for monetary transactions.
- It is packaged as a NetBeans project (build.xml, nbproject folder) with source code under `Sys/src` and GUI forms under `Sys/src/teste`.

##### High‐Level Architecture Analysis
- Top‐level Packages:
- BlockChain – core blockchain logic (Blockchain.java)
- Utiles – cryptographic utilities (RSA keypair generation, SHA-256 hashing)
- teste – Swing‐based GUI and user‐interaction classes (wallet creation, block views, info screens)
- Build & Deployment:
- `build.xml` and `nbproject/` define compilation targets.
- `Sys/dist/` contains the runnable `teste.jar` and required `javax.xml.bind.jar` library.

##### Main Components
a. GUI Layer (Swing Forms)
- Forms: FirstVue, CreatWallet, Infos, VueBlock
- Responsibilities: Accept user input (create wallet, initiate transactions), display blockchain state.
b. Application Logic Layer
- teste.Wallet – represents user wallet, holds keypair and balance.
- teste.Block – data model for a single block (timestamp, previous hash, transactions).
- teste.Calculhash – controller to compute block hashes via Utiles.
c. Blockchain Core
- BlockChain.Blockchain – maintains the list of blocks, validates and adds new blocks, enforces proof-of-work.
d. Crypto Utilities
- Utiles.utiles – generates RSA keypairs, signs/verifies transactions, computes SHA-256 hashes.
e. Persistence/Storage (In‐Memory for Simulation)
- Blockchain held in a Java List/ArrayList in memory.

##### Relationships and Data Flow
- GUI → Application Logic: User actions (button clicks) trigger controller methods in teste.*
- Application Logic → Crypto Utilities: Calls to `utiles.generateKeyPair()`, `utiles.applySha256(data)`, `utiles.verifySignature()`.
- Application Logic → Blockchain Core: New blocks created by GUI controllers are passed to `Blockchain.addBlock(block)`.
- Blockchain Core → Application Logic/GUI: After validation, the updated blockchain is pushed back to the GUI for display.

##### Architectural Patterns & Design Principles
- Layered Architecture: Separate GUI, business logic, core algorithm, and utilities.
- MVC Elements:
- Model: Block, Wallet, Blockchain
- View: .form files (Swing)
- Controller: Calculhash and event handlers in the .java GUI classes
- Single Responsibility: Each package has a clear role—core blockchain vs. crypto vs. presentation.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "GUI Layer"
        FV["FirstVue"]:::gui
        CW["CreatWallet"]:::gui
        INF["Infos"]:::gui
        VB["VueBlock"]:::gui
    end

    subgraph "Application Logic Layer"
        WAL["Wallet"]:::logic
        BLK["Block Model"]:::logic
        CALC["Calculhash"]:::logic
    end

    subgraph "Crypto Utilities"
        UTIL["utiles"]:::util
    end

    subgraph "Blockchain Core"
        BC["Blockchain"]:::core
    end

    subgraph "Build & Deployment"
        ANT["build.xml"]:::external
        NB["nbproject"]:::external
        JAR["teste.jar"]:::external
        JAXB["javax.xml.bind.jar"]:::external
    end

    FV -->|triggers methods in| WAL
    FV -->|triggers methods in| CALC
    CW -->|triggers methods in| WAL
    CW -->|triggers methods in| CALC
    INF -->|displays data from| WAL
    VB -->|displays chain from| BC

    WAL -->|creates transactions| CALC
    CALC -->|calls| UTIL
    WAL -->|creates blocks| BLK
    BLK -->|passed to| BC
    BC -->|updates view| VB
    BC -->|returns updated chain| INF

    click FV "https://github.com/iseddik/blockchain/blob/main/Sys/src/teste/FirstVue.java"
    click CW "https://github.com/iseddik/blockchain/blob/main/Sys/src/teste/CreatWallet.java"
    click INF "https://github.com/iseddik/blockchain/blob/main/Sys/src/teste/Infos.java"
    click VB "https://github.com/iseddik/blockchain/blob/main/Sys/src/teste/VueBlock.java"
    click WAL "https://github.com/iseddik/blockchain/blob/main/Sys/src/teste/Wallet.java"
    click BLK "https://github.com/iseddik/blockchain/blob/main/Sys/src/teste/Block.java"
    click CALC "https://github.com/iseddik/blockchain/blob/main/Sys/src/teste/Calculhash.java"
    click BC "https://github.com/iseddik/blockchain/blob/main/Sys/src/BlockChain/Blockchain.java"
    click UTIL "https://github.com/iseddik/blockchain/blob/main/Sys/src/Utiles/utiles.java"
    click ANT "https://github.com/iseddik/blockchain/blob/main/Sys/build.xml"
    click NB "https://github.com/iseddik/blockchain/tree/main/Sys/nbproject/"
    click JAR "https://github.com/iseddik/blockchain/blob/main/Sys/dist/teste.jar"
    click JAXB "https://github.com/iseddik/blockchain/blob/main/Sys/dist/lib/javax.xml.bind.jar"

    classDef gui fill:#D0E6FF,stroke:#1E90FF,color:#000;
    classDef logic fill:#E6FFE6,stroke:#2E8B57,color:#000;
    classDef util fill:#FFF4E6,stroke:#FFA500,color:#000;
    classDef core fill:#F0F0F0,stroke:#A9A9A9,color:#000;
    classDef external fill:#FFE6F0,stroke:#FF1493,color:#000;
```
