StackMoth/Work/PT Tracker

Offline-first & edge

Offline in the gym, synced across devices, migrated off a live sheet

A mobile-first client, session and strength-tracking app on Capacitor Android and Cloudflare D1.

8 sRevision sync poll
30 daysD1 point-in-time recovery
42Source files (~5,000 lines)
0Hard deletes

Gyms have concrete walls and patchy reception. Logging a set cannot block on a network round-trip, and picking up a second phone cannot show stale numbers.

Architecture
React app (web + Capacitor Android) ──► Worker (Hono) ──► D1 (SQLite) ▲ old Google Sheet (Apps Script) ──(one-time import cron)───────┘

Engineering notes

Sync, durability & migration

01Facts
Scale
~5,000 lines across 42 files
Frontend
React, Tailwind, TanStack Query, Capacitor Android
Backend
Hono on Cloudflare Workers & D1 (SQLite)
Auth
Cloudflare Access (30-day email-code sessions)
Tests
14 end-to-end import/API tests & mobile UI smoke test
Hosting
pt-tracker.stackmoth.com (Access-gated) & public GitHub
02Offline on the floor, synced every eight seconds

The app caches the working dataset on the phone and queues edits made without signal. When online, open clients poll a lightweight revision counter every eight seconds and refetch only when the counter moves, so a session logged on one device appears on another almost immediately without hammering D1.

03Nothing is ever removed

Deleting a client, session or weight entry sets deleted = 1 rather than removing the row. Renaming a client propagates cleanly across every session and strength log, Settings offers a one-tap JSON export (/api/export) including deleted rows and archived sheet records, and D1 retains 30 days of point-in-time recovery.

04Lossless one-time Google Sheet migration
  • A lightweight Apps Script added hidden _id and _updated columns and exposed a shared-secret read endpoint.
  • The Worker’s 5-minute cron reconciled changed rows by timestamp so edits made in either place resolved to the newer write, then retired the sheet once D1 became the source of truth.
  • Every cell of the source tabs — including unmapped custom columns — was copied verbatim into sheet_archive, so nothing disappeared during the transition.
05An Android shell that rarely needs rebuilding

Capacitor wraps the live Worker origin with native haptics, system share-sheet exports for client weight logs, Android back-button handling and an offline screen. GitHub Actions builds the signed APK, while everyday UI improvements ship directly by deploying the Worker — no APK reinstall required.

AI-assisted, human-accountable. AI tools contributed significantly to the implementation described here. The specification, the review of every change, the production operation and the accountability are mine.

Next case study

Diyon & Co.