# cyscz/blockchain-based-data-sharing architecture

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

- Interactive diagram: https://gitdiagram.com/cyscz/blockchain-based-data-sharing
- Repository: https://github.com/cyscz/blockchain-based-data-sharing

## Overview

##### Main Components

a) Client-Server Architecture
- Two distinct server components (client_server_1 and main_server)
- Each server contains identical structure with web interface components
- Blockchain nodes for each server

b) Data Storage Layer
- Blockchain storage (Hyperledger Fabric)
- IPFS storage system
- Data balancing mechanism between on-chain and off-chain storage

c) Frontend Components
- Web interface (templates directory)
- Static assets (CSS, JS, images)
- User interaction flows

**┌─ User Interface Layer ─────────────────────┐**
- Web Frontend (React/Python)              │
- Templates (HTML)                         │
- Static Assets (CSS/JS)                   │
- ┬───────────────────────┘
- ↓
**┌─ Application Layer ──────────────────────┐**
- ┌─ Client Server 1 ─┐  ┌─ Main Server ─┐ │
- Server.py       │  │ - Server.py    │ │
- Blockchain.py   │  │ - Blockchain.py│ │
- ┘  └───────────────┘  │
- ┬───────────────────────┘
- ↓
**┌─ Storage Layer ────────────────────────────┐**
- ┌─ On-Chain ─────┐    ┌─ Off-Chain ─────┐ │
- Hyperledger    │    │ IPFS Protocol   │ │
- Fabric         │←→│ Storage         │ │
- ┘    └───────────────┘   │
- ┘

##### Key Elements to Highlight

a) Current Implementation:
- Basic blockchain file sharing system
- Web interface for file upload/download
- Server-side blockchain implementation

b) Planned Features:
- Data balancing mechanism (highlight as future component)
- AI-powered optimization (mark as future enhancement)
- IPFS integration (show as planned component)

##### Data Flow Indicators
- File upload path from UI → Server → Storage
- Blockchain transaction flow
- Data balancing decision points
- IPFS interaction paths

##### Implementation Notes
- Maintain consistent component sizing
- Version/status indicators for planned features

Remember to:
- Clearly distinguish between implemented and planned features
- Optimization points for data balancing
- Integration points for future AI components

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "User Interface Layer"
        UI_CS1["Client Server 1 UI"]:::frontend
        UI_MS["Main Server UI"]:::frontend
        
        subgraph "Templates"
            T_INDEX["Index Interface"]:::frontend
            T_UPLOAD["Upload Interface"]:::frontend
            T_DOWNLOAD["Download Interface"]:::frontend
            T_BLOCKCHAIN["Blockchain Connection Interface"]:::frontend
        end
        
        subgraph "Static Assets"
            CSS["Stylesheets"]:::frontend
            JS["JavaScript"]:::frontend
            IMG["Images"]:::frontend
        end
    end

    subgraph "Application Layer"
        subgraph "Client Server 1"
            CS1_SERVER["Server Implementation"]:::server
            CS1_BLOCKCHAIN["Blockchain Node"]:::blockchain
            CS1_CONFIG["Configuration"]:::config
        end
        
        subgraph "Main Server"
            MS_SERVER["Server Implementation"]:::server
            MS_BLOCKCHAIN["Blockchain Node"]:::blockchain
            MS_CONFIG["Configuration"]:::config
        end
    end

    subgraph "Storage Layer"
        subgraph "On-Chain Storage"
            HYPERLEDGER["Hyperledger Fabric"]:::blockchain
        end
        
        subgraph "Off-Chain Storage"
            IPFS["IPFS Protocol"]:::storage
        end
        
        BALANCER["Data Balancing Mechanism"]:::future
    end

    %% Connections
    UI_CS1 --> CS1_SERVER
    UI_MS --> MS_SERVER
    CS1_SERVER --> CS1_BLOCKCHAIN
    MS_SERVER --> MS_BLOCKCHAIN
    CS1_BLOCKCHAIN --> HYPERLEDGER
    MS_BLOCKCHAIN --> HYPERLEDGER
    HYPERLEDGER <--> BALANCER
    BALANCER <--> IPFS

    %% Click Events
    click CS1_SERVER "https://github.com/CyScz/Blockchain-based-data-sharing/blob/main/client_server_1/server.py"
    click CS1_BLOCKCHAIN "https://github.com/CyScz/Blockchain-based-data-sharing/blob/main/client_server_1/blockchain.py"
    click CS1_CONFIG "https://github.com/CyScz/Blockchain-based-data-sharing/blob/main/client_server_1/my_constants.py"
    click MS_SERVER "https://github.com/CyScz/Blockchain-based-data-sharing/blob/main/main_server/server.py"
    click MS_BLOCKCHAIN "https://github.com/CyScz/Blockchain-based-data-sharing/blob/main/main_server/blockchain.py"
    click MS_CONFIG "https://github.com/CyScz/Blockchain-based-data-sharing/blob/main/main_server/my_constants.py"
    click T_INDEX "https://github.com/CyScz/Blockchain-based-data-sharing/blob/main/client_server_1/templates/index.html"
    click T_UPLOAD "https://github.com/CyScz/Blockchain-based-data-sharing/blob/main/client_server_1/templates/upload.html"
    click T_DOWNLOAD "https://github.com/CyScz/Blockchain-based-data-sharing/blob/main/client_server_1/templates/download.html"
    click T_BLOCKCHAIN "https://github.com/CyScz/Blockchain-based-data-sharing/blob/main/client_server_1/templates/connect_blockchain.html"
    click CSS "https://github.com/CyScz/Blockchain-based-data-sharing/tree/main/client_server_1/static/css/"
    click JS "https://github.com/CyScz/Blockchain-based-data-sharing/tree/main/client_server_1/static/js/"
    click IMG "https://github.com/CyScz/Blockchain-based-data-sharing/tree/main/client_server_1/static/img/"

    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef server fill:#2ecc71,stroke:#27ae60,color:white
    classDef blockchain fill:#e67e22,stroke:#d35400,color:white
    classDef storage fill:#9b59b6,stroke:#8e44ad,color:white
    classDef config fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef future fill:#e74c3c,stroke:#c0392b,color:white,stroke-dasharray: 5 5
```
