Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🏥 MedMarket: Decentralized Federated Learning Marketplace

License: MIT Python 3.10+ React Blockchain IPFS Federated Learning

MedMarket is a cutting-edge Decentralized Federated Learning Marketplace (DFLM) designed to revolutionize collaborative medical AI. By combining Federated Learning (FL) with Blockchain technology and Differential Privacy (DP), MedMarket enables medical institutions to train high-performance AI models without ever sharing sensitive patient data.


🌟 Key Features

  • 🔒 Privacy-First Training: Uses Flower for federated orchestration and Opacus for Differential Privacy, ensuring patient records never leave hospital firewalls.
  • 🔗 Blockchain-Backed Trust: Smart contracts handle escrow-based payments, model provenance, and automated reward distribution.
  • ⚖️ Fair Payouts: Implements Shapley Value approximation to calculate the marginal contribution of each data provider, ensuring fair financial rewards.
  • 📦 Decentralized Artifact Storage: Model weights and dataset manifests are stored immutably on IPFS via Pinata.
  • 🛡️ Cryptographic Provenance: Every trained model is anchored to the Ethereum blockchain, providing a verifiable audit trail of its training history.
  • 🖥️ Dual-Role Dashboard: Tailored experiences for Model Developers (Job creation, monitoring) and Data Providers (Dataset management, payout tracking).

🏗️ System Architecture

graph TD
    subgraph "Frontend (React + Vite)"
        UI[User Dashboard]
        Wallet[MetaMask / Web3]
    end

    subgraph "Backend (FastAPI)"
        API[API Server]
        DB[(PostgreSQL)]
        IPFS_S[IPFS Service]
        BC_S[Blockchain Service]
    end

    subgraph "ML Core (Flower)"
        FS[FL Server]
        FC1[FL Client 1 - Hospital A]
        FC2[FL Client 2 - Hospital B]
        FC3[FL Client 3 - Hospital C]
    end

    subgraph "Blockchain (Hardhat)"
        SC1[Escrow Contract]
        SC2[Provenance Registry]
        SC3[DFLM Token]
    end

    UI <--> API
    API <--> DB
    API <--> IPFS_S
    API <--> BC_S
    BC_S <--> SC1
    API -- triggers --> FS
    FS <--> FC1
    FS <--> FC2
    FS <--> FC3
    IPFS_S <--> Pinata[Pinata IPFS Node]
Loading

🛠️ Technology Stack

Component Technology
Frontend React 18, Vite, TypeScript, TailwindCSS, Lucide, Radix UI, Framer Motion
Backend FastAPI (Python 3.10), SQLAlchemy, Alembic, PostgreSQL
ML Engine Flower (flwr), PyTorch, TorchVision
Privacy Opacus (Differential Privacy)
Blockchain Solidity, Hardhat, Ethers.js, Web3.py
Storage IPFS (Go-IPFS), Pinata Cloud
DevOps Docker, Docker Compose

📂 Project Structure

MedMarket/
├── backend/            # FastAPI API Server & Business Logic
├── blockchain/         # Smart Contracts & Hardhat Environment
├── frontend/           # React Web Application
├── ml_core/            # Federated Learning Server & Client Logic
├── usability_study/     # Research Documentation & User Study Results
├── docker-compose.yml  # Full Stack Orchestration
└── run_commands.bat    # Quick Setup Script for Windows

🚀 Getting Started

Prerequisites

Quick Start (Recommended)

The entire system is containerized for easy deployment. Run the following command in your terminal:

docker compose up --build

Alternatively, on Windows, you can use the provided batch script:

run_commands.bat

This will spin up:

  1. PostgreSQL: Metadata storage.
  2. IPFS: Decentralized file storage.
  3. Hardhat Node: Local blockchain at http://localhost:8545.
  4. Backend: API at http://localhost:8000.
  5. Frontend: Web UI at http://localhost:5173.

🔄 Workflow

1. Model Developer Phase

  • Connect Wallet: Link your MetaMask to the local Hardhat network.
  • Create Job: Define model architecture (ResNet50/UNet), rounds, and escrow amount.
  • Lock Funds: Deposit DFLM tokens into the Escrow contract to guarantee payment.

2. Data Provider Phase

  • Browse Jobs: Find training tasks matching your available datasets.
  • Contribute: Upload a dataset manifest (JSON) to participate.
  • Train: The system automatically triggers the FL client within your secure environment.

3. Payout & Verification

  • Aggregation: Flower server aggregates model weights using FedAvg.
  • Evaluation: Marginal contributions are calculated via Shapley values.
  • Payout: Once the "Dispute Window" passes, tokens are released to hospitals based on their data quality.
  • Provenance: Download the final global model anchored to the blockchain.

📝 License

Distributed under the MIT License. See LICENSE for more information.


🎓 Academic Context

This project was developed as a Final Year Project (FYP) to address the challenges of data silos in medical research. It demonstrates a production-ready integration of Web3 and AI for privacy-preserving healthcare innovation.


About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages