Case study 01MyHab2026
MyHab Heartbeat — Web App
A recovery and wellbeing web app for people in 12-step programs — sobriety tracking, journalling, meetings and craving-distraction games — taken from a prototype to a typed, tested Next.js product for a rehabilitation provider.

The brief
MyHab Heartbeat helps people in recovery — AA, NA and GA alike — stay on track day to day. A sober-streak counter drives a garden that grows as the streak does, alongside a private journal, goals and habits, daily readings, a meeting finder, one-tap support contacts and crisis lines.
It began as a Vite prototype generated with AI tooling. My job was to turn it into something a rehabilitation provider could own: a maintainable Next.js app with real access control, subscriptions and a test suite.
What I built
- Migrated the app from Vite to the Next.js 16 App Router, with access control enforced in route-group layouts instead of client-side effects
- A typed API boundary: React Query hooks call Route Handlers backed by shared Zod contracts, so browser code never talks to the database directly
- Stripe subscriptions with Checkout, the Customer Portal and an idempotent, signature-verified webhook that tolerates out-of-order events
- Row-level-security-first Supabase schema with a single entitlement check shared by server and client
- Eight arcade-style distraction games for cravings, with leaderboards and a public mandala gallery
- Daily AA and NA readings proxied by the server and cached for offline use
- Build gates for type checking, tests, linting and a reachability check that fails on orphaned modules
Hardening
Live verification surfaced bugs worth fixing properly: an expired token briefly made a paying subscriber look unentitled, and a UTC-versus-local date bug marked every new goal overdue east of Greenwich. Both now have tests.
I also removed what wasn’t earning its keep — an unused CMS, a background purge worker and a direct database connection — so the handover codebase is smaller than the prototype it replaced.
By the numbers
- Automated tests
- 1,069
- Database migrations
- 36
- API route handlers
- 35