Skip to content
prakartiiPublic

About

Digital maternal-health platform designed to improve continuity of care through patient registration, pregnancy tracking, risk monitoring, referral coordination, and role-based workflows for healthcare workers and administrators.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

ย 

History

16 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Maatri ๐Ÿ‘ฉโ€โš•๏ธ

AI-powered maternal healthcare platform for early risk detection, referral management, QR-based patient identity, and rural healthcare analytics.

Node.js Express.js Supabase PostgreSQL JWT Healthcare


Problem Statement

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.


Features

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)


User Roles

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 โ€”

Workflow

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     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


Tech Stack

Layer Technology
Runtime Node.js (ES Modules)
Framework Express.js 5
Database Supabase ยท PostgreSQL
Auth JWT + bcrypt
QR qrcode
Geo Haversine nearest-hospital matching

Project Structure

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

API Overview

Base URL: http://localhost:5000 ยท Auth: Authorization: Bearer <token> ยท Response: { success, data } or { success, error }

Auth /api/auth

Method Endpoint Access Description
POST /login Public Returns JWT
POST /register Doctor Create ANM or Doctor account
GET /me Authenticated Current user profile

Patients /api/patients

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

Visits /api/visits

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

Referrals /api/referrals

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

QR /api/qr

Method Endpoint Access Description
GET /:patientId ANM Generate QR card
POST /scan Doctor Patient + latest visit + risk

Hospitals /api/hospitals

Method Endpoint Access Description
GET / ANM, Doctor All facilities
GET /nearest ANM, Doctor Nearest by lat/lng ยท filter OBGYN / blood bank

Analytics /api/analytics

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

Offline Sync /api/sync

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

Upload /api/upload

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

AI Integration /api/ai

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


Database Overview

Run in Supabase SQL Editor (in order):

  1. supabase/schema.sql
  2. supabase/schema_updates.sql
  3. 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


Setup

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


Future Scope

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

Team

Built for mothers in rural India.

Maatri โ€” เคฎเคพเคคเฅƒ โ€” mother

About

Digital maternal-health platform designed to improve continuity of care through patient registration, pregnancy tracking, risk monitoring, referral coordination, and role-based workflows for healthcare workers and administrators.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages