A blockchain-based healthcare platform built on Solana that gives patients true ownership and control over their medical records while providing hospitals, doctors, and insurers with secure, compliant, and fraud-proof access.
CypherMed leverages Solana's high-performance blockchain to create immutable audit trails of medical record access while keeping sensitive patient data encrypted in off-chain PostgreSQL databases. This hybrid approach ensures:
- Patient Sovereignty: Complete control over who accesses medical data
- HIPAA Compliance: Cryptographic proof of consent and access
- Fraud Prevention: Tamper-proof audit logs for insurers
- Emergency Access: Break-glass protocols for life-threatening situations
- Interoperability: Seamless data sharing between healthcare providers
- Patients can grant and revoke access to specific healthcare providers
- Granular permissions for doctors, hospitals, and insurance companies
- Individual access control per provider (not institution-wide by default)
- Time-based access grants with automatic expiration
- Condition-based access rules per record type
- Patient: Full ownership and control of all medical records
- Doctor: View and create records with patient permission
- Hospital: Institutional access to patient records during treatment
- Insurer: Read-only access for claims verification
- Emergency Responder: Temporary emergency access with audit trail
- Every access attempt is recorded on-chain (successful and failed)
- Timestamps for all record creation, modification, and access events
- Cryptographic proof of who accessed what and when
- Cannot be altered or deleted - permanent compliance record
- Real-time monitoring of unauthorized access attempts
- "Break-glass" access for life-threatening situations
- Emergency responders can access critical medical information
- All emergency access is logged with justification
- Post-emergency audit and review process
- Patient notification of emergency access
- General Medical Records: Patient history, diagnoses, treatments
- Prescriptions: Medication history and current prescriptions
- Lab Results: Blood work, imaging, pathology reports
- Visit Summaries: Doctor's notes and consultation records
- Immunization Records: Vaccination history
- Each record type has customizable access rules
- Sensitive medical data stored encrypted in off-chain PostgreSQL
- Only metadata, timestamps, and access logs stored on-chain
- Zero-knowledge proofs for verification without data exposure
- End-to-end encryption for all off-chain data
- Patient controls encryption keys
- HIPAA-compliant audit trails
- Cryptographic proof of patient consent
- Fraud-proof verification for insurance claims
- Regulatory compliance automation
- Exportable audit logs for legal requirements
- Healthcare providers can request access from patients
- Patients approve/deny access requests
- Automated notifications for pending requests
- Batch approval for multiple providers
- Access history and statistics
- Birth Registration: Hospital registers newborns with birth certificate
- Guardian Management: Parents control minor's records (auto-expires at 18)
- Age-Based Transfer: Automatic control handoff when patient turns 18
- Family Linking: Connect parent-child relationships for hereditary tracking
- Permanent Record: Never lose medical history from birth onward
- Patient Accounts: Identity and access control lists
- Access Grants: Permissions and expiration timestamps
- Audit Logs: Immutable record of all access events
- Record Metadata: Record IDs, types, timestamps, and hashes
- Emergency Access: Break-glass event logs
- Encrypted Medical Records: Full patient medical data
- IPFS/Arweave CIDs: Pointers to distributed storage (future)
- Encryption Keys: Patient-controlled key management
- Session Data: Temporary access tokens
β
Privacy: Sensitive data never touches the blockchain
β
Immutability: Access logs cannot be tampered with
β
Performance: Fast queries on off-chain DB, verified on-chain
β
Cost-Effective: Only critical data incurs blockchain storage costs
β
Scalability: PostgreSQL handles high-volume medical data
- Solana: High-performance L1 blockchain
- Anchor Framework: Rust-based Solana development framework
- Rust: Smart contract programming language
- Helius RPC: Enhanced Solana RPC with better reliability and developer tooling
- SPL Token (Future): For tokenomics/payment system
- PostgreSQL: Encrypted medical record storage
- Node.js/Express: API layer between frontend and blockchain
- TypeScript: Type-safe backend development
- Socket.IO: Real-time notifications
- Next.js/React: User interface framework
- Solana Web3.js: Blockchain interaction
- Wallet Adapter: Integration with Phantom, Solflare
- TailwindCSS: UI styling
- Encryption: AES-256 for data at rest
- Key Management: Patient-controlled private keys
- Access Control: On-chain authorization checks
- Audit Logging: Immutable blockchain records
CypherMed uses Helius RPC for:
- Reliable RPC: Higher rate limits and better uptime than public endpoints
- Enhanced Performance: Faster transaction confirmation and data retrieval
- Developer Tooling: Access to Helius APIs for transaction parsing and webhooks
To configure Helius, set your API key in app/.env.local:
NEXT_PUBLIC_HELIUS_API_KEY=your_helius_api_key_hereCypherMed/
βββ programs/
β βββ cyphermed/
β βββ src/
β β βββ lib.rs # Main program entry
β β βββ state/ # Account structures
β β β βββ mod.rs
β β β βββ patient.rs # Patient account
β β β βββ record.rs # Medical record metadata
β β β βββ access_grant.rs # Access permissions
β β β βββ audit_log.rs # Audit trail entries
β β βββ instructions/ # Program instructions
β β β βββ mod.rs
β β β βββ initialize_patient.rs
β β β βββ create_record.rs
β β β βββ grant_access.rs
β β β βββ revoke_access.rs
β β β βββ access_record.rs
β β β βββ emergency_access.rs
β β βββ errors.rs # Custom error codes
β β βββ utils.rs # Helper functions
β βββ Cargo.toml
βββ tests/ # Integration tests
βββ migrations/ # Deployment scripts
βββ app/ # Frontend (future)
βββ Anchor.toml # Anchor configuration
βββ Cargo.toml # Workspace configuration
βββ README.md # This file
-
Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh source $HOME/.cargo/env
-
Install Solana CLI
sh -c "$(curl -sSfL https://release.solana.com/stable/install)" export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH"
-
Install Anchor
cargo install --git https://github.com/coral-xyz/anchor avm --locked --force avm install latest avm use latest
-
Install Node.js & Yarn
# Install Node.js 18+ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash nvm install 18 nvm use 18 # Install Yarn npm install -g yarn
-
Clone the repository
git clone https://github.com/StaySafe020/CypherMed.git cd CypherMed -
Install dependencies
yarn install
-
Configure Solana for local development
solana config set --url localhost solana-keygen new # Create a new keypair if needed
-
Start local validator
solana-test-validator
-
Build the program
anchor build
-
Run tests
anchor test -
Deploy to devnet
solana config set --url devnet solana airdrop 2 # Get devnet SOL anchor deploy
We provide a Docker Compose file and Prisma setup to run a local Postgres instance for development and testing.
Why use Docker here:
- Reproducible local DB (same Postgres version across developers)
- Easy CI parity for migrations and integration tests
Quick start (from repository root):
# 1) Start local Postgres using the provided Compose file
cd backend
docker-compose up -d
# 2) Create the `.env` file used by Prisma
echo 'DATABASE_URL="postgresql://postgres:postgres@localhost:5432/cyphermed?schema=public"' > .env
# 3) Generate Prisma client and run migrations
npx prisma generate
npx prisma migrate dev --name init
# 4) Seed a test patient (script provided)
npm run prisma:seed
# 5) Stop containers when done
docker-compose downNotes:
- The Compose file uses
postgres:15and mounts a seed SQL file on first init. If your system has the legacydocker-composebinary, usedocker-compose(we include support for that); otherwisedocker composeworks when the Docker Compose plugin is available. - Prisma creates tables with model-casing (e.g.,
"Patient"). When querying directly withpsql, quote identifiers or use the exact casing.
If you prefer not to run Docker locally, use a managed Postgres instance and set DATABASE_URL accordingly in backend/.env.
# Run all tests
anchor test
# Run specific test file
anchor test --skip-build tests/patient.test.ts
# Run with detailed logs
RUST_LOG=debug anchor test// Patient registers on the platform
initialize_patient(
patient_wallet: Pubkey,
name: String,
date_of_birth: i64,
)// Patient grants a doctor access to specific record types
grant_access(
patient: Pubkey,
provider: Pubkey,
role: Role::Doctor,
record_types: vec![RecordType::GeneralMedical, RecordType::LabResults],
expiration: Some(timestamp + 30_days),
)// Doctor creates a new medical record
create_record(
patient: Pubkey,
provider: Pubkey,
record_type: RecordType::Prescription,
data_hash: String, // Hash of encrypted off-chain data
ipfs_cid: String, // IPFS content identifier
)// Emergency responder accesses patient records
emergency_access(
responder: Pubkey,
patient: Pubkey,
justification: String, // "Car accident, unconscious patient"
)// Anyone can verify access history on-chain
get_audit_logs(
patient: Pubkey,
from_timestamp: i64,
to_timestamp: i64,
)- Private Keys: Patients must securely store their Solana wallet keys
- Off-Chain Security: PostgreSQL must be properly secured and encrypted
- Access Control: All on-chain instructions verify permissions
- Emergency Access: Requires justification and creates permanent audit trail
- Data Encryption: All off-chain medical data is encrypted at rest
- Transport Security: TLS/SSL for all API communications
- β Project initialization
- β Smart contract development (Anchor/Rust)
- β Patient registration & management
- β Medical record CRUD (create/update/delete)
- β Access grant/revoke system
- β Access request workflow (request β approve/deny)
- β Batch access grants
- β Audit logging system (on-chain)
- β Comprehensive test suite (17 tests passing)
- β Emergency access system (break-glass)
- β Time-based permissions (expiration support)
- β³ Multi-signature for sensitive records
- β Comprehensive testing
- β PostgreSQL integration (schema + migrations)
- β Encryption key management
- β REST API development (patients, records, access requests, notifications)
- β WebSocket for real-time notifications
- β Guardian system for lifetime records
- β Birth registration workflow
- β³ React web application
- β³ Patient dashboard
- β³ Provider interface
- β³ Wallet integration
- β³ Security audit
- β³ Performance optimization
- β³ Documentation
- β³ Mainnet deployment
- β³ Token economics
- β³ AI-powered insights
- β³ Mobile applications
- β³ Interoperability standards (FHIR)
Contributions are welcome! Please follow these guidelines:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the APACHE 2.0 License - see the LICENSE file for details.
Project Maintainer: StaySafe020
Repository: https://github.com/StaySafe020/CypherMed
This is experimental software for healthcare data management. Always ensure compliance with local healthcare regulations (HIPAA, GDPR, etc.) and conduct thorough security audits before production use. Not intended for production medical use without proper security audits and regulatory approval.
- Solana Foundation for the high-performance blockchain
- Anchor Framework team for excellent developer tools
- Open-source healthcare community
- All contributors and supporters of decentralized healthcare
Built with β€οΈ on Solana