Skip to content
Griff Gym
Mobile app

Griff Gym

A native Android strength-training log — with its own backend.

Available on Google Play ·

  • Android
  • Kotlin
  • Jetpack Compose
  • .NET 10
  • PostgreSQL
  • Clean Architecture
Short description

Offline-first strength training log. Cycles, 1RM and honest statistics.

Screenshots

Drag the strip sideways to browse. Click a screenshot to enlarge it, then use the arrow keys.

Full description

Griff Gym is a native Android strength-training log built around a single rule: training never waits on the internet.

Every training feature works with no account and no network. The database on your phone is the source of truth — an account is optional and adds a cloud backup on top of that, never a replacement for it.

A PROGRAM BUILT FROM YOUR OWN NUMBERS

On first run you enter three maxes — squat, bench press, deadlift — or get them from a set you know you can hit. From those, the app builds a six-week cycle sized off percentages of your own maxes. Nothing is generated for someone who has not entered a number.

A PLAN, NOT A CALENDAR

The program is a sequence, not a schedule. Training a day early or a week late makes no difference — the app simply advances to the next unit. Week six is a deload, trained at 50% of that cycle's reference maxes.

CYCLES, NOT ONE PROGRAM FOREVER

Finishing the last workout of week six opens a cycle review. For each lift independently you decide whether your reference max goes up by a suggested amount, stays the same, or changes by an amount you choose. The next cycle starts from a fresh snapshot of those numbers.

LOGGING SETS WITHOUT FRICTION

The workout screen shows what the plan asked for next to what you actually did. Every keystroke that parses is written straight to the database, so a session survives the app being killed between sets. Home then shows IN PROGRESS and a CONTINUE button.

STATISTICS THAT TELL THE TRUTH

Big-three 1RM progression, personal records, total volume, and a consistency calendar with records marked. Estimated 1RM uses the Epley formula over sets you actually logged. A reference max is a planning number you typed in — and is deliberately never treated as a record.

1RM CALCULATOR

Weight and reps turned into an estimated one-rep max, with a training percentage table. You can also pull your current maxes into the calculator with one tap.

YOUR DATA STAYS YOURS

Local-only mode is the default and fully functional — nothing leaves the phone. Create an account and your history gets a durable copy on the server, so a new phone picks up at the set you left off on. You delete the account yourself, from inside the app, behind two confirmations — cloud backup included.

WHO IT IS FOR

Lifters running a percentage-based block who want one log instead of a notebook, a spreadsheet and their memory.

No ads. No subscription. No profiling.


Technology

Scope of work: Product design, architecture, app and backend implementation, deployment

Mobile application
  • Kotlin
  • Jetpack Compose
  • Material 3
  • Navigation Compose
  • Hilt
  • Coroutines
  • Flow / StateFlow
  • WorkManager
  • Gradle Kotlin DSL
  • KSP
On-device data
  • Room
  • SQLite
  • DataStore
  • Android Keystore (AES-256-GCM)
Backend
  • .NET 10
  • ASP.NET Core
  • EF Core 10
  • PostgreSQL 16
  • Npgsql
  • FluentValidation
  • JWT + refresh token rotation
Testing
  • JUnit
  • Turbine
  • xUnit v3
  • Testcontainers
  • Robolectric
Delivery
  • Docker
  • docker compose
  • Linux VPS
  • Reverse proxy + TLS
  • Google Play

Case study — architecture and technology

13 min

The project in one paragraph

Griff Gym is a native Android strength-training log with its own .NET backend holding a durable copy of a lifter's history. All of it — the domain model, the Compose UI, the API and the Docker deployment — was built as one project run on Clean Architecture on both sides. What follows is which architectural decisions were made, and why those ones.

The assumption everything else follows from

A training app has one non-negotiable property: it must not lose data and it must not make anyone wait on the network. Somebody is standing between sets with a phone in one hand, thirty seconds to spare and no signal in a basement gym.

Hence the rule that runs through the whole project: Room is the only thing the UI reads from, in both modes. Logging a set, completing a workout, starting a cycle — none of it touches the network on the way to the screen. An account is not a licence for the app; it adds a second consumer of the write path and a background process that drains that queue.

Mobile architecture — modules, not packages

Clean Architecture is often a README claim after which everything imports everything anyway. Here the boundaries are real Gradle modules, so the compiler enforces them instead of a person:

:app             composition root — Application, MainActivity, Hilt entry points, icon
:presentation    100% Compose, ViewModels, UiState/UiEvent, navigation, theme
:application     use cases; all business orchestration, never in a ViewModel
:domain          pure Kotlin: models, value objects, rules, repository contracts
:infrastructure  Room, DataStore, Retrofit/OkHttp, WorkManager, repository implementations

Dependencies point inward:

:app ──────────► :presentation ──► :application ──► :domain
  └────────────► :infrastructure ──────────────────► :domain

Two things turn that into a mechanism rather than good intentions:

  • :domain and :application are plain JVM modules. The Android SDK, Compose and Room are not on their compile path — they cannot be pulled in even by accident.

  • :presentation never sees :infrastructure. The two are wired together only in :app, through Hilt. A ViewModel calls a use case, not a DAO, and a Room entity never appears in a UiState.

One tap through the layers

Compose screen
      │  user action
      ▼
ViewModel                       (presentation)
      │  invoke(...)
      ▼
Use case                        (application)
      │  repository interface
      ▼
Repository implementation       (infrastructure)
      │  DAO / HTTP call
      ▼
Room  ◄──────────────────────►  sync engine
      │  Flow<Entity>
      ▼
ViewModel  ──►  UiState  ──►  Compose recomposes

The sync engine sits beside that path, not inside it. It reads and writes Room through its own DAOs and never intercepts a use case call — a workout screen has no idea whether an account exists.

The rule that shaped the data model

The training plan is a template. Pressing START copies it into a session snapshot: every prescribed set becomes its own set_log row carrying plannedWeight, plannedReps and plannedRpe. Results are written to separate actual* columns.

The consequence is that editing the program later cannot rewrite history, and a session shows what was asked for next to what actually happened. One decision in the model that removes an entire class of "why does my workout from last year look different now" bugs.

The active workout is not held in a ViewModel. Every keystroke that parses is written straight through to Room, so a session survives the process being killed between sets.

Backend — same boundaries, different language

The backend is ASP.NET Core on .NET 10 with PostgreSQL 16 through EF Core, deployed with Docker on Linux behind a TLS-terminating reverse proxy. Clean Architecture as four projects:

GriffGym.Api  ────────►  GriffGym.Application  ────────►  GriffGym.Domain
                                 ▲                              ▲
                                 └──── GriffGym.Infrastructure ─┘

The enforcement here is as crude and as effective as the Gradle module: `GriffGym.Domain.csproj` has no `PackageReference` elements at all. The domain cannot reach for ASP.NET Core, EF Core, Npgsql, HTTP or JWT, because those assemblies are not on its compile path. The rule does not depend on anybody remembering it.

Use cases, not a mediator

The application layer is explicit classes — CreateTrainingCycleUseCase, LogSetUseCase — registered by name. No MediatR.

MediatR earns its keep when there are many handlers and real cross-cutting behaviours worth putting in a pipeline. Here there are around twenty use cases, and the two cross-cutting concerns — validation and error mapping — already have first-class homes in ASP.NET Core: an action filter and an IExceptionHandler. A mediator would buy indirection and a Send(object) call site that no longer tells you what runs.

There is a side effect I wanted: the registration list is the system's surface area. If something new can be done to a lifter's training data, it appears in a diff, where somebody has to look at it.

Three models, not one

Domain model            Persistence entity           API contract
WorkoutSession     ≠    WorkoutSessionRecord    ≠    WorkoutResponse
  • Domain — rich and self-validating. Private setters, behaviour-bearing methods, invariants checked in constructors. WorkoutSession.LogSet refuses to write into a finished session.

  • Persistence — flat bags of columns EF Core knows how to write, plus sync metadata. All internal.

  • API — what goes on the wire.

The separation costs mapping code. It buys three things. First: an EF entity exposed as JSON leaks column names and — worse — accepts them on the way in. That is mass assignment by default. No request contract in this API has a UserId field, so no request can assert whose data it is writing. Second: a v2 of the API can change shape without the domain moving underneath it. Third: sync metadata lives on the persistence entity, where an interceptor stamps it, rather than being something every use case has to remember.

Client-generated identifiers

Every synchronised record has a uuid primary key with ValueGeneratedNever(). The client is allowed to invent it.

This is not a preference. The product has a stated path in which someone uses Griff Gym purely locally for six months, accumulating cycles and hundreds of sessions, and only then creates an account and uploads all of it. Those rows already have identities. A server assigning its own would force a remapping of every foreign key in the phone's database at exactly the moment a bug is least recoverable and least visible.

So: nothing in this model assumes the server saw a record first. Where the server does mint an identifier it uses Guid.CreateVersion7() — sequential, so primary key inserts stay clustered rather than scattering writes across the whole index the way v4 does.

Sync is a copy, not a dependency

Signing in does not mean "turn syncing on". It means "work out which of four situations this is", because getting it wrong destroys training history. That is one use case with a name and its own tests — ResolvePostSignInActionUseCase — rather than an if inside a ViewModel:

PhoneAccountResult
emptyemptystart onboarding, nothing to move
has dataemptyupload the phone's history (the migration case)
emptyhas datarestore the account's history to this phone
has datahas datarefuse to guess — ask the lifter to resolve it

Once an account is backing up, logging a set writes to Room immediately and marks the change PENDING_UPLOAD. A background pass (WorkManager, NetworkType.CONNECTED, exponential backoff) pushes it when a connection is available. Nothing about a workout ever waits on the network.

The sync metadata has four states: PENDING_UPLOAD, SYNCED, CONFLICT and FAILED. Two rules protect the data on both sides:

  • A backup that fails is never recorded as one that succeeded. The app stays local-only and says so — it does not claim a copy exists that does not. That is the worst possible failure mode, because the lifter stops worrying about something that is not protecting them.

  • If the server has moved on, the record is marked CONFLICT, the local copy is kept untouched, and it is not retried until something resolves it. Nothing is silently overwritten.

Restoring an account's history to a phone is one Room transaction: it lands whole, or the database is left exactly as it was. Historical cycles are restored exactly as stored — never regenerated from today's reference maxes, which would quietly rewrite what a lifter was actually asked to do three years ago. A restore reproduces history; it does not reinterpret it.

Security

The refresh token is the one secret the app stores, and it is treated accordingly:

  • Encrypted with an AES-256-GCM key generated in the Android Keystore, in its own DataStore file — never plain text, never SharedPreferences. If the ciphertext ever becomes permanently undecryptable (a factory reset, restoring a backup onto different hardware) it is treated as "no session" rather than a crash: sign in again, and nothing about the Room data is affected.

  • Access tokens are short-lived and refreshing happens behind a mutex. Several requests failing at once with a stale token trigger exactly one refresh — refresh tokens are single-use and rotate, so a second concurrent refresh would present an already-retired token, which the server treats as theft and revokes the whole session for.

  • The API base URL is a build setting, not a constant in source. Release builds read GRIFFGYM_API_BASE_URL and refuse to build if it is not an HTTPS URL — there is no default a release could ship with by accident.

  • On the server there is no signing key anywhere in the repository. Startup validation refuses to boot without one rather than falling back to a default, so a misconfigured deployment fails immediately instead of issuing tokens signed with something predictable.

Account deletion, or: ordering is the feature

The one irreversible action in the app, so its ordering follows directly from that:

  1. Call the server and go no further until it confirms the account is gone. A local wipe attempted while offline would destroy the lifter's training while leaving the account and its cloud copy untouched — and no screen afterwards could offer either back.

  2. Only once the server has answered: cancel the scheduled sync workers, then clear the local data. The other order would leave a window in which a background pass wakes up, reads a half-cleared database and tries to reconcile it against an account that no longer exists.

  3. Reset the data mode to "undecided", returning the installation to the state it was in before the account existed.

There is no "delete once a connection returns" queue. A deletion nobody was there to see complete is not one anybody consented to.

Technology stack

AreaTechnologies
AppKotlin, Jetpack Compose, Material 3, Navigation Compose, Hilt, Coroutines, Flow/StateFlow, WorkManager
On-device dataRoom, SQLite, DataStore, Android Keystore (AES-256-GCM)
Backend.NET 10, ASP.NET Core, EF Core 10, PostgreSQL 16, Npgsql, FluentValidation, JWT with refresh token rotation
TestingJUnit, Turbine, Robolectric, xUnit v3, Testcontainers
DeliveryDocker, docker compose, Linux VPS, TLS reverse proxy, Google Play

Database migrations are an explicit deployment step, not a side effect of startup: several replicas booting at once would race to alter the same schema, and a bad migration would take the service down with no way to stop it. EnsureCreated() appears nowhere in the project — workout history is the point of this system and it does not get dropped for convenience.

What the project actually taught me

Clean Architecture is often accused of ceremony. Here it paid for itself somewhere I had not planned for: adding accounts and sync eight months after the first offline version shipped required touching not a single Compose screen, because the screens never knew where their data came from. The sync engine went in beside the existing path rather than through it.

The second thing I would repeat: boundaries enforced by the build system, not by code review. A JVM module without the Android SDK and a .csproj with no PackageReference are two lines of configuration that do more to keep an architecture intact than any document.

And a third: wherever a decision can destroy a user's data, it gets its own use case, with its own name and its own tests. An if inside a ViewModel is exactly where that kind of mistake hides.


Let's talk about the planned project

The first consultation is free and without obligation. A short description of the process and the expected outcome is enough.

Let's talk about the project