Skip to content

Ferrisama/DeFS

Repository files navigation

Decentralized File Storage System

This project is a decentralized file storage system built using Ethereum blockchain, IPFS, and React. It allows users to upload, retrieve, and manage files with version control capabilities.

Features

  • Upload files to IPFS and store metadata on Ethereum blockchain
  • Retrieve files from IPFS using blockchain metadata
  • Version control: upload multiple versions of a file
  • View version history of files
  • Revert to previous versions of a file
  • Delete files
  • Basic CSV data visualization for uploaded CSV files

Security Features

Client-Side Encryption

This project implements client-side encryption to ensure the highest level of data privacy:

  • Files are encrypted in the browser before being uploaded to IPFS.
  • The encryption key never leaves the user's device.
  • Files are automatically decrypted in the browser when retrieved.
  • Uses AES encryption from the crypto-js library.

This approach ensures that even if the IPFS network or the blockchain were to be compromised, the file contents would remain secure. Only users with the correct encryption key can view the decrypted contents of the files.

Technologies Used

  • Solidity for smart contracts
  • Foundry for Ethereum development environment
  • IPFS for decentralized file storage
  • Node.js and Express for the backend server
  • React for the frontend
  • Ethers.js for Ethereum interaction
  • Recharts for data visualization
  • Tailwind CSS for styling

Prerequisites

  • Node.js (v14 or later)
  • npm
  • Foundry (for Ethereum development)
  • IPFS Desktop

Setup

  1. Clone the repository:

    git clone https://github.com/yourusername/decentralized-file-storage.git
    cd decentralized-file-storage
    
  2. Install backend dependencies:

    npm install
    
  3. Install frontend dependencies:

    cd client
    npm install
    
  4. Compile and deploy the smart contract:

    forge build
    forge create src/Contract.sol:FileStorage --interactive
    

    Note the deployed contract address.

  5. Update the contract address in server.js:

    const contractAddress = "YOUR_DEPLOYED_CONTRACT_ADDRESS";
  6. Start the IPFS Desktop application.

  7. Start the backend server:

    node server.js
    
  8. In a new terminal, start the React app:

    cd client
    npm start
    
  9. Open your browser and navigate to http:https://localhost:3001

Usage

  1. Upload a File: Enter a file name, select a file, and click "Upload".
  2. View Files: The list of uploaded files is displayed on the main page.
  3. Retrieve a File: Click "View" next to a file name to retrieve its content.
  4. Delete a File: Click "Delete" next to a file name to remove it from the system.
  5. View Version History: After retrieving a file, its version history is displayed.
  6. Revert to a Previous Version: In the version history, click "Revert" next to the desired version.
  7. CSV Visualization: If the uploaded file is a CSV with specific headers (created_at, temperature, humidity, distance), a chart will be displayed after retrieval.

Project Structure

  • src/Contract.sol: Solidity smart contract for file metadata storage
  • server.js: Express server handling IPFS and Ethereum interactions
  • client/src/App.js: Main React component for the user interface
  • client/src/CSVAnalysis.js: React component for CSV data visualization

Future Enhancements

  • User authentication and authorization
  • Advanced search and filtering options
  • Folder structure for better file organization
  • Diff view between file versions
  • Mobile-responsive design

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License.