[WIP] Technical Requirements

Purpose

This document provides technical specifications and architecture guidelines for building the AarogyaDost MVP.

Updated: Based on [[product/research/opensource-tools-to-use|research on open source tools]], this document recommends tech stack optimized for local-first, privacy-focused health data management.

Related: [[mvp-prd]] | [[mvp-metrics-framework]] | [[product/research/opensource-tools-to-use]]


Architecture Principles

1. Local-First

  • Data stored on user's device by default

  • App works fully offline

  • No dependency on cloud services for core features

  • Optional cloud backup (post-MVP)

2. Privacy by Design

  • End-to-end encryption

  • No data leaves device without explicit consent

  • Anonymized analytics only

  • Zero-knowledge architecture

3. Performance-First

  • Fast app launch (<3s)

  • Smooth UI interactions (60fps)

  • Efficient data processing

  • Minimal resource usage

4. Simple & Maintainable

  • Clear separation of concerns

  • Well-documented code

  • Automated testing

  • Easy to debug


Tech Stack Recommendations

Pros:

  • ✅ Cross-platform (macOS, Windows, Linux) with single codebase

  • ✅ Fast development (web technologies)

  • ✅ Rich ecosystem (npm packages)

  • ✅ Easy to hire developers (React common)

  • ✅ Hot reload for fast iteration

Cons:

  • ❌ Larger app size (~150MB+)

  • ❌ Higher memory usage

  • ❌ Slower startup time

Stack:

Option B: Tauri + React (Better Performance)

Pros:

  • ✅ Smaller app size (~5-10MB)

  • ✅ Lower memory usage

  • ✅ Faster startup

  • ✅ Better security (Rust backend)

Cons:

  • ❌ Newer framework (smaller community)

  • ❌ Steeper learning curve (Rust)

  • ❌ Fewer libraries/plugins

Stack:

Option C: Native Apps (Best Performance, Slower Development)

Pros:

  • ✅ Best performance and UX

  • ✅ Smallest app size

  • ✅ Platform-native feel

Cons:

  • ❌ Separate codebases (Swift for macOS, Kotlin/C# for Windows)

  • ❌ 2-3x development time

  • ❌ Harder to maintain

Not recommended for MVP (iterate to native later if needed)

Recommendation: Electron + React

  • Best balance of speed-to-market and functionality

  • Single codebase for all platforms

  • Easy to iterate and add features

  • Can migrate to Tauri later if performance becomes issue


Application Architecture

High-Level Architecture

Folder Structure


Database Schema

SQLite Schema


Core Services

1. OCR Service (Smart OCR for Indian Lab Reports)

Responsibility: Extract structured data from Indian medical documents with multi-language support

Research Context: See [[product/research/opensource-tools-to-use]] for detailed OCR technology evaluation

Indian Lab Report Challenges:

  • Multiple formats: Thyrocare, Dr. Lal PathLabs, Apollo, SRL Diagnostics each have unique layouts

  • Multi-language content: Hindi, Tamil, Telugu names and headers mixed with English values

  • Table structures: Complex nested tables with reference ranges

  • Handwritten notes: Doctor annotations and prescriptions

Implementation Options:

Option A: Tesseract OCR (Open-Source)

Pros: Free, works offline, no API costs Cons: 70-80% accuracy, slower processing

Option B: Cloud OCR API (Google Cloud Vision or AWS Textract)

Pros: 90-95% accuracy, handles tables well Cons: Costs ~$1.50 per 1000 images, requires internet, privacy concern

  • Use Tesseract for initial extraction (free, offline)

  • Fall back to Cloud API for failed/low-confidence extractions

  • User always reviews and can correct

2. Encryption Service

Responsibility: Encrypt/decrypt user data at rest

3. Chart Service

Responsibility: Generate biomarker trend charts


API Design (IPC for Electron)

Main Process ↔ Renderer Process Communication


Performance Requirements

Load Time Targets

Operation
Target
Measurement

App Launch

<3s

Time to render UI

Timeline Load (100 docs)

<2s

Query + render

Chart Render

<1s

Data fetch + draw

Document Upload

<5s

File copy + encrypt + DB write

OCR Processing

<30s

Per document

Search Results

<500ms

Query + render

Optimization Strategies

  1. Database Indexing: Index frequently queried fields

  2. Lazy Loading: Load documents/charts on-demand

  3. Virtualization: Virtualize long lists (react-window)

  4. Caching: Cache chart data, thumbnails

  5. Background Processing: OCR in worker threads

  6. Database Connection Pool: Reuse SQLite connections


Security Requirements

1. Password Security

  • Use bcrypt or Argon2 for password hashing

  • Minimum password length: 8 characters

  • Derive encryption key from password using PBKDF2 (100,000 iterations)

2. Data Encryption

  • AES-256-GCM for encryption

  • Unique IV for each encryption operation

  • Store encryption key in OS keychain (not in app)

3. File Storage

  • All documents encrypted at rest

  • Encrypted files stored in app-specific folder

  • Prevent access from other apps

4. Memory Security

  • Clear sensitive data from memory after use

  • No logging of passwords or encryption keys

5. Network Security

  • No network requests in MVP (fully offline)

  • When adding cloud backup: TLS 1.3, certificate pinning


Testing Strategy

Unit Tests (80% Coverage Target)

Integration Tests

E2E Tests (Critical User Flows)

Use Playwright or Spectron for E2E testing:

  1. First-time user onboarding

  2. Upload document → View timeline

  3. Upload document → View chart

  4. Search and filter documents

  5. Export data


Development Setup

Prerequisites

Initial Setup

Scripts


Deployment & Distribution

Code Signing (Required for macOS/Windows)

macOS:

  • Obtain Apple Developer account ($99/year)

  • Generate Developer ID certificate

  • Sign app with electron-builder

Windows:

  • Obtain Code Signing certificate (~$200-500/year)

  • Sign with electron-builder

Auto-Updates

Use electron-updater for auto-updates:

Distribution Channels

  1. Direct Download (MVP)

    • Host .dmg (macOS) and .exe (Windows) on website

    • Use GitHub Releases for storage

  2. App Stores (Post-MVP)

    • Mac App Store

    • Microsoft Store


Monitoring & Error Tracking

Sentry Integration

Performance Monitoring


Open Technical Decisions

1. OCR Approach

Recommendation: Start with Option A (Tesseract), add Cloud API later if accuracy insufficient.

2. UI Framework

Recommendation: shadcn/ui for modern, lightweight UI.

3. Chart Library

Recommendation: Recharts for simplicity and React integration.


  • [[mvp-prd]] - Product Requirements

  • [[mvp-metrics-framework]] - Metrics & Analytics

  • [[memo]] - Product Vision


Next Steps

  1. Choose tech stack (Electron + React recommended)

  2. Set up project with boilerplate

  3. Implement database schema and migrations

  4. Build core services (OCR, Encryption, Charts)

  5. Implement UI components (Timeline, Charts, Upload)

  6. Integrate analytics (PostHog)

  7. Write tests (unit + integration)

  8. Package and distribute (code signing, installers)

Status: Ready for development ✅

Last updated