# anushreejha/blocksharecloud architecture

> Architecture diagram of the GitHub repository anushreejha/blocksharecloud, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/anushreejha/blocksharecloud
- Repository: https://github.com/anushreejha/blocksharecloud

## Overview

- Web Server & User Interface: Represent the Flask application (app.py) along with its static assets (styles.css) and templates (index.html). This is the front-end that interacts with users via web forms for file uploads and downloads.
- File Upload/Processing Module: Highlight the file upload workflow where files are temporarily stored (uploads directory created at runtime) before they are sent to IPFS.
- IPFS Integration: Include the IPFS client functionality (ipfs.py), and note that there is a “go-ipfs” directory with associated scripts and a README for integration purposes. This component handles storing the file in the decentralized storage network (ensure the IPFS daemon is running).
- Blockchain Component: Represent the blockchain module (blockchain.py) which records the metadata (file name and IPFS hash) of each uploaded file, providing traceability and integrity.
- File Download Handler: Illustrate the download process where the IPFS hash is provided, the file is retrieved from IPFS, and then renamed and served with its original name as recorded on the blockchain.
- External Dependencies & Configurations: Mention the requirements file (requirements.txt) for dependencies and the additional deployment/setup steps (e.g., creating uploads/downloads directories, running the IPFS daemon).

##### Architectural Patterns and Technologies
- MVC Style / Separation of Concerns: Though the project is simple, separate the concerns of presentation (templates and static), business logic (Flask routes in app.py), storage handling (ipfs.py), and metadata management (blockchain.py).
- In-Memory Blockchain: Emphasize that the blockchain is currently non-persistent, making it a lightweight and straightforward traceability mechanism.
- External Service Integration: Clearly mark the dependency on the running IPFS daemon, vital for decentralized file storage.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A("User Browser"):::user
    B("Web Server (Flask - app.py)"):::backend
    C1("Static Asset: styles.css"):::frontend
    C2("Template: index.html"):::frontend
    D("Temporary Storage (uploads)"):::upload
    E1("IPFS Client (ipfs.py)"):::ipfs
    E2("go-ipfs README"):::ipfs
    E3("go-ipfs Install"):::ipfs
    F("IPFS Network"):::external
    G("Blockchain Module (blockchain.py)"):::blockchain
    H("External Dependencies (requirements.txt)"):::config

    %% User initiates file upload/download request
    A -->|"fileUpload/downloadRequest"| B

    %% Web Server serves UI assets
    B -->|"serveUI"| C1
    B --> C2

    %% File Upload Flow
    B -->|"receiveUpload"| D
    D -->|"forwardFile"| E1
    E1 -->|"storeFile_returnHash"| F
    E1 -->|"recordMetadata"| G

    %% Illustrate go-ipfs integration details
    E1 -->|"integrate"| E2
    E2 -->|"loadScripts"| E3

    %% File Download Flow
    A -->|"downloadRequest(hash)"| B
    B -->|"lookupMetadata"| G
    G -->|"returnFileInfo"| B
    B -->|"fetchFile"| E1
    E1 -->|"retrieveFile"| F
    F -->|"sendFile"| B
    B -->|"deliverFile"| A

    %% Click Events
    click B "https://github.com/anushreejha/blocksharecloud/blob/main/app.py"
    click C1 "https://github.com/anushreejha/blocksharecloud/blob/main/static/styles.css"
    click C2 "https://github.com/anushreejha/blocksharecloud/blob/main/templates/index.html"
    click E1 "https://github.com/anushreejha/blocksharecloud/blob/main/ipfs.py"
    click E2 "https://github.com/anushreejha/blocksharecloud/blob/main/go-ipfs/README.md"
    click E3 "https://github.com/anushreejha/blocksharecloud/blob/main/go-ipfs/install.sh"
    click G "https://github.com/anushreejha/blocksharecloud/blob/main/blockchain.py"
    click H "https://github.com/anushreejha/blocksharecloud/blob/main/requirements.txt"

    %% Styles
    classDef user fill:#ffef9f,stroke:#333,stroke-width:2px;
    classDef backend fill:#b3e5fc,stroke:#333,stroke-width:2px;
    classDef frontend fill:#c5e1a5,stroke:#333,stroke-width:2px;
    classDef upload fill:#ffe082,stroke:#333,stroke-width:2px;
    classDef ipfs fill:#d1c4e9,stroke:#333,stroke-width:2px;
    classDef external fill:#ffccbc,stroke:#333,stroke-width:2px;
    classDef blockchain fill:#f8bbd0,stroke:#333,stroke-width:2px;
    classDef config fill:#cfd8dc,stroke:#333,stroke-width:2px;

    %% Place External Dependencies node at the bottom for configuration awareness
    B ---|"config"| H
    click H "https://github.com/anushreejha/blocksharecloud/blob/main/requirements.txt"
```
