System Flow
Key end-to-end flows — auth, reminders, forum, notifications.
Authentication & token refresh
The frontend axios interceptor automates the refresh: on a 401 (excluding /login, /register, /refresh), it calls /api/refresh, retries the original request once, and on failure clears tokens and redirects to /login.
Reminder lifecycle
A single pengingats row holds multiple daily dose times in its details.jadwal array. Per-schedule send state is tracked in a sent_schedules map inside the same JSONB so each time fires independently.
Forum thread creation + broadcast
The randomized delay (normal distribution, mean 15s σ 5s, floor 4s) avoids WhatsApp gateway rate-limiting.
Caregiver–patient pairing
Relations are self-referential many-to-many through the user_relations table (caregiver_id ↔ patient_id).
Nearby doctors (location-aware)
Province matching reuses the emergency-numbers geocode pipeline. The frontend falls back to the plain GET /api/dokter list if /nearby fails.