AfyaLink — Post-discharge patient monitoring platform for Kenya
# AfyaLink
Post-discharge patient recovery platform for the Kenyan market.
This repository implements one loop end to end:
> A clinician discharges a patient → the patient receives scheduled check-ins and
> medication reminders → symptom answers matching a red-flag rule trigger an
> alert to the clinician and caregiver → the clinician resolves it from a
> dashboard.
---
## Stack
| Layer | Choice |
|---|---|
| Backend | Go 1.25, Gin, `pgx/v5` (explicit SQL, no ORM) |
| Database | PostgreSQL 16, migrations via `golang-migrate` |
| Frontend | React 19 + Vite, Tailwind CSS v4, React Router |
| Auth | JWT access tokens (15 min) + rotating refresh tokens (7 days) |
| Password hashing | Argon2id |
| Field encryption | AES-256-GCM |
---
## Layout
```
backend/
cmd/api/ HTTP server
cmd/scheduler/ check-in & dose generation, overdue sweep
cmd/seed/ demo data (development only)
internal/
api/ route table — the authorisation policy in one file
auth/ Argon2id, JWT, refresh rotation
middleware/ auth, RBAC, rate limit, CORS, audit, logging
patients/ patients, discharge records, notes, ownership checks
medications/ prescriptions and dose logs
checkins/ check-ins and the red-flag rule engine
alerts/ alert inbox and resolution
crypto/ AES-256-GCM helpers
audit/ append-only access trail
db/ pgx pool + embedded migrations
scheduler/ the periodic jobs
logging/ structured logging with PHI redaction
pkg/validator/ strict JSON binding and validation
src/ React frontend
lib/ api client, auth context, i18n copy table, formatting
components/ small reusable pieces (AlertCard, PatientRow, CheckinForm, …)
pages/ one directory per role
```
The Go module lives under `backend/` rather than at the repository root so it
can sit alongside the existing Vite app …