side project
Leer en españolToppit
A workout app for iPhone and Apple Watch, with an optional AI coach that uses your own API key. Programmes play out as a season of matches against your past self, with levels and XP.
What it is
Toppit is a workout app for iPhone and Apple Watch, in English and Spanish. Your training runs as a season of matches against your past self, with levels and XP to track progress, and there are 7-minute circuits for short days.
Apex, the AI coach, is optional: it uses your own Anthropic or OpenAI key, and without one the app uses built-in lines and sends nothing. There is no account, your data stays on the device, and workouts go to Apple Health only if you turn that on.
How it's built
Toppit is one SwiftUI app, organised in folders that act as packages, plus a small Apple Watch app that shares a few files with it. The domain logic (exercise catalogue, programmes, season rules, sessions, stats) is plain Swift that takes values and a date, so I can test it without a database; only a few store types touch SwiftData. The AI coach, Apple Health and the Watch link sit beside it as services, and the screens work without any of them.
highlights
Every workout is a match against your past self
A programme is a season of weekly rounds, and each planned session is a fixture. Your opponent is your last match of the same workout, or the plan on a first try. The score is the volume you lift, and the result is a win, a draw or a loss. I store the result once at full time instead of recomputing it, so changing the rules later never rewrites history.
XP and progression as small pure functions
The engine is a handful of small pure types: a one-rep-max estimate, a progression rule that adds weight only when you hit every planned rep last time, and an XP table. Because they take plain values and a date, the tests are short and easy to read.
An AI coach you can switch off or swap
Apex works with Anthropic or OpenAI behind one provider interface and one shared runner for structured answers. A request is only built when a key exists and you have agreed for that provider, and switching provider asks again. Every AI job has an offline fallback, so with no key the app still works and sends nothing. A static check also fails the gate if the AI code touches Health or heart-rate data.
The model’s answer is untrusted input
When Apex writes a whole programme, the app gives it a pool of exercises that fit your equipment and a set budget it works out itself, so the model never does the maths. The answer is then decoded and checked: unknown exercises are rejected, one your kit can’t do is swapped for the closest one it can, repeats are dropped and every number is clamped. A broken answer gets one stricter retry, then an error.
The Watch mirrors the phone
The phone holds the only record of your sets and sends the Watch snapshots of the live match. The Watch sends back button presses tagged with the match and the revision they were based on, and the phone ignores stale ones and resends the state. Exactly one of the two devices saves the workout to Apple Health, so it never lands twice, and saving to Health is opt-in.
A strict quality gate instead of CI
There is no CI. A local gate runs a set of static rules in seconds (file length, no hidden failures, no literal colours or fonts, layering, privacy checks and more). The full run adds clean builds, SwiftLint, the unit tests, UI walks with an accessibility audit and test-count and coverage floors it can’t fall below. A pre-push hook runs it, with Swift 6 strict concurrency and warnings as errors underneath.
- Swift 6
- SwiftUI
- SwiftData
- HealthKit
- WatchConnectivity
- Keychain
- Swift Testing
- XCUITest