Skip to content

Decentralized system for hospitals and medical records using blockchain technology.

Notifications You must be signed in to change notification settings

TanujTS/aarovia

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ₯ Decentralized Medical Records Platform (MedChain)

A revolutionary blockchain-powered platform for secure, patient-controlled medical record management built with modern technologies.

πŸ—οΈ Project Structure

This is a Turborepo monorepo with the following structure:

devjams/
β”œβ”€β”€ apps/
β”‚   β”œβ”€β”€ web/              # Next.js 14 frontend (Patient/Doctor dashboard)
β”‚   β”‚   β”œβ”€β”€ src/app/      # App router pages
β”‚   β”‚   β”œβ”€β”€ src/components/ # React components
β”‚   β”‚   └── src/styles/   # Global styles
β”‚   └── api/              # Express.js API server
β”‚       β”œβ”€β”€ src/routes/   # API endpoints
β”‚       β”œβ”€β”€ src/middleware/ # Auth, validation, etc.
β”‚       └── src/index.ts  # Server entry point
β”œβ”€β”€ packages/
β”‚   β”œβ”€β”€ database/         # Drizzle ORM schemas and migrations
β”‚   β”‚   β”œβ”€β”€ src/schema/   # Database tables and relations
β”‚   β”‚   └── drizzle.config.ts # Drizzle configuration
β”‚   β”œβ”€β”€ web3/             # Blockchain integration utilities
β”‚   β”‚   β”œβ”€β”€ src/wallet.ts # Wallet operations
β”‚   β”‚   β”œβ”€β”€ src/contracts.ts # Smart contract interactions
β”‚   β”‚   └── src/ipfs.ts   # IPFS file storage
β”‚   β”œβ”€β”€ types/            # Shared TypeScript types
β”‚   └── config/           # Shared configuration
β”œβ”€β”€ .env.example          # Environment variables template
β”œβ”€β”€ setup.sh              # Automated setup script
└── turbo.json            # Turborepo configuration

πŸš€ Quick Start

Prerequisites

  • Node.js 18+ - Download here
  • PostgreSQL - Local installation or Neon DB cloud database
  • Git - For version control

Automated Setup

# Clone the repository
git clone <your-repo-url>
cd devjams

# Run the automated setup script
./setup.sh

Manual Setup

# Install dependencies
bun install

# Copy environment file
cp .env.example .env.local

# Update .env.local with your database URL and API keys

# Build all packages
bun run build

# Start development servers
bun run dev

πŸ› οΈ Tech Stack

Core Technologies

  • Frontend: Next.js 14 (App Router), React 18, TypeScript
  • Backend: Express.js, Node.js, TypeScript
  • Database: PostgreSQL with Drizzle ORM
  • Blockchain: Ethereum, Solidity, Ethers.js v6
  • Storage: IPFS/Filecoin for decentralized file storage
  • Styling: TailwindCSS, Radix UI components
  • Monorepo: Turborepo for build orchestration

Key Features

  • πŸ” Patient-Controlled Access: Patients own and control their medical data
  • ⛓️ Blockchain Security: Immutable record hashes stored on-chain
  • πŸ“ Decentralized Storage: Medical files stored on IPFS/Filecoin
  • 🚨 Emergency Access: ICE mode for critical health information
  • πŸ₯ Provider Integration: APIs for healthcare providers to integrate
  • πŸ” Audit Trail: Complete history of data access and sharing

πŸ“‹ Available Scripts

Development

bun run dev          # Start all development servers
bun run build        # Build all packages and apps
bun run lint         # Lint all packages
bun run type-check   # TypeScript type checking
bun run test         # Run tests across all packages
bun run clean        # Clean all build artifacts

Database Operations

bun run db:generate  # Generate database migrations
bun run db:push      # Push schema changes to database
bun run db:migrate   # Run pending migrations

πŸ₯ User Roles & Workflows

πŸ‘¨β€βš•οΈ For Patients

  1. Onboarding: Connect wallet, create profile
  2. Upload Records: Encrypt and store medical documents on IPFS
  3. Share Access: Grant temporary access to healthcare providers
  4. Emergency Mode: Set up ICE profile for emergencies
  5. Manage Access: View and revoke provider permissions

πŸ₯ For Healthcare Providers

  1. Registration: Submit credentials for verification
  2. Request Access: Ask patients for record access
  3. View Records: Access patient data with granted permissions
  4. Upload Results: Add test results and reports (with consent)
  5. Integration: Use APIs to connect existing systems

πŸ”§ For Administrators

  1. Provider Verification: Verify healthcare provider credentials
  2. System Monitoring: Monitor platform usage and security
  3. Compliance: Ensure HIPAA/GDPR compliance

🌐 Environment Setup

Create a .env.local file in the root directory:

# Database Configuration
DATABASE_URL="postgresql://username:password@localhost:5432/medical_records"

# API Configuration
NEXT_PUBLIC_API_URL="http://localhost:3001"
PORT=3001

# Authentication
JWT_SECRET="your-super-secret-jwt-key-change-this-in-production"

# Blockchain Configuration
NEXT_PUBLIC_CHAIN_ID=1
NEXT_PUBLIC_RPC_URL="https://mainnet.infura.io/v3/your-infura-key"

# Smart Contract Addresses (deploy these first)
MEDICAL_RECORDS_ACCESS_CONTRACT="0x..."
MEDICAL_RECORDS_STORAGE_CONTRACT="0x..."

# IPFS Configuration
IPFS_API_URL="https://ipfs.infura.io:5001"
IPFS_GATEWAY_URL="https://ipfs.io/ipfs/"

# Pinata (for IPFS pinning)
PINATA_API_KEY="your-pinata-api-key"
PINATA_SECRET_KEY="your-pinata-secret-key"

# Environment
NODE_ENV="development"

οΏ½ Deployment Guide

Frontend (Vercel)

  1. Connect your GitHub repository to Vercel
  2. Set environment variables in Vercel dashboard
  3. Deploy automatically on git push

Backend (Railway/Heroku)

  1. Create new app on Railway or Heroku
  2. Connect GitHub repository
  3. Set environment variables
  4. Deploy with auto-deployments enabled

Database (Neon/Supabase)

  1. Create PostgreSQL database on Neon or Supabase
  2. Update DATABASE_URL in environment variables
  3. Run migrations: bun run db:push

Smart Contracts (Hardhat)

# Deploy to testnet first
npx hardhat deploy --network sepolia

# Deploy to mainnet
npx hardhat deploy --network mainnet

πŸ“± Getting Started Walkthrough

Patient Journey

  1. Connect Wallet: Use MetaMask or WalletConnect
  2. Create Profile: Fill in basic information and emergency contacts
  3. Upload First Record: Add a medical document (PDF, image, etc.)
  4. Set ICE Mode: Configure emergency access information
  5. Share with Doctor: Grant access to a healthcare provider

Provider Journey

  1. Register: Submit license and verification documents
  2. Wait for Approval: Admin reviews and verifies credentials
  3. Request Access: Ask patient for record access
  4. View Records: Access granted patient information
  5. Upload Results: Add new medical records for patients

πŸ§ͺ Testing

# Run all tests
bun run test

# Run specific package tests
bun run test --filter=@aarovia/api
bun run test --filter=@aarovia/web

# Run with coverage
bun run test -- --coverage

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Run tests and linting
  5. Submit a pull request

πŸ“„ License

This project is licensed under the MIT License.

About

Decentralized system for hospitals and medical records using blockchain technology.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •