TRCKS
Training data that reads like flight telemetry.
A multi-sport performance tracker for serious athletes. It records GPS through football matches and runs, logs lifting against a program, and debriefs every session with AI.
How it's wired
The whole system, drawn the way data moves through it. Each step says what was chosen, what it beat and what was tuned. Solid lines are live today; dashed ones are built and tested but not switched on.
- 01
It starts on the field
GPS, the accelerometer and a Bluetooth heart-rate band feed the Flutter app. A foreground service keeps GPS running with the screen locked. Its fixes and the app's own arrive through one handler, so every fix is checked the same way.
- Chose
- Raw fixes for every number
- Over
- One smoothed track
A Kalman filter rounded off sprint peaks and sharp cuts, the moments football is made of. It now only draws the trail on the map; distance and speed are counted from raw fixes.
Tuned
A fix only counts if it's within 10 m, isn't a duplicate from the second stream, isn't out of order and doesn't imply more than 45 km/h. Speed leads with the chip's Doppler reading, so a GPS jump can't turn into a sprint.
- Accuracy gate
- 10 m
- Glitch cut
- > 45 km/h
- 02
Nothing gets lost
Every five seconds the live session is written to SQLite, so a killed app offers to resume. When the match ends it goes into a vault on the phone, before the post-match form and before any network call. The form adds to a match that is already saved.
- Chose
- The phone saves first
- Over
- Straight to the server
Two real failures: saves that crashed for accounts missing a profile row, and a fallback that kept four fields and threw the GPS away. Now the server holds the second copy, not the only one.
Tuned
Vault files are written to a temp file and renamed, with a SHA-256 checksum, so a crash never leaves half a match and a corrupt one is set aside. The big tracking file and the small form header are kept apart, so editing the form doesn't re-zip 27,000 sensor samples.
- 90-minute match
- 2.4 MB
- Offline save
- < 1 s
- 03
Saved the moment it ends
Supabase holds sign-in, the Postgres database and file storage. A match is saved by one database function that writes the session, the match, every GPS point, the sprints and the zones in a single transaction. History and analytics read straight back from it.
- Chose
- Supabase
- Over
- My own API first
Sign-in, Postgres, realtime and storage on day one let the app ship before a backend existed. Everything it does is plain Postgres, so the backend could later take over without moving the data.
Tuned
Saves are idempotent: a match sent twice is ignored on its id, so the phone can retry without asking. Unsent matches retry by themselves once the phone is signed in and back online.
- Calls per save
- 1
- Retries
- Automatic
- 04
One match, every phone
A host opens a match, and players, a referee and a coach join with a six-letter code or a QR. The referee logs goals, assists and cards; Supabase Realtime sends each one to every phone, so all of them show the same score as it happens.
- Chose
- Every player's phone tracks them
- Over
- One device for the team
No vests and no pods: the phone in your pocket is the sensor. Each phone records its own player, so a dropped connection only delays that player's numbers, never the match.
- Roles
- 4
- Join
- Code or QR
- 05
A debrief after every session
When a session ends, its numbers go to Gemini and a written coaching debrief comes back beside the heatmap and a 1–10 rating. Analytics adds a weekly written insight across every sport.
- Chose
- A hosted model, for now
- Over
- Elis on the phone
The fine-tuned coach was too slow on a Samsung A12-class phone. Debriefs use Gemini until Elis is served from the backend, where any phone can reach it.
- Model
- Gemini
- Rating
- 1–10
- 06
The web side
A React and Vite app on Vercel reads the same database, for lifting, programs and an admin dashboard. Its coach chat runs through a Vercel edge function to Perplexity Sonar.
- Chose
- An edge function before the AI
- Over
- Calling it from the browser
The first version read the API key in the browser. The edge function keeps the key on the server, limits each visitor to 30 messages a minute, and keeps the coach on football and lifting.
- Host
- Vercel
- Chat limit
- 30/min
- 07
A backend that does the maths
FastAPI on Python 3.12, in strict layers: routers know HTTP, services know the rules, and the calculations are pure functions with no input or output. Every team-match action passes one authorizer, and a match locks only when the host finalizes it, so late uploads still count.
- Chose
- Filtering per metric
- Over
- One smoothed track for all
Top speed is the 99th percentile of raw speeds, a sprint has to hold for a second, and only total distance is smoothed. Peaks survive, which is how professional tracking vendors do it.
Tuned
It queries Postgres directly instead of through Supabase's REST layer, saving an HTTP hop, and every query still runs as the signed-in user. Tests run against a real Postgres, not SQLite.
- Tests
- 177
- Deployed
- Not yet
- 08
Elis, the coach
Elis is Qwen 2.5 3B, fine-tuned with QLoRA on 515 worked examples: 500 synthetic matches and 15 questions about itself. Give it a match and it answers in five bullets that know your position and quote your numbers.
- Chose
- A small model, fine-tuned
- Over
- A big general one
A 3B model trains on one GTX 1660 Ti in an afternoon and knows the app's own metrics. Bigger models wait until paying users justify them.
Tuned
Training took 2 h 6 min and brought the loss from 2.60 to 0.68. Quantized to 4 bits, the model went from 5.9 GB to 1.8 GB and runs in 2.2 GB of graphics memory.
- Token accuracy
- 83%
- Size
- 1.8 GB Q4
What it does
Everything here runs in the app today except Elis's chat tab, which waits for the backend.
| Ref | Feature | What it does | Status |
|---|---|---|---|
| F1 | Football tracking | Walk the pitch's corners to calibrate it. Speed zones, sprints, high-intensity distance and PlayerLoad, with a heatmap that flips at half time so you always attack upward. | Live |
| F2 | Team matches | Join with a six-letter code or a QR as host, player, referee or coach. Goals, assists and cards reach every phone live. | Live |
| F3 | Running | Pace, splits and climb on a satellite map that works offline. It pauses itself above 35 km/h, because that's a vehicle. | Live |
| F4 | Lifting | Pick a program and today's exercises load themselves. Sets, reps, a rest timer and a plate calculator. | Live |
| F5 | Analytics | Trends across every sport, a 1–10 match rating and a written weekly insight. | Live |
| F6 | Heart rate | A Bluetooth band streams heart rate into the match. It reconnects on its own and is kept awake while it streams. | Live |
| F7 | Elis chat | Ask the fine-tuned coach about a match. It answers locally today; the chat tab in the app is designed, not built. | Built, not live |