Architecture Overview
Salud Health is a privacy-preserving medical records management system built on the Aleo blockchain. The platform enables patients to store encrypted health records on-chain and securely share them with healthcare providers using temporary, cryptographically-secured access tokens.High-Level Architecture
Three-Tier Architecture
1. Frontend (React + TypeScript)
Technology Stack:- React 18 with TypeScript
- Vite 5.0 (build tool)
- Tailwind CSS (styling)
- Zustand (state management)
- IndexedDB (local caching)
- User interface for patients and doctors
- Client-side data encryption before transmission
- QR code generation and scanning
- Local record caching for performance
- Session state management
~/workspace/source/Main APP/
2. Backend API (Node.js)
Technology Stack:- Node.js 18+
- Express.js (REST API)
- Aleo SDK (@provablehq/sdk)
- In-memory session storage
- Wallet connection and session management
- Transaction execution on Aleo blockchain
- Aleo SDK integration
- Record retrieval from blockchain
- Access token validation
~/workspace/source/backend/
3. Blockchain Layer (Aleo)
Smart Contract:salud_health_records_v6.aleo
Core Components:
Private Records (Patient-Only Visibility)
Public Mappings (Access Control)
~/workspace/source/Salud Health Contract/src/main.leo
Component Communication
Patient Record Creation Flow
Doctor Access Grant Flow
Data Storage Strategy
On-Chain Storage (Aleo Blockchain)
Private Records:- Medical record data (encrypted, ~360 bytes per record)
- Only accessible by record owner
- Permanent, immutable storage
- Access grants (who has access to what)
- Record metadata (for discovery)
- Access token validity flags
- Patient record counts
Off-Chain Storage
Frontend (IndexedDB):- Cached records for fast retrieval
- Session state
- Temporary UI data
- Active sessions (sessionId → wallet)
- Private keys (session duration only)
- No persistent medical data storage
Security Architecture
Multi-Layer Privacy Protection
Authentication & Authorization
Patient Authentication:- Private key input
- Backend creates session
- Session ID stored in frontend
- All transactions signed with patient’s key
- QR code contains:
{recordId, accessToken, expiresAt} - Doctor scans QR code
- System calls
verify_access()on-chain - Smart contract validates:
- Token exists in
access_grantsmapping - Doctor address matches grant
- Current block height < expiration
- Grant not revoked
- Token exists in
Scalability Considerations
Frontend Performance
- Code splitting by route
- Lazy loading for QR scanner (heavy library)
- Local caching with IndexedDB
- Optimistic UI updates
Backend Performance
- Stateless API design
- Session-based connection pooling
- Async transaction handling
- Connection timeout management
Blockchain Constraints
- Record size limit: ~360 bytes encrypted per record
- Block time: ~15 seconds
- Transaction fees: paid by patient
- Storage: permanent on-chain
Workarounds for Large Data
For medical records exceeding 360 bytes:Technology Stack Summary
| Layer | Technology | Purpose |
|---|---|---|
| Frontend | React 18 + TypeScript | User interface |
| Vite 5.0 | Build tooling | |
| Tailwind CSS | Styling | |
| Zustand | State management | |
| Backend | Node.js 18+ | API server |
| Express.js | REST API framework | |
| Aleo SDK | Blockchain interaction | |
| Blockchain | Aleo | Privacy-preserving L1 |
| Leo Language | Smart contract | |
| Storage | IndexedDB | Client-side cache |
| Aleo Records | On-chain private data | |
| Aleo Mappings | On-chain public state |
Deployment Architecture
Development Environment
Production Environment
Key Design Decisions
Why Private Key Input?
Salud requires direct private key input (vs. browser wallet connection) because:- Client-side encryption: Medical data must be encrypted in the browser using the private key before transmission
- Zero-knowledge operations: Cryptographic proofs require direct key access
- Access token generation: Secure token creation needs private key cryptography
- HIPAA-grade privacy: Browser wallets don’t expose keys for encryption operations
Why Backend API?
Despite being a dApp, Salud uses a backend for:- Aleo SDK complexity: SDK requires Node.js environment
- Session management: Maintains wallet connections
- Transaction orchestration: Simplifies complex multi-step flows
- Error handling: Provides better UX with retry mechanisms
Why 12 Field Elements?
Medical records use 12 field elements (~360 bytes capacity):- Sufficient for basic records: Covers most medical notes, prescriptions, lab results
- Gas efficiency: Balance between capacity and transaction cost
- Aleo constraints: Field elements are native to Leo language
- Extensibility: Can create multiple records for larger data
Further Reading
Data Flow
Detailed data flow diagrams for all operations
Encryption
Encryption implementation and security details