How aradhya0/blockchain-file-storage works
Based on our analysis of the project’s file tree and README, this application is a decentralized, blockchain‐based file storage system. It combines a web‐based client interface with a peer-to-peer blockchain network to securely store files in on-chain blocks. The architecture involves several key modules:
Main Components
• Blockchain Engine:
• Files Involved: Block.py, Blockchain.py, POW_Comparison.py.
• Purpose: Implements the blockchain data structure, handles block creation with file data (including filename, filesize, and file content) and integrates two different Proof of Work (PoW) algorithms (one using a random nonce and another incrementing a nonce) to secure the chain.
• Peer Node:
• File: peer.py.
• Purpose: Acts as one of the decentralized network nodes. It listens for incoming file upload transactions, initiates and participates in block creation/mining, and ensures that once a file is uploaded it can be retrieved securely.
• Web Client/Server:
• Files Involved: run_app.py, app/ (which includes templates, views.py, and static assets).
• Purpose: Provides a user interface, likely built with Flask, where users can upload files, view the blockchain data, and download files. The templates and CSS within app/templates and app/static offer a front-end web experience.
• File Upload & Testing:
• Directory: Test_File_Upload (contains sample files of various types).
• Purpose: Serves as a test suite or sample dataset for validating file uploads into the system.
• Static Resources and Templates:
• Files: CSS files, base.html, and index.html.
• Purpose: Support the front-end design and user interactions, offering an easy way to display and access files stored on the blockchain.
Relationships and Data Flow
• The Web Client/Server (via run_app.py and the “app” folder) interacts with the blockchain backend. When a user uploads a file, it is sent over to the blockchain engine.
• The Blockchain Engine (via Blockchain.py and Block.py) packages the file’s metadata and data into a new block. It then applies the PoW algorithm (with proof-of-work details in POW_Comparison.py) before appending it to the chain.
• The Peer Node (peer.py) operates as an independent server node that can also initiate mining and validate blocks. It interacts with the client, potentially letting users or other peers request/download stored files.
• The Test_File_Upload directory provides sample files to test the file upload mechanism and verify the blockchain’s behavior.
Architectural Patterns & Design Principles
• Client-Server Architecture: Clear separation between the front-end client (handling the user interface and uploads) and the back-end (handling blockchain operations).
• Decentralized/P2P Design: With the peer.py module, the system demonstrates decentralized data validation and blockchain propagation.
• Security via Cryptographic Proof of Work: Two PoW methods are implemented and compared, emphasizing both security (via random nonce generation) and performance trade-offs.
• Modular Code Separation: Different functionalities (block formation, file handling, proof of work, and web serving) are clearly separated into different Python modules and directories.
Technologies and Frameworks
• Python is the primary language, with Flask likely used for the web application (based on the “app” folder structure and template files).
• Cryptographic hashing algorithms (SHA256, as described in the README) are central to the blockchain’s security.
• Front-end assets (CSS, Bootstrap, Font Awesome) aid in creating a user-friendly interface.