Hazard data on this site is live. Case and health records shown are sample data. CryoHealth is in field testing and not yet approved for clinical use.
CRYOHEALTH
Scalable solution for glacier-dependent regions
Sign in

Schema design

CryoHealth runs on a single PostgreSQL 16 database with the PostGIS extension. Every service reads and writes the same 17 tables, and every change to them is a TypeORM migration in CryoHealth-api. Nothing else alters the schema.

Current as of migration 1790097238238-BackfillProtocolSteps (11 migrations). Browse the migrations on GitHub ↗

Conventions

  • Every table has a uuid primary key named id, generated by uuid_generate_v4(). Timestamps are timestamptz.
  • Locations are PostGIS geometries in WGS 84 (SRID 4326), except glaciers and district centroids, which store latitude and longitude as plain numbers.
  • Column names follow two styles. Tables from the initial API schema use camelCase (lakeId, createdAt). Tables and columns added for the web dashboard use snake_case (district_id, created_at).
  • Pipeline outputs keep their inputs: runId on observations and scores, and the full score breakdown in hazard_scores.components.

Tables by domain

Hazard monitoring

Glacial lakes, glaciers, and the satellite observations and scores computed for them.

Alerts

Human-issued GLOF alerts, their acknowledgements, and the audit trail behind them.

Community health

CHW case records, IMCI protocols, and the offline sync ledger.

Identity & facilities

Users, roles, CHW profiles, and the health facilities they belong to.

Reference geography

Administrative districts that lakes, glaciers, alerts, and cases are grouped by.

Relationships

All 20 foreign keys. lakes, users, and districts are the hubs most other tables point to.

FromReferencesOn delete
lakes.district_iddistricts.idset null
observations.lakeIdlakes.idcascade
hazard_scores.lakeIdlakes.idcascade
lake_risk_scores.lake_idlakes.idcascade
glaciers.district_iddistricts.idset null
glacier_observations.glacier_idglaciers.idcascade
alerts.lakeIdlakes.idset null
alerts.district_iddistricts.idset null
alerts.issuedByIdusers.idno action
alert_acknowledgements.alert_idalerts.idcascade
alert_acknowledgements.chw_idusers.idcascade
audit.actorIdusers.idno action
chw_cases.chwIdusers.idno action
cases.chw_idusers.idrestrict
cases.district_iddistricts.idset null
sync_log.userIdusers.idno action
users.facilityIdfacilities.idno action
chw_profiles.user_idusers.idcascade
chw_profiles.district_iddistricts.idset null
facilities.lakeIdlakes.idno action

Enums

tier
normalwatchhighcritical

Used by lakes.currentTier, hazard_scores.tier, alerts.tier

dam_type
morainebedrockiceunknown

Used by lakes.damType

role
cryohealth_adminfacility_adminchwviewer

Used by users.role

alert_status
activecleared

Used by alerts.status

sync_state
queuedsynced

Used by chw_cases.syncState

Tables

PK primary key · FK foreign key · UQ unique · null column is nullable

Hazard monitoring

lakes

Monitored glacial lakes and their current hazard tier.

ColumnTypeDetails
idPKuuid
default uuid_generate_v4()
namevarchar
nameUrvarchar · null
Urdu name
slugUQvarchar
valleyvarchar
districtvarchar
Free-text district name
district_idFKuuid · null
→ districts on delete set null
damTypedam_type
default 'unknown'
glacierContactboolean
default false
icimodIdUQvarchar · null
ICIMOD inventory ID
geomgeometry(Point, 4326)
boundarygeometry(Polygon, 4326) · null
elevationMinteger · null
area_km2numeric · null
historicalGlofboolean
default false
currentTiertier
default 'normal'
current_risk_scorenumeric
default 0
downstream_populationinteger
default 0
staleboolean
default false
No recent usable observation
sourcetext
Provenance of the lake record
sourceUrlvarchar · null
createdAttimestamptz
default now()
updatedAttimestamptz
default now()

district (text) and district_id (FK) coexist: the text column predates the districts table.

observations

Lake water-extent measurements from Sentinel-2 scenes, written by the EO pipeline.

ColumnTypeDetails
idPKuuid
default uuid_generate_v4()
lakeIdFKuuid
→ lakes on delete cascade
capturedAttimestamptz
sourcevarchar
default 'sentinel2'
areaKm2numeric(12,6)
cloudFractionnumeric(5,4) · null
sceneIdvarchar · null
runIdvarchar
Pipeline run that produced it
createdAttimestamptz
default now()
Indexes: (lakeId, capturedAt) · UNIQUE (lakeId, capturedAt, source) — dedupe re-runs

hazard_scores

Per-run hazard score and tier for a lake, with the inputs that produced it.

ColumnTypeDetails
idPKuuid
default uuid_generate_v4()
lakeIdFKuuid
→ lakes on delete cascade
runIdvarchar
scorenumeric(8,4)
tiertier
componentsjsonb
Score inputs, kept so any tier can be recomputed
computedAttimestamptz
createdAttimestamptz
default now()
Indexes: (lakeId, computedAt)

lake_risk_scores

Time series of lake risk scores with a confidence value and data source.

ColumnTypeDetails
idPKuuid
default uuid_generate_v4()
lake_idFKuuid
→ lakes on delete cascade
scorenumeric
tiertext
Plain text, not the tier enum
confidencenumeric
default 0.8
sourcetext
default 'sentinel-1'
observed_attimestamptz
default now()
Indexes: (lake_id, observed_at DESC)

Parallel to hazard_scores; both tables exist in the current schema.

glaciers

Glacier inventory (RGI / GLIMS) for the monitored region.

ColumnTypeDetails
idPKuuid
default uuid_generate_v4()
nametext
rgi_idtext · null
Randolph Glacier Inventory ID
glims_idtext · null
district_idFKuuid · null
→ districts on delete set null
latdouble precision
lngdouble precision
area_km2numeric · null
length_kmnumeric · null
elevation_min_minteger · null
elevation_max_minteger · null
statustext
default 'unknown'
terminus_typetext · null
sourcetext · null
last_observedtimestamptz · null
notestext · null
created_attimestamptz
default now()
Indexes: (district_id)

glacier_observations

Dated glacier measurements: area, length, and terminus change.

ColumnTypeDetails
idPKuuid
default uuid_generate_v4()
glacier_idFKuuid
→ glaciers on delete cascade
observed_attimestamptz
area_km2numeric · null
length_kmnumeric · null
terminus_change_mnumeric · null
statustext · null
sourcetext · null
notestext · null
created_attimestamptz
default now()
Indexes: (glacier_id, observed_at DESC)

Alerts

alerts

GLOF alerts issued by a person, with bilingual body text and action items.

ColumnTypeDetails
idPKuuid
default uuid_generate_v4()
lakeIdFKuuid · null
→ lakes on delete set null
district_idFKuuid · null
→ districts on delete set null
tiertier
titlevarchar
bodytext
body_entext · null
Backfilled from `body`
body_urtext · null
chipsjsonb · null
Short action tags
checklistjsonb · null
Numbered action items
windowStarttimestamptz · null
windowEndtimestamptz · null
estimated_windowtext · null
downstreamSummarytext · null
affected_populationinteger
default 0
statusalert_status
default 'active'
issuedByIdFKuuid · null
→ users on delete no action
createdAttimestamptz
default now()
clearedAttimestamptz · null
Indexes: UNIQUE (lakeId, tier) WHERE status = 'active' — one active alert per lake and tier

chips and checklist are nullable and never backfilled: older alerts carry none rather than invented ones.

alert_acknowledgements

Records that a CHW has seen and acknowledged an alert.

ColumnTypeDetails
idPKuuid
default uuid_generate_v4()
alert_idFKuuid
→ alerts on delete cascade
chw_idFKuuid
→ users on delete cascade
acknowledged_attimestamptz
default now()
Indexes: UNIQUE (alert_id, chw_id)

audit

Append-only audit trail. Every alert creation or tier override records a human-readable reason.

ColumnTypeDetails
idPKuuid
default uuid_generate_v4()
actorIdFKuuid · null
→ users on delete no action
actionvarchar
entityTypevarchar
entityIdvarchar · null
reasontext · null
metajsonb · null
createdAttimestamptz
default now()

Community health

chw_cases

Triage cases captured offline on the field app and synced to the server.

ColumnTypeDetails
idPKuuid
default uuid_generate_v4()
chwIdFKuuid
→ users on delete no action
capturedAttimestamptz
payloadjsonb
outcomevarchar · null
syncStatesync_state
default 'synced'
deviceIdvarchar
clientCaseIdUQvarchar
Idempotency key for offline upsert
createdAttimestamptz
default now()
Indexes: (chwId, capturedAt)

cases

Structured case records used by the web dashboard's CHW and admin views.

ColumnTypeDetails
idPKuuid
default uuid_generate_v4()
chw_idFKuuid
→ users on delete restrict
district_idFKuuid · null
→ districts on delete set null
patient_ageinteger · null
patient_sextext · null
symptomstext
diagnosistext · null
treatmenttext · null
outcometext · null
is_disaster_relatedboolean
default false
created_attimestamptz
default now()
deleted_attimestamptz · null
Soft delete
Indexes: (chw_id, created_at DESC) · (district_id, created_at DESC)

Parallel to chw_cases: cases holds structured columns, chw_cases holds the device payload as jsonb.

protocols

IMCI and disaster-response protocols. All dosing and diagnosis text shown to CHWs comes from here.

ColumnTypeDetails
idPKuuid
default uuid_generate_v4()
slugUQtext
titletext
categorytext
bodytext
stepsjsonb · null
Ordered protocol steps
sourcetext
default 'WHO IMNCI'
is_disasterboolean
default false
created_attimestamptz
default now()
updated_attimestamptz
default now()

sync_log

One row per device sync, for tracing offline data back to its upload.

ColumnTypeDetails
idPKuuid
default uuid_generate_v4()
userIdFKuuid
→ users on delete no action
deviceIdvarchar
startedAttimestamptz
finishedAttimestamptz · null
itemCountinteger
default 0
statusvarchar
default 'ok'
detailjsonb · null
createdAttimestamptz
default now()

Identity & facilities

users

Everyone who can sign in: admins, facility staff, CHWs, and viewers.

ColumnTypeDetails
idPKuuid
default uuid_generate_v4()
rolerole
namevarchar
phoneUQvarchar · null
lhwIdUQvarchar · null
Lady Health Worker ID
passwordHashvarchar
facilityIdFKuuid · null
→ facilities on delete no action
activeboolean
default true
createdAttimestamptz
default now()

chw_profiles

Extra profile data for community health workers.

ColumnTypeDetails
idPKuuid
default uuid_generate_v4()
user_idFKuuid · null
→ users on delete cascade
full_nametext
default 'Community Health Worker'
district_idFKuuid · null
→ districts on delete set null
phonetext · null
languagetext
default 'ur'
created_attimestamptz
default now()

facilities

Health facilities (BHUs and others) and the lake that threatens them.

ColumnTypeDetails
idPKuuid
default uuid_generate_v4()
namevarchar
typevarchar
default 'bhu'
districtvarchar
geomgeometry(Point, 4326) · null
contactvarchar · null
lakeIdFKuuid · null
→ lakes on delete no action
vulnerabilitytext
default 'low'
createdAttimestamptz
default now()

Reference geography

districts

Administrative districts of Gilgit Baltistan.

ColumnTypeDetails
idPKuuid
default uuid_generate_v4()
nameUQtext
provincetext
default 'Gilgit Baltistan'
populationinteger · null
centroid_latdouble precision · null
centroid_lngdouble precision · null
created_attimestamptz
default now()