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.
- 🔒 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).
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]
| 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 |
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
- Docker Desktop
- Node.js (for local frontend development)
- Python 3.10+ (for local backend development)
The entire system is containerized for easy deployment. Run the following command in your terminal:
docker compose up --buildAlternatively, on Windows, you can use the provided batch script:
run_commands.batThis will spin up:
- PostgreSQL: Metadata storage.
- IPFS: Decentralized file storage.
- Hardhat Node: Local blockchain at
http://localhost:8545. - Backend: API at
http://localhost:8000. - Frontend: Web UI at
http://localhost:5173.
- 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.
- 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.
- 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.
Distributed under the MIT License. See LICENSE for more information.
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.