A patient-centric secure Electronic Health Record (EHR) sharing system using Hyperledger Fabric permissioned blockchain with optional federated learning capabilities.
🚀 Quick Start: See DOCKER_DEPLOYMENT.md for complete Docker-based deployment guide - no Fabric binaries installation required!
- Patient Control: Patients own and control access to their medical records
- Consent Management: Smart contract-based permission system (grant/revoke access)
- Immutable Audit Trail: All access attempts logged on blockchain
- Privacy-Preserving: End-to-end encryption (AES-256) with off-chain storage
- Role-Based Access: Patient, Doctor, and Admin roles with appropriate permissions
- Federated Learning (Phase 2): Privacy-preserving ML on distributed medical data
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ Patient │ │ Doctor │ │ Admin │
│ Dashboard │ │ Dashboard │ │ Dashboard │
└──────┬──────┘ └──────┬──────┘ └──────┬──────┘
│ │ │
└───────────────────┴───────────────────┘
│
┌──────▼──────┐
│ REST API │
│ (Node.js) │
└──────┬──────┘
│
┌───────────────┴───────────────┐
│ │
┌──────▼──────┐ ┌────────▼────────┐
│ Hyperledger│ │ IPFS / Cloud │
│ Fabric │ │ Storage │
│ (Chaincode)│ │ (Encrypted) │
└─────────────┘ └─────────────────┘
- Blockchain: Hyperledger Fabric 2.5
- Smart Contracts: Go 1.20+
- Backend API: Node.js 16+ / Python 3.9+ (FastAPI)
- Frontend: React 18+ with Material-UI
- Storage: IPFS or AWS S3
- Database: CouchDB (world state), PostgreSQL (optional metadata)
- Encryption: AES-256-GCM, RSA-2048, X.509 certificates
- ML Frameworks: PyTorch 2.1+ / TensorFlow 2.15+
- FL Algorithm: FedAvg (Federated Averaging)
- Aggregation: Python-based coordination service
- Docker Desktop 20.10+ (with Docker Compose)
- Node.js 16+ and npm 8+
- Go 1.20+ (for chaincode development)
- Python 3.9+ (tested with Python 3.14)
- Poetry 1.8+ (Python dependency management)
- At least 8GB RAM for Fabric network
Note: Hyperledger Fabric binaries are NOT required - all operations use Docker containers.
# Install Poetry (if not already installed)
curl -sSL https://install.python-poetry.org | python3 -
# Install dependencies
poetry install
# Activate virtual environment
poetry shellcp .env.example .env
# Edit .env with your configurationcd fabric-network
# Windows PowerShell
.\network.ps1 up
# This will:
# - Generate certificates using Docker
# - Start CouchDB containers (4 instances)
# - Start orderer and peer nodes
# - Create channel and join all peers# Build chaincode Docker image
cd ..\chaincode\ehr
docker build -t ehr-chaincode:1.0 .
# Package and deploy (see DEPLOYMENT_GUIDE.md for detailed steps)
cd ..\..\fabric-network
# Follow chaincode deployment section in documentationcd backend
npm install
npm run devcd frontend
npm install
npm run devAccess the application at http://localhost:3000
BlockChainProject/
├── fabric-network/ # Hyperledger Fabric network configuration
│ ├── docker-compose.yaml
│ ├── configtx.yaml
│ └── crypto-config.yaml
├── chaincode/ # Go smart contracts
│ └── ehr/
│ ├── main.go
│ ├── ehr.go
│ ├── consent.go
│ └── audit.go
├── backend/ # Node.js/Python REST API
│ ├── src/
│ ├── config/
│ └── tests/
├── frontend/ # React application
│ ├── src/
│ └── public/
├── ehr_system/ # Python utilities and FL
│ ├── crypto/
│ ├── ipfs/
│ └── federated_learning/
├── scripts/ # Deployment and management scripts
├── docs/ # Documentation
├── pyproject.toml # Python dependencies
└── README.md
-
Upload Medical Record
- Login to patient dashboard
- Upload file (automatically encrypted)
- Metadata stored on blockchain, file on IPFS
-
Grant Access to Doctor
- Navigate to "Consent Management"
- Enter doctor ID and select records
- Set expiration date (optional)
-
Revoke Access
- View active consents
- Click "Revoke" on specific consent
- Access immediately revoked on blockchain
-
View Accessible Records
- Login to doctor dashboard
- See list of all permitted patient records
- Click to download and view
-
Request Access
- Search for patient by ID
- Send access request
- Wait for patient approval
All actions are logged immutably:
- Record uploads
- Consent grants/revokes
- Access attempts (successful and failed)
- User authentication events
- DOCKER_DEPLOYMENT.md - Complete Docker-based deployment guide (Recommended)
- DEPLOYMENT_GUIDE.md - Detailed deployment instructions
- SETUP_SUMMARY.md - Python environment setup summary
- fabric-network/README.md - Network configuration details
- USER_MANUAL.md - End-user documentation
# Chaincode tests
cd chaincode/ehr
go test -v ./...
# Backend tests
cd backend
npm test
# Frontend tests
cd frontend
npm test
# Python tests
poetry run pytest# Python formatting and linting
poetry run black .
poetry run isort .
poetry run flake8
poetry run mypy .
# JavaScript/TypeScript
npm run lint
npm run format- Implement proper HSM (Hardware Security Module) for key management
- Conduct HIPAA compliance audit
- Perform professional security review
- Implement network segmentation and firewalls
- Set up regular security updates and monitoring
- Use production-grade certificate authority
- Implement rate limiting and DDoS protection
##: Federated Learning
privacy-preserving machine learning across hospitals:
- Local model training on encrypted data
- Blockchain-verified model updates
- Secure aggregation (FedAvg)
- Incentive mechanism for participation
- Governance and audit trail for ML models
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open Pull Request
MIT License - see LICENSE file for details
- Hyperledger Fabric Documentation
- IPFS Documentation
- Federated Learning: Google Research
- HIPAA Security Rule
For questions and support, please open an issue in the repository.