Why I built it this way
I shipped an AI mental-health app to the App Store and Google Play as a solo developer, on one small Hetzner server, with privacy designed in from day one.
The app is Sincere, a wellbeing companion for EU users. People type their most personal thoughts into it, so "we take privacy seriously" wasn't enough. I wanted an architecture where the AI service never knows who it is talking to, where deleting an account really deletes it, and where the monthly bill stays small enough for a bootstrapped project.
This post covers the architecture, the privacy decisions, the traps that cost me days, and what it all costs per month. It is not legal advice: GDPR compliance is a legal judgment, and this is the engineering side of it.
The architecture
Everything except the managed database and the AI model runs on one small server.
[embedded content: Sincere architecture · one server, two services]
The app talks only to Nginx. Keycloak holds identities; the two Spring Boot services receive a pseudonymous ID, and the AI service sends conversation text to the Claude API with no identity attached. Grafana, Prometheus and Umami analytics run on the same server. CI/CD is GitHub Actions with path-based triggers for the monorepo, plus EAS Build for the mobile app.
The privacy decisions
The core rule: no backend service except the identity provider knows who a user is.
- Pseudonymous IDs per service. Keycloak issues a pairwise pseudonymous identifier (a salted SHA-256
subclaim). The user service and the AI service only ever see that ID, never an email address or a name. - No location, no unnecessary fields. I removed fields I didn't need, including country. The less you store, the less you have to protect and explain.
- Layered consent. A short first screen covers what the AI is and isn't, a crisis-resources card, an 18+ confirmation and a separate, explicit checkbox for health data. Details sit one tap away.
- Real deletion. "Delete account" in the app removes the user from the user service and from Keycloak in one synchronous call. No support ticket, no background job that might silently fail.
- Honest retention. Deleted data can survive in backups for a bounded time. The privacy policy states the maximum, and the actual retention is shorter (nightly database dumps kept for 7 days).
- Passwordless login. Magic links only. I started with passkeys plus magic links, but even developer testers struggled with passkeys, so I removed them.
One thing to be precise about: conversation text is still sent to the AI provider for processing, and users can type identifying details themselves. Pseudonymization means identity is never attached to the conversation; it does not mean nobody processes the text.
The traps that cost me days
The code was the easy part. These are the issues that actually ate my evenings.
| Symptom | Cause | Fix |
|---|---|---|
| Magic-link login succeeded in Keycloak, but the app never opened | The token response had no id_token, so saving tokens on the device failed | Add "scope": "openid profile email" to the magic-link request, matching the normal login |
invalid_code during app review login | The app refreshed tokens early when less than 5 minutes remained, and the token lifetime was too short | Raise the token lifetime to 600 seconds |
| Server clock reset to midnight every hour | An old cron job in /etc/cron.d forcing the time | Delete it; open UDP 123 in the Hetzner firewall so NTP replies arrive |
| Spring Boot Actuator reachable from the internet | Management endpoints on the public port | management.server.port=9090, bound to localhost |
| Passkey registration silently skipped | The WebAuthn passwordless required action wasn't set as default | Fix the required-action order per realm; never change auth flows globally |
| iOS opened email links in Safari instead of the app | Universal Links setup interfering with the flow | Reworked the redirect; dropped Universal Links after Android regressions |
| DKIM failing to external inboxes | DNS TXT record setup at the registrar | Correct the record; verify against a non-Google inbox |
| Subscription credentials "invalid" on Android | Google Play takes about 36 hours to propagate | Wait, then re-validate in RevenueCat |
Next to the auth flow, server hardening was the other big chunk: Nginx rate limiting, Fail2ban with four jails (sshd, bot scanners, auth failures, rate-limit hits) and blocking of sensitive paths. HTTPS everywhere, of course.
What it really costs
The server is the cheap part; the honest total is a bit higher. Figures are approximate, check current prices before publishing.
| Item | Approx. cost | Note |
|---|---|---|
| Hetzner CX23, production (Falkenstein) | ~€5/month | Plus a second one for dev, and Hetzner backups |
| MongoDB Atlas, Frankfurt | €0 now | Free tier; about $57/month once paying users justify M10 |
| Google Workspace Business Starter | ~€7/month | Transactional email from my own domain |
| Claude API | Usage-based | Prompt caching keeps it manageable |
| Apple Developer Program | €99/year | |
| Google Play developer account | $25 once | |
| Domain | ~€15/year |
Keycloak, PostgreSQL, Nginx, Fail2ban, Grafana, Prometheus and Umami analytics are open source and run on the same server.
What I'd tell myself on day one
- Decide what you won't store before you write any code. Every field you skip is a privacy question you never have to answer.
- Keycloak is powerful and unforgiving. Change flows per client or realm, never globally, and keep a written log of every setting you touch.
- Make deletion synchronous and testable. If it relies on a background job, sooner or later it will silently fail.
- Budget time for app store review, not just for code. My hardest bug only appeared in the login flow Apple's reviewers use.
- AI assistants make you much faster, but you still have to know when an answer is wrong.
Over to you
Most of my time went into these plumbing parts, not into the app itself, and I'm curious whether other builders hit the same walls. If you're building something that handles sensitive data in the EU: which part would you least want to build yourself? Auth, consent and deletion, subscriptions, or server hardening? And how did you solve it?
Tell me in the comments or at info@sincerementalhealth.com.

