DEV Community

Cover image for I built a workout tracker that makes zero network requests. Here's what that changes
Mert
Mert

Posted on

I built a workout tracker that makes zero network requests. Here's what that changes

Most apps phone home. Analytics, crash reporting, feature flags, remote images. When I started Archetype, a free workout tracker for Android, I decided it would make no network requests at all. It's on Google Play since 28 October like that. This is what it changed.

The Data safety form was one answer

Google Play asks every developer what data the app collects and shares. Nothing leaves the phone, so the answer is "No data collected". No SDKs to check, no fine print.

You lose your eyes

Without crash reporting I don't see a crash on someone's phone unless they tell me. What I do instead

  • Play Console's Android vitals still shows crash and ANR rates. Android collects those, not the app.
  • Profile has a Help and support row that opens an email to me.
  • Tests matter more. There are about 300 test files (Jest and React Native Testing Library), and before a change ships I go through a written checklist on my own phone.

Everything lives in SQLite

Workouts, sets, measurements and settings are in SQLite on the phone (expo-sqlite). This was fine until I imported a long history. With 763 workouts, every screen read the whole history again, around 20,700 rows each time, and it took up to a second on the phone.

So the finished history is now kept in memory, and every write that can change it drops the copy instead of patching it. The next read loads it again, so the copy can't disagree with the tables.

export class CachedSessionRepository implements SessionRepository {
  private rows: SessionWithSets[] | null = null;
  // Bumped by every history write, so a read that started before it is not kept.
  private version = 0;
Enter fullscreen mode Exit fullscreen mode

The one rule that comes with it is that nothing writes session or set rows outside the repository. Raw SQL anywhere else would leave the copy stale.

Getting data in and out without a server

Import. Strong, Hevy and StrongLifts each export a CSV, and each has its own idea of a date. Strong writes "2019-10-14 13:32:50". Hevy's app writes "14 Oct 2019, 13:32" but the month word is in the phone's language, and Hevy's website writes "Oct 14, 2019, 1:32 PM" or a numeric form. So there is one small parser per shape, and the month word goes through a table of translated months.

// Hevy: the app's "d MMM yyyy, HH:mm" with a translated month word, the web's
// English "MMM d, yyyy, h:mm AM", or the web's numeric forms.
const app = /^(\d{1,2}) (\S+) (\d{4}), (\d{1,2}):(\d{2})$/.exec(s);
Enter fullscreen mode Exit fullscreen mode

None of the apps writes a timezone, so everything is kept as wall clock time.

Export. A full JSON backup through the share sheet, and a plain text Coach report. The Coach report can stay up to date in a folder you pick once with Android's Storage Access Framework, Google Drive included, so it syncs without the app touching the network. SAF writes don't truncate, so each write deletes the old file and creates a new one.

Notifications without a push server

The rest timer has to alert when the phone is locked. A scheduled local notification on a high importance channel does it, no push service. The permission is asked the first time a rest starts, not on first launch.

The cost is 157 MB

1,500+ exercises with how-to steps and about 1,300 animated demos, all in the app so it works offline. That's most of the download. I picked offline over size.

Would I do it again ?

Yes. The hardest part was giving up the dashboards. What I got back is an app I can describe in one sentence, nothing leaves your phone unless you send it.

If you want to try it, it's free with no ads and no account. https://play.google.com/store/apps/details?id=app.archetypefitness&referrer=utm_source%3Ddevto%26utm_campaign%3Darticle

Top comments (0)