Architecture Overview
High-level architecture of the Hallo Stroke platform.
System components
Hallo Stroke is a three-tier platform:
- Frontend (
hallo-stroke-bunny) — a React SPA served by nginx. Talks to the backend over REST. - Backend (
Hallo-Stroke-Backend) — a GoFiber REST API. Owns all business logic, auth, scheduling, and integrations. - Database — PostgreSQL, accessed via GORM. Stores users, content, forum, reminders, logs.
External services the backend integrates with:
- Google Maps Places API — nearby stroke facilities
- YouTube Data API v3 — educational video catalog
- WhatsApp gateway — bot, broadcast notifications, password reset links
- Web Push (VAPID) — browser push notifications
Architecture diagram
Request flow
The browser loads the React SPA. nginx serves the static bundle and falls back to index.html for client-side routing.
axios attaches the Authorization: Bearer <token> header to every request from localStorage.access_token.
GoFiber applies CORS (allowlist), request logging, then optional JWT middleware (OptionalJWT, JWTProtected, or AdminProtected).
The handler validates input, calls the service layer (business logic), which calls the repository (GORM) against PostgreSQL.
Notifications (WhatsApp / web push) are dispatched in goroutines so the HTTP response is not blocked.
Layered backend
Every backend module follows the same shape: model.go → repository.go → service.go → handler.go. cmd/main.go is the composition root that wires repos → services → handlers and injects cross-module notification services via setters.
Key design choices
- Dual-token JWT — short-lived access (60 min) + long-lived refresh (60 days) stored on the user row.
- PII encryption — the 16-digit NIK (national ID) is AES-GCM encrypted before storage, decrypted only on read.
- Async logging — user/admin activity logs are queued and flushed in a background worker; handlers return
202 Acceptedimmediately. - Scheduler-driven reminders — a 20-second ticker in
main.goevaluates all active reminders and dispatches WhatsApp + push notifications in the user's timezone. - Preference-filtered broadcasts — forum thread broadcasts only reach users whose registered preferences match the thread's category (including religion-gated categories).