# Private and safe by default

- **The server decides.** Every request checks the session, the role and which household/user the data belongs to. Never trust ids from the browser.
- **Validate everything** with allow-lists (see data-and-sync.md). Limit sizes of text and uploads.
- **Rate limits** on sign-in, invites, uploads, feedback and anything that sends email.
- **Content Security Policy** `default-src 'self'`: self-host fonts, scripts, map tiles and libraries so nothing loads from elsewhere. Add only what's needed.
- **Secrets** in `wrangler secret put` (live) and `.dev.vars` (local, gitignored). Never print them, log them or commit them.
- **No tracking** unless the user asks and understands it. Health counts (totals across everyone, never one person's entries) and private error reports (message and place, no contents) are enough to run an app.
- **Export** everything as JSON/CSV with a readme. **Delete** really deletes: rows, files in R2, sessions, push subscriptions.
- **Privacy page** in plain words: what's stored, where, who can see it, how long, how to delete. Keep it in step with the app with a test.
- **Real data**: the user's own logs are read-only to you and only when asked. Other people's are off-limits. Tests use made-up people.
- **Health and safety wording** (e.g. NHS guidance) quoted closely from the source, linked, and never presented as medical advice. Say the app isn't affiliated with or endorsed by the source.
