Skip to content

rtb-12/StarkMed

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

18 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

StarkMed - Decentralized Medical Records Platform

StarkMed Logo

Revolutionary blockchain-based health passport built on Starknet, providing secure, private, and globally accessible medical credential management.

StarkMed Platform Version License Network

πŸ”— Quick Links

🌟 Overview

StarkMed is a cutting-edge decentralized health passport platform that leverages Starknet's advanced blockchain technology to provide secure, private, and verifiable medical credential management. Built with IPFS storage and blockchain technology, StarkMed ensures that patients have complete control over their medical data while enabling instant, global verification.

✨ Key Features

πŸ” Military-Grade Security

  • End-to-end encryption for all medical records
  • Advanced cryptographic protocols ensuring absolute privacy
  • Zero-knowledge proof technology for data verification without exposure (planned for future implementation)

🌐 Decentralized Architecture

  • Built on Starknet's high-performance blockchain infrastructure
  • IPFS storage for truly decentralized, censorship-resistant data management
  • No single point of failure or control

⚑ Instant Verification

  • Generate secure QR codes for immediate credential sharing
  • Real-time blockchain verification
  • Cross-border medical compatibility

πŸ₯ Provider Ecosystem

  • Seamless integration with verified healthcare providers
  • Hospital and medical institution network
  • Trusted decentralized provider registry

πŸ‘€ Patient-Centric Control

  • Complete ownership of health data
  • Granular access control and permissions
  • Selective sharing with healthcare providers
  • Emergency access protocols

πŸ” Immutable Records

  • Tamper-proof medical history storage
  • Permanent, verifiable credential records
  • Full audit trail of all access and modifications

πŸ—οΈ Architecture

Smart Contract Layer (Cairo)

  • CredentialManager Contract: Core contract managing all health credentials
  • Provider Registry: Verified healthcare provider management
  • Access Control: Granular permission system for data sharing
  • Ownership Management: Secure transfer and management capabilities

Frontend Application (React + TypeScript)

  • Modern UI/UX: Built with React, TypeScript, and Tailwind CSS
  • Wallet Integration: Support for ArgentX, Braavos, and other Starknet wallets
  • Real-time Updates: Live blockchain state synchronization
  • Responsive Design: Mobile-first approach for global accessibility

Storage Layer

  • IPFS: Decentralized file storage via Pinata
  • Blockchain: Immutable credential metadata on Starknet
  • Local Cache: Client-side caching for improved performance

πŸš€ Application Flow

StarkMed Flow

1. User Registration & Wallet Connection

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   User Visits   β”‚ -> β”‚  Connect Wallet  β”‚ -> β”‚ Register Patientβ”‚
β”‚   StarkMed      β”‚    β”‚ (ArgentX/Braavos)β”‚    β”‚   On-Chain     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

2. Healthcare Provider Registration (Admin Only)

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚Contract Owner   β”‚ -> β”‚  Admin Panel     β”‚ -> β”‚Register Providerβ”‚
β”‚   Access        β”‚    β”‚    Access        β”‚    β”‚   On-Chain     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

3. Credential Issuance Workflow

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚Provider Creates β”‚ -> β”‚Document Upload   β”‚ -> β”‚  IPFS Storage   β”‚
β”‚  New Credential β”‚    β”‚ & Encryption     β”‚    β”‚   (Pinata)      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                 β”‚
                                 β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Patient       β”‚ <- β”‚  Credential      β”‚ <- β”‚Blockchain Mint  β”‚
β”‚ Notification    β”‚    β”‚   Available      β”‚    β”‚  (Starknet)     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

4. Credential Sharing & Verification

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Patient        β”‚ -> β”‚  Generate QR     β”‚ -> β”‚Third-Party      β”‚
β”‚ Shares Cred     β”‚    β”‚  Code/Link       β”‚    β”‚ Verification    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                 β”‚
                                 β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Verification   β”‚ <- β”‚ Blockchain       β”‚ <- β”‚  Input Cred     β”‚
β”‚    Result       β”‚    β”‚   Verification   β”‚    β”‚      ID         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

5. Access Control Management

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Credential     β”‚ -> β”‚  Manage Access   β”‚ -> β”‚Grant/Revoke     β”‚
β”‚    Owner        β”‚    β”‚   Modal          β”‚    β”‚  Permissions    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                 β”‚
                                 β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Authorized    β”‚ <- β”‚ Access Granted   β”‚ <- β”‚ On-Chain Tx     β”‚
β”‚    Viewers      β”‚    β”‚   Confirmed      β”‚    β”‚  Confirmation   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ› οΈ Technology Stack

Blockchain & Smart Contracts

  • Starknet: Layer 2 scaling solution for Ethereum
  • Cairo: Smart contract programming language
  • Scarb: Cairo package manager and build tool

Frontend

  • React 18: Modern UI library
  • TypeScript: Type-safe development
  • Vite: Fast build tool and development server
  • Tailwind CSS: Utility-first CSS framework
  • Starknet Kit: Wallet connection library
  • Lucide React: Modern icon library

Storage & Infrastructure

  • IPFS: Decentralized file storage
  • Pinata: IPFS pinning service
  • RPC Providers: Blockchain node access

πŸ“ Project Structure

StarkMed/
β”œβ”€β”€ credential_manager/          # Smart Contract Layer
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ credential_manager.cairo    # Main contract
β”‚   β”‚   └── lib.cairo                   # Contract exports
β”‚   β”œβ”€β”€ tests/                          # Contract tests
β”‚   β”œβ”€β”€ deploy.js                       # Deployment script
β”‚   β”œβ”€β”€ Scarb.toml                      # Project configuration
β”‚   └── deployment-sepolia.json         # Deployment info
β”‚
β”œβ”€β”€ frontend/                    # Frontend Application
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/         # UI Components
β”‚   β”‚   β”œβ”€β”€ contexts/           # React contexts
β”‚   β”‚   β”œβ”€β”€ hooks/              # Custom hooks
β”‚   β”‚   β”œβ”€β”€ lib/                # Utilities & contracts
β”‚   β”‚   β”œβ”€β”€ pages/              # Application pages
β”‚   β”‚   β”œβ”€β”€ services/           # Business logic
β”‚   β”‚   └── types/              # TypeScript definitions
β”‚   β”œβ”€β”€ public/                 # Static assets
β”‚   └── package.json            # Dependencies
β”‚
β”œβ”€β”€ LICENSE                     # MIT License
└── README.md                   # This file

πŸš€ Quick Start

Prerequisites

  • Node.js (v18 or higher)
  • Starknet Wallet (ArgentX or Braavos)
  • Cairo (for smart contract development)
  • Git

1. Clone the Repository

git clone https://github.com/rtb-12/starkmed.git
cd starkmed

2. Smart Contract Setup

cd credential_manager

# Install dependencies
scarb build

# Configure environment
cp .env.example .env
# Edit .env with your credentials

# Deploy to Sepolia (optional)
node deploy.js

3. Frontend Setup

cd ../frontend

# Install dependencies
npm install

# Configure environment
cp .env.example .env
# Add your Pinata API keys and contract address

# Start development server
npm run dev

4. Access the Application

Open http://localhost:8080 in your browser and connect your Starknet wallet.

πŸ”§ Configuration

Environment Variables

Frontend (.env)

# Pinata IPFS Configuration
VITE_PINATA_API_KEY=your_pinata_api_key
VITE_PINATA_SECRET_KEY=your_pinata_secret_key

# Contract Configuration
VITE_CONTRACT_ADDRESS=0x0746c9da88a54a60f534cfaefae0e72da73e7dc0ad3da449ffe60021622daa45
VITE_NETWORK=sepolia

# Application Configuration
VITE_APP_NAME=StarkMed
VITE_APP_VERSION=1.0.0

Smart Contract (.env)

# Network Configuration
STARKNET_NETWORK=sepolia
RPC_URL=https://starknet-sepolia.public.blastapi.io

# Account Configuration
ACCOUNT_ADDRESS=your_account_address
PRIVATE_KEY=your_private_key
CONTRACT_OWNER_ADDRESS=your_owner_address

πŸ“š API Reference

Smart Contract Functions

Public Functions

  • verify_credential(credential_id) - Verify credential authenticity
  • credential_exists(credential_id) - Check if credential exists
  • is_provider(address) - Check provider status
  • is_patient(address) - Check patient registration
  • get_credential_count() - Get total credential count

Provider Functions

  • issue_credential(patient, metadata_hash) - Issue new credential
  • register_patient() - Register as patient

Owner Functions

  • register_provider(address, name) - Register healthcare provider
  • transfer_ownership(new_owner) - Transfer contract ownership

Frontend Services

CredentialService

  • createCredential(form, walletAddress) - Create new credential
  • verifyCredential(credentialId) - Verify credential
  • getCredentials() - Get user credentials

AdminService

  • getAllProviders() - Get registered providers
  • registerProvider(address, name) - Register new provider
  • transferOwnership(newOwner) - Transfer ownership

πŸ§ͺ Testing

Smart Contract Tests

cd credential_manager
scarb test

Frontend Tests

cd frontend
npm test

πŸ”’ Security Features

Data Protection

  • End-to-end encryption for all medical documents
  • Zero-knowledge proofs for verification without data exposure (planned for future implementation)
  • Decentralized storage with IPFS prevents single points of failure

Access Control

  • Role-based permissions (Owner, Provider, Patient)
  • Granular access control for individual credentials
  • Time-limited access with automatic expiration
  • Audit trails for all access and modifications

Smart Contract Security

  • Owner-only admin functions with on-chain verification
  • Input validation for all contract interactions
  • Reentrancy protection and safe external calls
  • Event logging for transparency and monitoring

🌍 Deployment

Sepolia Testnet (Current)

  • Contract Address: 0x0746c9da88a54a60f534cfaefae0e72da73e7dc0ad3da449ffe60021622daa45
  • Network: Starknet Sepolia
  • Explorer: View on Starkscan

Production Deployment

For production deployment:

  1. Smart Contract: Deploy to Starknet Mainnet
  2. Frontend: Deploy to Vercel, Netlify, or similar
  3. IPFS: Configure production Pinata account
  4. Monitoring: Set up blockchain monitoring and alerts

🀝 Contributing

We welcome contributions! Please see our Contributing Guidelines for details.

Development Workflow

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Starknet Team for the amazing L2 infrastructure
  • OpenZeppelin for security best practices
  • Pinata for reliable IPFS services
  • Cairo Community for development resources

⚑ Built with ❀️ on Starknet - Empowering patients, securing health data, revolutionizing healthcare. ⚑

About

Revolutionary blockchain-based health passport built on Starknet, providing secure, private, and globally accessible medical credential management.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors