AI-powered maternal healthcare platform for early risk detection, referral management, QR-based patient identity, and rural healthcare analytics.
Rural maternal healthcare breaks down in four predictable places:
Gap
Impact
Delayed risk detection
High-risk pregnancies identified too late
Broken referral chains
No visibility from village referral to hospital admission
Connectivity barriers
Field data lost when networks fail
Fragmented records
History trapped in paper registers and verbal handoffs
Maatri closes the loop โ automated risk scoring, end-to-end referrals, QR hospital intake, offline batch sync, and village-level analytics.
Module
Capability
Authentication
JWT login, bcrypt hashing, role-based access
Patients
Full CRUD with village tracking and live risk status
Medical Visits
Vitals logging with automatic risk recalculation
Risk Engine
Rule-based triage: RED / AMBER / GREEN
Referrals
ANM โ hospital referral with status tracking
QR Workflow
Patient identity cards + doctor scan at intake
Hospitals
Facility directory with nearest-hospital matching
Analytics
Dashboard, heatmap, risk distribution, village stats
Follow-ups
Scheduled visits with priority levels
Offline Sync
Batch upload of patients, visits, and referrals
Risk engine: RED (BP โฅ 140/90, Hb < 7, severe symptoms) ยท AMBER (elevated BP, Hb 7โ10) ยท GREEN (normal)
ANM โ Field Worker
Doctor โ Hospital Clinician
Patients
Create, update, delete
View history
Visits
Log vitals (triggers risk engine)
View records
Referrals
Create
View, confirm arrival/admission, add notes
QR
Generate patient cards
Scan at intake
Hospitals
Find nearest facility
View directory
Analytics
Dashboard & heatmap
Dashboard & heatmap
Follow-ups
Schedule & manage
View
Sync
Offline batch upload
โ
โโโโโโโโโโโโโโโ Register โโโโโโโโโโโโ Log visit โโโโโโโโโโโโโโโ
โ ANM in โ โโโโโโโโโโโโโโโโบ โ Patient โ โโโโโโโโโโโโโโโโโบ โ Risk Engine โ
โ village โ โ record โ โ RED/AMBER/ โ
โโโโโโโโโโโโโโโ โโโโโโโโโโโโ โ GREEN โ
โ โ โโโโโโโโฌโโโโโโโ
โ High risk โผ โ
โโโโโโโโโโโโโโโโโโโโโโโโบ Create referral โโโบ Nearest hospital โ
โ โ
โผ โ
Generate QR card โ
โ โ
โผ โ
โโโโโโโโโโโโโโโ Scan QR โโโโโโโโโโโโ Update status โ
โ Doctor at โ โโโโโโโโโโโโโโโโ โ Hospital โ โโโ PENDING โ ARRIVED โ โ
โ hospital โ View history โ intake โ ADMITTED โ
โโโโโโโโโโโโโโโ โโโโโโโโโโโโ โ
โ
Analytics heatmap โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
(village-level risk distribution)
Referral flow: PENDING โ ARRIVED โ ADMITTED
Layer
Technology
Runtime
Node.js (ES Modules)
Framework
Express.js 5
Database
Supabase ยท PostgreSQL
Auth
JWT + bcrypt
QR
qrcode
Geo
Haversine nearest-hospital matching
Maatri/
โโโ src/
โ โโโ config/ # Supabase client
โ โโโ controllers/ # HTTP handlers
โ โโโ middleware/ # JWT + role guards
โ โโโ routes/ # API route definitions
โ โโโ services/ # Business logic (riskEngine, analytics, syncโฆ)
โ โโโ utils/ # apiResponse, geo helpers
โ โโโ app.js
โ โโโ server.js
โโโ supabase/ # SQL migrations (run in order)
โโโ scripts/ # seedUsers.js
โโโ .env.example
Base URL: http://localhost:5000 ยท Auth: Authorization: Bearer <token> ยท Response: { success, data } or { success, error }
Method
Endpoint
Access
Description
POST
/login
Public
Returns JWT
POST
/register
Doctor
Create ANM or Doctor account
GET
/me
Authenticated
Current user profile
Method
Endpoint
Access
Description
GET
/
ANM, Doctor
List patients
GET
/:id
ANM, Doctor
Patient detail
GET
/:id/qr
ANM
QR card (PNG data URL)
POST
/
ANM
Create patient
PUT
/:id
ANM
Update patient
DELETE
/:id
ANM
Delete patient
Method
Endpoint
Access
Description
GET
/patient/:patientId
ANM, Doctor
Visits by patient
GET
/:id
ANM, Doctor
Single visit
POST
/
ANM
Create visit ยท auto risk update
PUT
/:id
ANM
Update visit ยท re-triage
DELETE
/:id
ANM
Delete visit
Method
Endpoint
Access
Description
POST
/
ANM
Create referral
GET
/
Doctor
List referrals
GET
/:id
ANM, Doctor
Referral detail
PATCH
/:id/status
Doctor
Arrival / admission + notes
Method
Endpoint
Access
Description
GET
/:patientId
ANM
Generate QR card
POST
/scan
Doctor
Patient + latest visit + risk
Method
Endpoint
Access
Description
GET
/
ANM, Doctor
All facilities
GET
/nearest
ANM, Doctor
Nearest by lat/lng ยท filter OBGYN / blood bank
Method
Endpoint
Access
Description
GET
/heatmap
ANM, Doctor
Village risk map with coordinates
GET
/dashboard
ANM, Doctor
KPIs: patients, risk counts, referrals
GET
/risk-distribution
ANM, Doctor
Risk breakdown with percentages
GET
/village-stats
ANM, Doctor
Per-village patient stats
Follow-ups /api/followups
Method
Endpoint
Access
Description
GET
/
ANM, Doctor
List ยท filter by status / priority
POST
/
ANM
Schedule follow-up
PATCH
/:id
ANM
Update date, priority, or status
Method
Endpoint
Access
Description
POST
/batch
ANM
Idempotent batch sync ยท skips duplicates
POST
/
ANM
Batch sync patients, visits, referrals
GET
/status
ANM
Sync history and latest status
Method
Endpoint
Access
Description
POST
/audio
ANM, Doctor
Upload audio ยท multipart/form-data field file
POST
/image
ANM, Doctor
Upload image ยท returns Supabase Storage URL
Method
Endpoint
Access
Description
POST
/transcribe
ANM, Doctor
Send audioUrl โ FastAPI speech-to-text
POST
/ocr
ANM, Doctor
Send imageUrl โ FastAPI OCR
Typical flow: upload file โ use returned file_url โ call /api/ai/transcribe or /api/ai/ocr
Run in Supabase SQL Editor (in order):
supabase/schema.sql
supabase/schema_updates.sql
supabase/schema_updates_analytics.sql
Table
Purpose
users
Auth โ roles: anm, doctor
patients
Registry ยท qr_token ยท current_risk
medical_visits
Vitals per visit
hospitals
Facilities with geo + capacity
referrals
Handshake: PENDING โ ARRIVED โ ADMITTED
villages
Centroids for heatmap
followups
Scheduled ANM visits
offline_sync_logs
Sync audit trail
Core links: visits โ patients ยท referrals โ patients, hospitals, users ยท followups โ patients
Prerequisites: Node.js 18+ ยท Supabase project
git clone < repo-url> && cd Maatri
npm install
cp .env.example .env # set SUPABASE_URL, SUPABASE_SERVICE_ROLE_KEY, JWT_SECRET
Run the three SQL files in Supabase, then:
npm run seed:users # doctor@maatri.org / doctor123 ยท anm@maatri.org / anm123
Run supabase/storage_setup.sql in Supabase to create the uploads bucket, then:
npm run dev # http://localhost:5000 ยท FastAPI at FASTAPI_URL (default :8000)
Quick demo flow: ANM login โ create patient โ log visit โ create referral โ generate QR โ Doctor login โ scan QR โ confirm arrival โ view /api/analytics/dashboard
Phase
Direction
AI agents
Diagnostic, counseling, logistics, triage, scheduling (aiOrchestrator.js)
SMS layer
Alerts + offline sync via text (smsService.js)
Mobile
ANM field app + Doctor hospital dashboard
Integrations
ABHA health ID ยท USSD fallback ยท Hindi/regional languages
Real-time
Push alerts for RED-risk patients ยท automated follow-up reminders
Built for mothers in rural India.
Maatri โ เคฎเคพเคคเฅ โ mother