Overview PatientPulse Backend PulseVault Mobile Data Flow Interoperability AI Architecture Security Deployment

System Architecture

A full view of how PatientPulse (provider backend) and PulseVault (patient mobile app) are designed, how they connect to India's Digital Health infrastructure, and how to extend the platform.

High-Level System Overview
Client Layer

🌐 Provider Web App

React + TypeScript + Vite

📱 PulseVault Android

Kotlin + Jetpack Compose

🏥 Patient Portal

React (patient-web)

🏢 Insurer Portal

React (insurer-portal)

👨‍⚕️ Provider App

React (provider-web)

API Layer

PatientPulse API

FastAPI · Python · 452 endpoints

PulseVault API

Express · Node.js · 88 endpoints

Domain Services (Chunked Monolith)

Auth Chunk

OTP · SSO · MFA · Google OAuth

Clinical Chunk

OPD · IPD · Emergency · Triage

AI Chunk

Forecasting · Lab AI · Scribe

Billing Chunk

Claims · Payments · GST

Governance Chunk

DPIA · Consent · Audit · DSR

Data Layer

PostgreSQL

Multi-schema · Audit chain · LISTEN/NOTIFY

Room DB (Android)

Offline-first local persistence

Object Storage

S3 / GCS / Azure — health records

External Integrations

🏛 ABDM

ABHA · PHR · HFR · HPR

📋 FHIR R4

HL7 · Bundles · Adapters

🏥 NHCX

Claims Exchange

💳 Razorpay

Payments · Subscriptions

📲 Twilio

SMS · WhatsApp · OTP

PatientPulse Backend Architecture

PatientPulse is a domain-chunked FastAPI monolith. Rather than microservices (which add ops overhead) or a single giant module (which becomes unmaintainable), it uses a chunked pattern — independent domain registries that register routes into one process.

FastAPI Monolith — Domain Chunk Pattern

main_monolith.py

Entry point · uvicorn · ASGI · middleware stack

main_domains/

Domain registry — each chunk registers its own routes

routes/ (60+ files)

auth · care_flow · mobile_bff · enterprise_compat · bureau · ipd · billing…

Database Schema Separation

domain_tables.py

Core clinical entities

tenant_schema.py

Multi-org isolation

security_schema.py

Audit chain · consent

analytics_schema.py

Operational metrics

Tech Stack

🐍 Python 3.12 ⚡ FastAPI 0.115 🦄 Uvicorn (ASGI) 🐘 PostgreSQL + Psycopg3 📐 Pydantic v2 🔑 PyJWT 🤖 XGBoost 📊 LightGBM 🔮 Prophet 📉 statsmodels / SARIMAX 🔐 SAML 2.0 🌐 Google OAuth 🔒 cryptography 46.x

PulseVault Mobile Architecture

PulseVault is a multi-module Android application with a clean-architecture layering — feature modules sit on top of core modules. The Node.js backend acts as a BFF (Backend for Frontend) with a staged proxy migration path to PatientPulse canonical.

PulseVault Multi-Module Android Architecture
Feature Modules (Jetpack Compose Screens)

feature:auth

OTP login flow

feature:home

Daily summary

feature:vault

Health records

feature:insights

AI health cards

feature:share

Consent + sharing

feature:doctors

Appointments

↕ ViewModel (Jetpack) ↕
Core Modules

core:data

Repository pattern · sync orchestration

core:network

Retrofit · OkHttp · generated SDK

core:database

Room · offline-first entities

core:auth

EncryptedSharedPreferences · JWT

core:model

Kotlin data classes · API contracts

↕ Hilt DI ↕
Node.js BFF (Express) — Proxy-Ready

Auth Routes

→ Proxies to PatientPulse

Profile Routes

→ Proxies to PatientPulse

Push Routes

→ FCM via proxy

Deprecation Gate

archive-ready / write-disable / read-only

Key Data Flows

Patient OTP Login Flow

1

Patient enters phone

Mobile app or web portal calls POST /auth/patient/request-otp

2

Twilio sends OTP

PatientPulse calls Twilio (SMS or WhatsApp), rate-limited per phone/IP

3

Patient verifies OTP

POST /auth/patient/verify-otp returns JWT access token + HttpOnly refresh cookie

4

Session established

Access token used in Authorization header; refresh via POST /v1/auth/refresh

Consult → FHIR → ABDM Push Flow (Feature 7A)

1

Doctor completes consult

Consult note saved via POST /opd/consult-notes — triggers outbox event

2

FHIR bundle assembled

PatientPulse assembles R4 Bundle (Patient + Conditions + Medications + Observations)

3

Pre-consult summary

Feature 7B: AI generates patient summary, fetches available doctors for follow-up

4

ABDM connector push

Bundle auto-pushed to patient's ABHA-linked health locker via ABDM connector

Interoperability Architecture

India Digital Health Mission — Integration Points

ABDM Connector

Configurable mode: stub (dev) or live (prod). Handles ABHA linking, PHR push/pull, HFR sync, HPR sync.

ABDM_CONNECTOR_MODE=live

FHIR R4 Adapter

Maps PatientPulse domain models → HL7 FHIR R4 resources. Supports Bundle, Patient, Condition, MedicationRequest, Observation.

HL7 Certified

NHCX Gateway

National Health Claims Exchange integration. Submit claims, poll status, handle pre-auth flows via correlation IDs.

Live Claims

AI & ML Architecture

AI System Components

📈 Demand Forecasting

Ensemble: XGBoost + LightGBM + Prophet + SARIMAX. Predicts OPD/Emergency load 1–14 days ahead.

🧪 Lab AI

Interprets lab reports via LLM (OpenAI or local Ollama). Returns abnormal flags + recommendations.

📝 Ambient Scribe

Transcript → SOAP note generation. Reduces documentation burden for doctors.

🛡 AI Safety

Kill switch at GET /admin/ai/kill-switch. Review queue for AI outputs. No raw patient data in prompts by default.

AI Configuration

Set AI_ENABLED=true, configure either OPENAI_API_KEY (cloud) or AI_LOCAL_MODEL_URL (Ollama for on-premise). AI_NO_RAW_PATIENT_DATA=true strips identifiers before LLM calls.

Security Architecture

🔐

Authentication

  • OTP via Twilio (SMS/WhatsApp)
  • Google OAuth 2.0
  • SAML 2.0 for enterprise SSO
  • Platform MFA (TOTP)
  • JWT access tokens (900s)
  • HttpOnly refresh cookies
🛡

Data Protection

  • CERT-In log retention
  • DPIA (Data Protection Impact)
  • DSR (Data Subject Requests)
  • Consent audit chain
  • Cryptography 46.x
  • EncryptedSharedPreferences (Android)
🔍

Compliance

  • NABH-aligned workflows
  • ABDM compliance
  • NHCX standards
  • GDPR-informed DSR flows
  • Audit trail immutability
  • Legal signoff tracking

Deployment

Recommended Production Deployment

PatientPulse API

Docker container · Railway or Render · Auto-scale on load

PulseVault API

Node.js Docker · Proxy mode to PatientPulse · Deprecation gate controls rollout

Database

Managed PostgreSQL · Supabase or RDS · SSL required · Direct URL for migrations

+

Nginx

Reverse proxy · TLS termination

FCM

Android push notifications

Object Storage

S3 / GCS / Azure for records

Prometheus

Metrics at /metrics endpoint

Start Building → API Reference