How Nucain Care works
A bird's-eye view of the platform: the modules that power daily care, the data that holds it together, and the rules engine that enforces safety in real time.
Clients
Web app (PWA) for workers, managers and admins. Role-aware UI.
Edge API
Server functions issue authenticated reads/writes with RLS.
Postgres
Residents, MAR, shifts, incidents, audit. RLS on every table.
[ Worker / Manager / Admin ]
│ HTTPS · JWT
▼
┌────────────────────┐ server time
│ Edge Server Funcs │ ─────────────────┐
│ + Rule Engine │ │
└─────────┬──────────┘ ▼
│ ┌──────────────────┐
RLS-scoped│ │ pg_cron jobs │
▼ │ · MAR sweeps │
┌───────────────┐ │ · Drill alerts │
│ Postgres │ ◄─────── │ · Renewals │
│ (RLS, audit) │ └──────────────────┘
└───────┬───────┘
│ change feeds
▼
┌────────────────┐
│ Notifications │ → email / SMS / push
└────────────────┘Data model
Simplified entity overview. Every table is RLS-protected and audit-logged.
- · id
- · name
- · dob
- · home_id
- · key_worker_id
- · risk_level
- · id
- · resident_id
- · name
- · dose
- · schedule_cron
- · prn
- · id
- · med_id
- · due_at
- · given_at
- · given_by
- · status
- · id
- · staff_id
- · home_id
- · start_at
- · end_at
- · status
- · id
- · resident_id
- · type
- · severity
- · reported_by
- · status
- · id
- · actor_id
- · action
- · target
- · occurred_at
for each med in medications:
due = next_cron(med.schedule, server_now())
if server_now() > due + 30m and not given:
create_incident(type="missed_med",
severity=med.criticality)
notify(roles=[manager], channel="sms")
if given_at within window(due ± 15m):
mar_entry.status = "on_time"
elif given_at within window(due ± 60m):
mar_entry.status = "late"
else:
mar_entry.status = "missed"
append_audit(actor, action="MAR.update", target=med.id)All time-sensitive logic (MAR windows, shift clocking, time-gated forms) reads from select now() at time zone 'utc' on the database, never the client.
Tamper-proof
Clients cannot pre-fill forms by changing device clock.
Window enforced
Forms unlock only when server window opens, and lock at server close.
Audit aligned
Every action stamped with server timestamp, not device time.
Daily medication round — flow
- 1
Scheduler wakes
pg_cron sweeps every minute, scoring each MAR slot.
- 2
Worker notified
Window opens; push & in-app alert sent to assigned worker.
- 3
Dose recorded
Worker signs in-app; server validates window & double-sign rules.
- 4
Audit & follow-up
If missed, incident auto-created and manager paged.
