Skip to content

Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.

Docs: den Coach dort beschreiben, wo Leute ihn suchen

Duarte Santosebb8e390fbbf
diff --git a/.env.example b/.env.example
index 52e25b1cb..2b214d1e4 100644
--- a/.env.example
+++ b/.env.example
@@ -76,3 +76,25 @@ RP_NAME=openGym
# fine; set a mailto: if you would rather they mailed you:
#
# VAPID_SUBJECT=mailto:[email protected]
+
+# ── AI Coach (optional, off by default) ────────────────────────────────────
+# The Coach is not in the image you get by default, and it stays off even when
+# it is: an admin has to turn it on in Settings → Admin and connect a provider
+# account. An instance that never does either is byte-for-byte the same app it
+# was before the feature existed.
+#
+# API_TARGET picks which API image gets built. `default` carries no AI runtime
+# at all — no Agent SDK, no Codex, no bubblewrap. `coach` adds them (~300 MB):
+#
+# API_TARGET=coach docker compose up -d --build api
+#
+# COACH_DISABLED is the kill switch that outranks the admin toggle. Set it when
+# you want the Coach off for certain — after an incident, or on an instance
+# where nobody should be able to turn it on:
+#
+# COACH_DISABLED=1
+#
+# Credentials never live here. They are encrypted into ./coach.json, or for the
+# Codex provider cached in ./coach-auth — a sibling of ./data, never inside it,
+# so a live sign-in does not ride along in the documented backup archive.
+# See docs/AI_COACH.md.
diff --git a/README.md b/README.md
index b4d8d22ad..8df65f7e5 100644
--- a/README.md
+++ b/README.md
@@ -85,6 +85,7 @@ as a home-screen app, passkey sign-in, offline support, sync across your phone a
- 📥 **Bring your history with you** — import from **FitNotes** (Android and iOS), **Strong** and **Hevy**, or body weight straight out of an **Apple Health** export. Exercise names are matched against the library and anything unrecognised becomes one of your own exercises, so nothing in the file is dropped
- 📦 **Yours to keep** — one-tap JSON export/import, guest mode, **no telemetry**
- 🤖 **Ask an AI about your training** (optional) — an [MCP server](mcp/README.md) lets a client like Claude Desktop or Cursor read your history in your own words: *"what did I bench last week?"*. Read-only, spawned locally by the client, nothing leaves your box. Not in the Docker build — if you don't use an AI assistant, it isn't there
+- 🧠 **An AI coach that writes your plan** (optional, off by default) — answer a handful of questions and it designs a week of routines; later it reads what you actually logged and proposes changes, each one with the evidence behind it. You approve every change and can undo it. It runs on **your** server under **your** provider account, and it needs a separate image to exist at all — the default build carries no AI runtime whatsoever. See [docs/AI_COACH.md](docs/AI_COACH.md)
- 📱 **Standalone Android app** — the whole tracker as a sideloadable APK: no account, no server, data on the phone, native workout reminders ([download](https://opengym.duarte-santos.ch))
## Quick start (self-host)
@@ -164,6 +165,8 @@ All via `.env` (see `.env.example`):
| `INVITE_ONLY` | Require an invite code to create a profile | *(off)* |
| `ALLOW_GUEST` | Offer "Continue without account" — set `0` to require a profile | *(on)* |
| `VAPID_SUBJECT` | Contact URL sent with push notifications | your `ORIGIN` |
+| `API_TARGET` | Which API image to build: `default` (no AI runtime) or `coach` | `default` |
+| `COACH_DISABLED` | Set to `1` to force the AI Coach off instance-wide, whatever the admin toggled | *(unset)* |
Push notification keys are generated on first run and saved to `./data/vapid.json` — nothing to set.
`DATA_DIR` is pinned to `/data` by `docker-compose.yml` and mapped to `./data` on the host; change the
@@ -176,6 +179,7 @@ Rough, community-driven — ideas and PRs welcome:
- [x] Standalone mobile app — Android APK to sideload ([download](https://opengym.duarte-santos.ch)); on iOS as a self-hosted PWA (no store listings planned)
- [x] Automatic progression programs (linear, Greyskull LP, double progression) with stalls and deloads
- [x] Estimated 1RM per exercise
+- [x] Optional AI coach — designs a plan and reviews your training, on your own server and your own provider account ([docs](docs/AI_COACH.md))
- [ ] Percentage / training-max programming (5/3/1-style) on top of the progression engine
- [ ] More starter plans (upper/lower, full-body, 5×5)
- [x] Importers from FitNotes / Strong / Hevy (including the RPE they record), and body weight from Apple Health
@@ -196,6 +200,12 @@ lives in pure functions under `frontend/src/lib/` with tests next to them: `npm
`frontend/`. Vitest is a dev dependency; the app itself ships no runtime dependencies beyond
React, the router and Zustand.
+The optional AI Coach (`api/coach/`) is built the same way round: a by-name allowlist decides
+what may leave the server, and a closed-list validator decides what may come back — the model
+can touch routines and the weekly schedule, nothing else, and every change is applied on the
+client only after you approve it. The AI runtime lives in a separate Docker build target, so an
+instance that never asks for it never carries it. See [docs/AI_COACH.md](docs/AI_COACH.md).
+
The same pure helpers power an optional MCP server (`mcp/`) that lets an LLM client like
Claude Desktop read your data over stdio — see [mcp/README.md](mcp/README.md). Opt-in, not
in the Docker build.
diff --git a/website/docs.html b/website/docs.html
index 4cadfdd18..e222c8b2b 100644
--- a/website/docs.html
+++ b/website/docs.html
@@ -40,6 +40,7 @@
<a href="#iphone">iPhone</a>
<a href="#selfhost">Self-hosting</a>
<a href="#mcp">Ask an AI</a>
+ <a href="#coach">AI Coach</a>
<a href="#import">Import your history</a>
<a href="#backup">Backups</a>
<a href="#build">Build it yourself</a>
@@ -113,6 +114,26 @@ docker compose up -d</code></pre>
an AI assistant, it simply isn't there. Setup is a few lines of client config:
<a href="https://github.com/DuarteSantos8/openGym/blob/main/mcp/README.md" rel="noopener">mcp/README.md</a>.</p>
+ <h2 id="coach">Let an AI coach write your plan</h2>
+ <p>Separate from the read-only bridge above, openGym has an optional <b>AI Coach</b> that can
+ design a training plan and, later, review what you actually logged and propose changes to
+ it. Answer a few questions — goal, days a week, session length, equipment, anything to work
+ around — and it builds a week of routines. Every suggestion carries the evidence behind it,
+ you approve or reject each one, and you can undo the last set of changes.</p>
+ <p>It is <b>off by default and not in the default image</b>. The Coach needs a build that
+ includes an AI runtime, which the normal one deliberately does not carry:</p>
+ <pre><code>API_TARGET=coach docker compose up -d --build api</code></pre>
+ <p>Then an admin turns it on in <b>Settings → Admin → AI Coach</b> and connects a provider
+ account. It runs on <b>your</b> server under <b>your</b> account — there is no openGym
+ service in the middle, and nothing is sent anywhere until you ask it for something. What
+ leaves the server is a by-name allowlist (your plan, your logged sets, body weight if you
+ track it) under a pseudonym; your name, sign-in details and other profiles never do. What
+ comes back can only touch routines and your weekly schedule, and is applied on your device
+ after you approve it.</p>
+ <p>The Coach is not a doctor or a physiotherapist. If something hurts, ask a professional.
+ Full details, including exactly what is sent and how credentials are stored:
+ <a href="https://github.com/DuarteSantos8/openGym/blob/main/docs/AI_COACH.md" rel="noopener">docs/AI_COACH.md</a>.</p>
+
<h2 id="import">Import your training history</h2>
<p>Coming from another tracker? <b>Settings → Data → Import from another app</b> reads:</p>
<ul>