Skip to content

codeandbe/MedVault

Repository files navigation

MedVault

Blockchain-Powered Emergency Medical Records Platform

MedVault

MedVault is a secure healthcare platform that enables patients to maintain ownership and control of their medical records through blockchain-based access control, decentralized storage, and end-to-end encryption.

The platform combines smart contracts, IPFS storage, client-side cryptography, wallet authentication, and immutable audit logs to provide secure emergency medical record access while preserving patient privacy.

Live Demo: https://med-vault-khaki.vercel.app


Problem Statement

Traditional healthcare systems often rely on centralized databases that can create security, privacy, and accessibility challenges during emergencies.

MedVault addresses these challenges by allowing patients to:

  • Own and control their medical records
  • Encrypt records before they leave their device
  • Grant access to authorized healthcare personnel
  • Revoke access at any time
  • Maintain an immutable audit trail of every interaction

Key Capabilities

  • Upload encrypted medical records
  • Store records on IPFS
  • Grant access to doctors and paramedics
  • Revoke access at any time
  • Immutable blockchain audit trail
  • Wallet-based authentication
  • Client-side encryption before upload
  • Decentralized storage architecture
  • Real-time permission management
  • Blockchain-backed access verification

Screenshots

Upload Medical Records

Upload Medical Record

Grant Medical Access

Grant Access

Access Patient Records

Record Access

Blockchain Audit Trail

Audit Log

Cloudflare + Pinata Infrastructure

Pinata Server


System Architecture

Patient
    │
    ▼
Client-side AES-256 Encryption
    │
    ▼
IPFS (Pinata)
    │
    ▼
CID Storage
    │
    ▼
MedVault Smart Contract
    │
    ▼
Access Control Layer
    │
    ▼
Authorized Medical Personnel
    │
    ▼
Audit Events
    │
    ▼
Immutable Blockchain Ledger

Project Overview

MedVault is a blockchain-powered Emergency Medical Record Access System that enables patients to securely manage healthcare records using decentralized technologies.

The platform integrates:

  • Blockchain smart contracts for access control
  • IPFS for decentralized storage
  • AES-256 encryption for data privacy
  • Wallet-based authentication
  • Immutable audit trails

The result is a secure, transparent, and patient-controlled healthcare record system.


How It Works

Upload Flow (Patient)

Select Medical Record
        ↓
Generate AES-256 Key
        ↓
Encrypt File Locally
        ↓
Upload Encrypted File to IPFS
        ↓
Receive CID
        ↓
Store CID on Blockchain
        ↓
Grant Access to Medical Personnel

Access Flow (Medical Personnel)

Enter Patient Wallet Address
            ↓
Verify Permission On-Chain
            ↓
Retrieve CID
            ↓
Fetch Encrypted File from IPFS
            ↓
Decrypt Using Authorized Key
            ↓
View Medical Record

Audit Flow

User Action
      ↓
Smart Contract Event
      ↓
Blockchain Storage
      ↓
Immutable Audit Record
      ↓
Frontend Audit Dashboard

Security Model

Client-Side Encryption

Medical records are encrypted in the browser before transmission using AES-256-GCM encryption.

Key Wrapping

Encryption keys are wrapped individually for each authorized recipient.

Blockchain Access Control

Smart contracts enforce permissions and ownership verification.

Immutable Audit Trail

Every upload, access request, grant, and revocation is recorded on-chain.

Revocable Permissions

Patients retain full control and may revoke access at any time.


Technical Architecture

Smart Contract Layer

MedVault.sol

Core responsibilities:

  • Medical record registration
  • Permission management
  • Access validation
  • Audit logging

Key Functions:

uploadRecord(cid)
grantAccess(grantee, wrappedKey)
revokeAccess(grantee)
getRecord(patient)

Events:

RecordUploaded
AccessUpdated
AccessAttempt

Frontend Layer

Built using React and Vite.

Core pages:

  • Upload Medical Record
  • Access Patient Records
  • Audit Log Viewer

Features:

  • MetaMask integration
  • Encryption utilities
  • Smart contract interaction
  • IPFS integration
  • Event monitoring

Infrastructure Layer

Blockchain

  • BlockDAG Awakening Testnet
  • Solidity Smart Contracts
  • Foundry Framework

Storage

  • IPFS
  • Pinata

Backend Services

  • Cloudflare Workers
  • Pinata Gateway Services

Technology Stack

Blockchain

  • Solidity
  • Foundry
  • Ethers.js
  • BlockDAG Testnet

Frontend

  • React 18
  • Vite
  • JavaScript
  • React Router

Storage

  • IPFS
  • Pinata

Security

  • AES-256-GCM
  • Web Crypto API
  • @noble/secp256k1

Infrastructure

  • Cloudflare Workers
  • Vercel

Skills Demonstrated

Blockchain Development

  • Smart Contract Development
  • Solidity Programming
  • Blockchain Event Logging
  • Access Control Systems

Security Engineering

  • AES-256 Encryption
  • Secure Key Management
  • Cryptographic Workflows
  • Permission Systems

Web3 Development

  • MetaMask Integration
  • Wallet Authentication
  • Decentralized Storage
  • IPFS Workflows

Full-Stack Engineering

  • React Development
  • Frontend Architecture
  • API Integration
  • Cloud Deployment

Project Structure

MedVault/
├── contracts-foundry/
│   ├── contracts/
│   │   └── MedVault.sol
│   ├── script/
│   └── test/
│
├── frontend/
│   ├── src/
│   │   ├── pages/
│   │   ├── utils/
│   │   └── components/
│
├── DOCUMENTATION.md
├── BUILD_VERIFICATION.md
├── PROJECT_STRUCTURE.md
└── README.md

Local Development

Clone Repository

git clone https://github.com/codeandbe/MedVault.git
cd MedVault

Install Dependencies

bash init_medvault.sh

Configure Environment

VITE_PINATA_API_KEY=
VITE_PINATA_SECRET_API_KEY=
VITE_RPC_URL=
VITE_CHAIN_ID=1043
VITE_CONTRACT_ADDRESS=

Run Application

cd frontend
npm install
npm run dev

Testing

Smart Contract Tests

cd contracts-foundry

forge test
forge test -vvv
forge test --gas-report

Manual Verification

  • Upload encrypted medical records
  • Grant access permissions
  • Retrieve authorized records
  • Revoke permissions
  • Verify blockchain audit logs

Future Enhancements

Short-Term

  • Time-limited permissions
  • Emergency access codes
  • Multi-file support
  • Record categorization

Medium-Term

  • Mobile applications
  • Biometric authentication
  • Secure messaging
  • Appointment integration

Long-Term

  • AI-assisted healthcare insights
  • Decentralized Identity (DID)
  • Zero-Knowledge Proofs
  • EHR interoperability
  • Multi-chain support

Security Notice

This project is a Proof of Concept and should not be used in production healthcare environments without:

  • Smart contract security audits
  • HIPAA compliance review
  • GDPR compliance assessment
  • Infrastructure hardening
  • Enterprise key management systems

License

MIT License


Author

Iyobosa Amaddin Majid

GitHub: https://github.com/codeandbe


Project Status

Version: v1.0.0 MVP

Status: Proof of Concept

Deployment: BlockDAG Awakening Testnet

Live Demo: https://med-vault-khaki.vercel.app


Securing Emergency Medical Records Through Blockchain, Encryption, and Decentralized Storage.