A blockchain-based healthcare records management system built on the Stacks ecosystem using Clarity smart contracts and React.
- Project Overview
- Architecture
- Project Structure
- Smart Contracts
- Frontend Application
- Getting Started
- Development
- Testing
- Deployment
- Security Features
- Contributing
HealthEncrypted is a decentralized application (dApp) that enables secure management of healthcare records on the Stacks blockchain. The platform revolutionizes healthcare data management by providing:
- Patient-controlled health records with granular access control
- Secure provider access management with role-based permissions
- Decentralized data storage ensuring data integrity and availability
- HIPAA-compliant data handling and privacy protection
- Immutable audit trails for all record access and modifications
The project follows a modular architecture with clear separation of concerns:
HealthEncrypted/
├── contracts/ # Clarity smart contracts
├── secure-health-frontend/ # React frontend application
├── tests/ # Contract test files
├── settings/ # Environment configurations
├── Clarinet.toml # Clarity project configuration
└── package.json # Project dependencies
PatientRecord.clar
- Main contract implementing:- Patient record management
- Access control mechanisms
- Healthcare provider verification
- Data encryption standards
src/
├── components/
│ ├── auth/ # Authentication components
│ │ ├── AuthGuard.tsx
│ │ ├── AuthStatus.tsx
│ │ ├── ConnectWallet.tsx
│ │ └── RoleGuard.tsx
│ ├── common/ # Reusable UI components
│ │ ├── Alert.tsx
│ │ ├── Button.tsx
│ │ ├── Input.tsx
│ │ └── Loading.tsx
│ ├── layout/ # Layout components
│ │ ├── Footer.tsx
│ │ ├── Header.tsx
│ │ ├── Layout.tsx
│ │ └── Sidebar.tsx
│ ├── patient/ # Patient-specific components
│ │ ├── AccessControl.tsx
│ │ ├── PatientRecords.tsx
│ │ ├── PatientRegistration.tsx
│ │ └── RecordUpdate.tsx
│ └── provider/ # Healthcare provider components
│ ├── PatientList.tsx
│ ├── ProviderRegistration.tsx
│ └── RecordView.tsx
├── contexts/ # React contexts
│ └── AuthContext.tsx
├── hooks/ # Custom React hooks
│ ├── useAuth.ts
│ ├── useContract.ts
│ └── useIPFS.ts
├── pages/ # Main application pages
│ ├── Dashboard.tsx
│ ├── Home.tsx
│ ├── PatientDashboard.tsx
│ └── ProviderDashboard.tsx
└── utils/ # Utility functions
├── constants.ts
├── helpers.ts
└── types.ts
- Node.js (v16.0.0 or later)
- npm (v8.0.0 or later)
- Clarinet (latest version)
- Stacks Wallet for authentication
- Clone the repository:
git clone https://github.com/gboigwe/HealthEncrypted.git
cd HealthEncrypted
- Install project dependencies:
npm install
cd secure-health-frontend
npm install
- Set up development environment:
# Configure Clarinet for smart contract development
clarinet integrate
# Start the frontend development server
cd secure-health-frontend
npm run dev
This project was developed with assistance from AI, which helped with:
- Smart contract architecture and optimization
- Frontend component structure and React hooks implementation
- TypeScript type definitions and interfaces
- Security pattern implementations
- Documentation and code comments
- Test case suggestions
All AI suggestions were carefully reviewed and validated to ensure code quality, security, and best practices. The final implementation decisions and critical security features were human-verified.
- Use Clarinet for contract testing and deployment
- Follow the Clarity best practices and patterns
- Test all functions thoroughly using the test suite
- Built with Vite + React + TypeScript
- Utilizes Tailwind CSS for styling
- Implements responsive design principles
# Run contract tests
clarinet test
# Check contract syntax
clarinet check
# Run frontend tests
cd secure-health-frontend
npm test
- Configure deployment settings in
settings/Devnet.toml
- Deploy contracts:
clarinet deploy --network testnet
- Build the production bundle:
cd secure-health-frontend
npm run build
- Deploy to your hosting service of choice
The platform implements multiple layers of security:
-
Smart Contract Security
- Role-based access control
- Function-level authorization checks
- Input validation and sanitization
- Secure data storage patterns
-
Frontend Security
- Wallet connection security
- Session management
- Data encryption in transit
- Protected routes and components
We welcome contributions to HealthEncrypted! Please follow these steps:
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to your branch
- Create a Pull Request
- Follow the established code style and patterns
- Write clear commit messages
- Include tests for new features
- Update documentation as needed
- All code changes require review
- Address review feedback promptly
- Ensure CI/CD checks pass
- Keep changes focused and atomic