DMRX is an open-source, patient-controlled medical records exchange built around encrypted off-chain storage and Stellar/Soroban auditability.
The core idea: hospitals issue trusted records, patients control access, doctors receive temporary scoped permissions, and every access event is auditable without putting private medical files on-chain.
Google Drive for health records, but patient-owned, encrypted by default, and blockchain-auditable.
Medical records are often trapped inside hospital systems, shared through slow manual processes, or carried physically by patients. DMRX provides a portable exchange layer where records can be verified across institutions while patients remain in control.
DMRX is designed for hospitals, clinics, doctors, patients, HMOs, NGOs, rural health programs, governments, regulators, and telemedicine platforms.
Stellar is useful for identity, fast verification, low-cost transactions, and multi-party trust systems. DMRX uses Stellar and Soroban for compact proofs, permission state, identity references, and audit logs.
DMRX does not use the blockchain as file storage. Clinical files stay encrypted off-chain. Stellar stores hashes, grants, revocations, and access proofs.
- Patient-controlled access.
- Medical files encrypted before upload.
- Minimal data on-chain.
- Signed records from verified institutions.
- Temporary and scoped permissions.
- Revocable access.
- Tamper detection with hashes.
- Fully auditable access history.
- Open-source and self-hostable.
This repository is an implementation scaffold. It includes frontend app shells, backend service skeletons, starter Soroban contracts, shared TypeScript packages, Prisma metadata models, and monorepo configuration.
It is not production-ready yet. Authentication, deployed contracts, complete storage adapters, full tests, CI, and compliance hardening still need to be completed.
Frontend Apps
Patient Portal
Hospital Dashboard
Doctor Dashboard
|
v
Backend Services
Auth Service
Records Service
Permissions Service
Audit Service
|
v
---------------------------------------------------------------
| Stellar/Soroban | PostgreSQL | Redis | IPFS/S3/MinIO |
| Contracts | Metadata | Cache | Encrypted files |
---------------------------------------------------------------
| Layer | Stores |
|---|---|
| Stellar/Soroban | record hashes, DID references, permission grants, revocations, access audit events, contract rules |
| PostgreSQL | actors, record metadata, permission metadata, audit references, chain transaction references |
| IPFS/S3/MinIO | encrypted PDFs, lab results, imaging files, prescriptions, notes, scans, audio, video |
| Actor | Capabilities |
|---|---|
| Patient | view records, grant access, revoke access, review audit logs, share temporary scoped access |
| Hospital | upload records, encrypt files, sign metadata, anchor hashes, verify authenticity |
| Doctor | request access, read authorized records, upload consultation notes, sign treatment entries |
| Regulator/Admin | verify institutions, monitor audits, review abuse reports, investigate emergency access |
dmrx/
frontend/
patient-portal/
hospital-dashboard/
doctor-dashboard/
backend/
auth-service/
records-service/
permissions-service/
audit-service/
contracts/
identity/
access-control/
audit-log/
packages/
shared/
crypto/
database/
stellar-client/
storage/
.env.example
package.json
pnpm-workspace.yaml
tsconfig.base.json
turbo.json
The main product folders are frontend/, backend/, and contracts/. The packages/ folder holds reusable code shared across apps and services.
| App | Port | Purpose |
|---|---|---|
frontend/patient-portal |
3000 |
patient records, permissions, revocations, audit history |
frontend/hospital-dashboard |
3001 |
record upload, encryption, signing, hash anchoring |
frontend/doctor-dashboard |
3002 |
access requests, authorized record viewing, consultation notes |
| Service | Port | Starter endpoints | Responsibility |
|---|---|---|---|
auth-service |
4000 |
GET /api/auth/health, POST /api/auth/identities |
wallet identity, DID profile, roles, sessions, institution verification |
records-service |
4010 |
GET /api/records/health, POST /api/records |
encryption orchestration, metadata, hashing, storage, chain anchoring |
permissions-service |
4020 |
GET /api/permissions/health, POST /api/permissions/grants |
grants, revocations, expiration, scoped access, emergency access |
audit-service |
4030 |
GET /api/audit/health, POST /api/audit/events |
access logs, audit references, patient history, regulator queries |
| Package | Purpose |
|---|---|
packages/shared |
domain types, actor roles, record scopes, audit actions |
packages/crypto |
hashing, AES encryption helpers, key wrapping interfaces |
packages/database |
Prisma schema and database client |
packages/storage |
S3/MinIO storage interface scaffold |
packages/stellar-client |
Stellar/Soroban client wrapper scaffold |
| Contract | Purpose |
|---|---|
contracts/identity |
registers identity references, DID strings, roles, and verification state |
contracts/access-control |
stores grants, grantees, scopes, record references, expiration, revocation, emergency flags |
contracts/audit-log |
stores compact access proofs and emits audit events for indexers |
Connect wallet -> create DID profile -> store encrypted profile metadata -> register identity reference on-chain
Select patient DID -> upload file -> encrypt with AES-256-GCM -> wrap AES key for patient -> upload encrypted file -> save metadata -> anchor hash
Doctor requests access -> patient reviews scope and duration -> patient approves records -> grant is stored -> grant is anchored through Soroban
Doctor opens record -> backend checks active grant -> encrypted file is retrieved -> access event is logged -> audit proof is anchored
Emergency requested -> multi-party approval required -> time-limited emergency grant created -> all access events marked for review
Security is critical because DMRX handles medical data. Required controls include end-to-end encryption, zero-trust service boundaries, role-based access control, patient-controlled grants, time-limited permissions, revocation support, hardware key support, secure key recovery, audit logging, multi-signature emergency access, least-privilege credentials, and no clinical content in public chain data.
Record created
-> generate AES data key
-> encrypt file with AES-256-GCM
-> hash original plaintext
-> wrap AES key for patient public key
-> upload encrypted file
-> store encrypted URI and key reference
-> anchor hash and metadata proof
Decrypt file -> calculate SHA-256 hash -> compare with anchored hash -> flag mismatch if hashes differ
This supports fraud detection, insurance disputes, medico-legal evidence, and record authenticity checks.
| Model | Purpose |
|---|---|
Actor |
patient, doctor, hospital, or regulator identity |
MedicalRecord |
encrypted record metadata and chain references |
PermissionGrant |
scoped patient-approved access |
AuditEvent |
record access and permission events |
Copy .env.example to .env and fill in local values.
cp .env.example .envImportant variables:
DATABASE_URLREDIS_URLSTORAGE_PROVIDERS3_ENDPOINTS3_BUCKETSTELLAR_NETWORKSTELLAR_HORIZON_URLSOROBAN_RPC_URLIDENTITY_CONTRACT_IDACCESS_CONTROL_CONTRACT_IDAUDIT_LOG_CONTRACT_IDJWT_SECRETDID_METHOD
Never commit real secrets.
Prerequisites:
- Node.js 20+
- pnpm 9+
- Rust stable
- Soroban CLI
- Docker Desktop or local PostgreSQL
Install dependencies:
pnpm installGenerate Prisma client:
pnpm db:generateRun all workspace dev tasks:
pnpm devRun a single frontend app:
pnpm --filter @dmrx/patient-portal dev
pnpm --filter @dmrx/hospital-dashboard dev
pnpm --filter @dmrx/doctor-dashboard devRun a single backend service:
pnpm --filter @dmrx/auth-service dev
pnpm --filter @dmrx/records-service dev
pnpm --filter @dmrx/permissions-service dev
pnpm --filter @dmrx/audit-service devBuild contracts:
pnpm contracts:build| Command | Description |
|---|---|
pnpm install |
Install dependencies |
pnpm dev |
Run development tasks |
pnpm build |
Build workspace |
pnpm lint |
Run lint/type checks |
pnpm typecheck |
Type-check workspace |
pnpm test |
Run test scripts |
pnpm format |
Format supported files |
pnpm db:generate |
Generate Prisma client |
pnpm db:migrate |
Run Prisma migrations |
pnpm contracts:build |
Build Soroban contracts |
DMRX should include frontend workflow tests, backend unit and integration tests, contract tests for identity and permissions, security tests for encryption and access control, and end-to-end tests for patient grant and doctor access flows.
| Phase | Goals |
|---|---|
| Phase 1 | patient registration, hospital upload, record hashing, encrypted storage, basic permission sharing |
| Phase 2 | doctor dashboard, audit logs, QR sharing, revocation UX |
| Phase 3 | emergency access, insurance verification, regulator dashboard, mobile responsiveness |
| Phase 4 | AI summaries, medication checks, offline rural sync, interoperability, national identity linkage |
- AI assistant layer for summaries and clinical checks.
- HMO and insurance verification workflows.
- Offline-first rural clinic sync.
- Government institution registry.
- Mobile app.
- Multi-country interoperability.
DMRX is a technical scaffold, not a compliance-certified medical product. Before real-world use, teams must review applicable health data laws, security requirements, data residency rules, clinical governance, and operational controls.
Do not use this scaffold with real patient data until security, legal, operational, and clinical reviews are complete.
Good first contribution areas include docs, Docker infrastructure, contract tests, Stellar client calls, Prisma migrations, storage adapters, frontend forms, API wiring, and CI checks.
This project is licensed under the MIT License. See LICENSE.