How subrata-bauri/healthchare-privacy works
HealthChain is a role-based healthcare application for registering patients, doctors and hospitals, sharing encrypted medical records under patient-approved access, and auditing activity without exposing access patterns on-chain. The main flow runs from role-specific UI through authenticated API controllers to record and access services; patients can revoke access by rotating encryption keys and re-encrypting records. Access events are mixed into Merkle batches, with roots anchored on Ethereum. The tree omits contract source files, so the on-chain subsystem is represented at its documented boundary; unsampled page and audit implementations are not inferred in detail.
Main entry points: blockchainService.js Contract integration · app.js Express API · keyRotationService.js Epoch key rotation · mixingService.js Access-log mixing
Components 25
Web application
- Role-based pages
frontend/src/pages - Session context
frontend/src/context/AuthContext.jsx - HTTP client
frontend/src/api/client.js - Wallet operations
frontend/src/api/blockchain.js
API and domain
- Express API
backend/src/app.js - Authentication routes
backend/src/routes/authRoutes.js - Record routes
backend/src/routes/recordRoutes.js - Access routes
backend/src/routes/accessRoutes.js - User routes
backend/src/routes/userRoutes.js - Key routes
backend/src/routes/keyRoutes.js - Record handling
backend/src/controllers/recordController.js - Access decisions
backend/src/controllers/accessController.js - Role administration
backend/src/controllers/userController.js - Key operations
backend/src/controllers/keyController.js - JWT and role checks
backend/src/middleware/auth.js
Privacy services
- Record encryption pipeline
backend/src/services/recordService.js - AES and hashing
backend/src/services/cryptoService.js - Epoch key rotation
backend/src/services/keyRotationService.js - Access-log mixing
backend/src/services/mixingService.js - Merkle proofs
backend/src/services/merkleService.js
Persistence and chain
- Encrypted file storage
backend/src/services/ipfsService.js - MongoDB domain records
backend/src/models - Contract integration
backend/src/services/blockchainService.js - Ethereum registries and anchors
blockchain
Other components
- Patients, doctors, hospitals, admins
Connections 43
- Patients, doctors, hospitals, admins → Role-based pages: use
- Role-based pages → Session context: authenticate
frontend/src/pages/DoctorDashboard.jsx - Role-based pages → HTTP client: request
frontend/src/pages/AccessManagement.jsx - Role-based pages → Wallet operations: sign transactions
frontend/src/pages/AccessManagement.jsx - Session context → HTTP client: refresh session
frontend/src/context/AuthContext.jsx - HTTP client → Express API: HTTP /api
- Express API → Authentication routes: mount
backend/src/app.js - Express API → Record routes: mount
backend/src/app.js - Express API → Access routes: mount
backend/src/app.js - Express API → User routes: mount
backend/src/app.js - Express API → Key routes: mount
backend/src/app.js - Record routes → JWT and role checks: protect routes
backend/src/routes/recordRoutes.js - Access routes → JWT and role checks: protect routes
backend/src/routes/accessRoutes.js - User routes → JWT and role checks: protect routes
backend/src/routes/userRoutes.js - Key routes → JWT and role checks: protect routes
backend/src/routes/keyRoutes.js - Record routes → Record handling: dispatch
backend/src/routes/recordRoutes.js - Access routes → Access decisions: dispatch
backend/src/routes/accessRoutes.js - User routes → Role administration: dispatch
backend/src/routes/userRoutes.js - Key routes → Key operations: dispatch
backend/src/routes/keyRoutes.js - Record handling → Record encryption pipeline: process records
backend/src/controllers/recordController.js - Record handling → MongoDB domain records: read and write
backend/src/controllers/recordController.js - Record handling → Contract integration: anchor and verify
backend/src/controllers/recordController.js - Record handling → Access-log mixing: log access
backend/src/controllers/recordController.js - Record encryption pipeline → AES and hashing: encrypt and decrypt
- Record encryption pipeline → Encrypted file storage: store files
- Access decisions → MongoDB domain records: persist grants
backend/src/controllers/accessController.js - Access decisions → Contract integration: check chain access
backend/src/controllers/accessController.js - Access decisions → Access-log mixing: record events
backend/src/controllers/accessController.js - Access decisions → Epoch key rotation: revoke and rotate
backend/src/controllers/accessController.js - Role administration → MongoDB domain records: manage profiles
backend/src/controllers/userController.js - Role administration → Contract integration: register on chain
backend/src/controllers/userController.js - Role administration → Access-log mixing: record events
backend/src/controllers/userController.js - Key operations → Epoch key rotation: manage epochs
backend/src/controllers/keyController.js - Key operations → Contract integration: anchor commitments
backend/src/controllers/keyController.js - Epoch key rotation → MongoDB domain records: read and update epochs
backend/src/services/keyRotationService.js - Epoch key rotation → AES and hashing: encrypt records
backend/src/services/keyRotationService.js - Epoch key rotation → Encrypted file storage: replace ciphertext
backend/src/services/keyRotationService.js - Epoch key rotation → Contract integration: anchor new epoch
backend/src/services/keyRotationService.js - Access-log mixing → MongoDB domain records: persist batches
backend/src/services/mixingService.js - Access-log mixing → Merkle proofs: build proofs
backend/src/services/mixingService.js - Access-log mixing → Contract integration: anchor root
backend/src/services/mixingService.js - Contract integration → Ethereum registries and anchors: call contracts
backend/src/services/blockchainService.js - Wallet operations → Ethereum registries and anchors: sign transactions