CASE STUDY · Architect · Fullstack · 2026
Elevate
An offline-first coaching suite for trainers, nutritionists and gyms
Offline-first coaching suite for trainers, nutritionists and gyms: Expo and Tauri v2 apps on one Supabase project, with local SQLite and a custom sync engine.
- Role
- Architect · Fullstack
- Year
- 2026
- Stack
-
- Expo SDK 54
- Tauri v2
- React 19
- Turborepo
- Drizzle ORM
- SQLite
- Supabase
- Astro
- Stripe
- Zustand
- NativeWind
The problem
Trainers, nutritionists and gym owners work on a computer, but their clients and members live on their phones, often in a gym basement with no signal. Most tools pick one side: either a web dashboard that dies offline, or a mobile app that is a thin client. And when the same client sees both a trainer and a nutritionist, nothing connects the two.
The solution
Elevate, by Capsule Codes, is a suite of three products: Coach (trainers and their clients), Nutri (nutritionists and patients) and Gym (owners, staff and members). Each has a mobile app (Expo) and a desktop app (Tauri v2), plus one Astro website on Vercel with Stripe billing. It all lives in a pnpm and Turborepo monorepo, with shared packages like @elevate/shared and @elevate/sync.
Both mobile and desktop are offline-first. Local SQLite is the source of truth, every row carries a pendingSync flag, and a sync engine pushes and pulls every five minutes and on reconnect. The backend is a single Supabase project with 113 migrations, around 136 RLS policies and five Edge Functions.
Status: the website is live; the mobile apps are not in the stores yet and the desktop builds are pre-release.
Stack and key decisions
- Mobile: Expo SDK 54, Expo Router 6, NativeWind 4, Drizzle with expo-sqlite, Zustand 5
- Desktop: Tauri v2, React 19, Vite, Tailwind 4, Drizzle with tauri-plugin-sql. The same offline-first model as mobile, not a thin client
- Server-authoritative actions as a queue: things only the server may decide are queued offline as RPCs and drained in FIFO order before table pushes. Client-generated UUIDs make replays idempotent, and rows the server rejects are retried up to a limit, then set aside as dead letters without losing the local row
- Deletion reconciliation: pulls are upsert-only, so they never see deletes made on another device.
reconcile.tsdrops orphaned rows only when the pull is proven complete, using keyset pagination because PostgREST silently caps results atmax_rows - Deterministic IDs: a gym class instance id is an FNV-1a hash of
(template_id, date), so two devices generating the same week produce the same primary key - Cross-professional visibility: when a client has a trainer and a nutritionist,
share_cross_datalets each see the other’s data read-only - Schema-first CI: migrations are never edited once pushed,
db-validateruns on an ephemeral Postgres,db-migrateruns on merge, and i18n keys are checked in CI
[OK] Billing stays out of the apps
Stripe lives only on the website. A webhook upserts a subscriptions row tagged coach, nutri or
gym, and the apps just mirror that state read-only. No in-app purchases, no store-billing logic to
keep in sync with the backend.
What I learned
Offline-first is a sync protocol, not a cache. Once the local database is the source of truth, ordering, retries, idempotency and failure handling are the product, and most of the effort goes there rather than into screens.
Deletes are the hard part. Upserting rows is easy; noticing that another device removed one is not, and a pull that is silently truncated looks exactly like a pull where rows were deleted. Refusing to delete anything unless the pull is provably complete is what keeps this safe.
Determinism beats coordination. Instead of asking devices to agree on who creates next week’s classes, I made the id a pure function of its inputs, so duplicates collapse on their own.
And keep billing out of the apps. One place to charge, one webhook, and three products that only read the result.
// 7 img