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.
JavaScript apple-watchbodyweightdockerfitnessfitness-trackergymhealthiosmcpnodejspasskeysprogressive-web-applicationspwareactself-hostedself-hostingvitewebauthnweightliftingworkout-tracker
nix, docs, k8s: exercise media come from catalogue/media, nothing is downloaded
Duarte Santos9549b75c4c85
diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.ymlindex 6042198ba..ca23cd917 100644--- a/.github/workflows/pages.yml+++ b/.github/workflows/pages.yml@@ -6,8 +6,8 @@## Pages serves static files only, so this build has no backend — VITE_DEMO=1 makes the app# boot straight into guest mode with a seeded example history (see frontend/src/lib/demo.js).-# The exercise images/GIFs (~140 MB) are never committed here; the demo build points at the-# upstream dataset on jsDelivr instead, pinned to a commit so the CDN can cache it forever.+# The exercise stills and animations (180 px) come from catalogue/media and are staged next to+# the build by scripts/catalogue/stage-media.mjs, so the demo serves them from its own origin.name: Deploy demo to GitHub Pageson:diff --git a/.gitignore b/.gitignoreindex d34fa5dfa..57b5fd121 100644--- a/.gitignore+++ b/.gitignore@@ -1,4 +1,5 @@-# Exercise media — fetched on first `docker compose up` (or via scripts/fetch-media.sh)+# Exercise media downloaded by installs before v1.4.0 (now in catalogue/media); kept ignored so an+# old folder never gets committed by accidentmedia/img/media/gif/diff --git a/.gitlab-ci.yml b/.gitlab-ci.ymlindex 7b6128e24..9f6037d26 100644--- a/.gitlab-ci.yml+++ b/.gitlab-ci.yml@@ -703,7 +703,7 @@ verify:stack:pull_policy: alwaysEOFdocker compose -f docker-compose.yml -f ci-images.override.yml config --quiet- # --no-deps skips the `media` service (a 140 MB clone the smoke test does not need).+ # --no-deps: start api and web only, from the images just built, nothing else from the file.docker compose -f docker-compose.yml -f ci-images.override.yml up -d --no-deps --no-build api webNET="$(docker network ls --filter name=opengym --format '{{.Name}}' | head -1)"curl() { docker run --rm --network "$NET" curlimages/curl:8.12.1 "$@"; }diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex a7cfa4762..de7e360a8 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -16,14 +16,15 @@ mcp/ Optional read-only MCP server for LLM clients (Claude Desktop, Cursorwebsite/ The static project site at opengym.duarte-santos.ch.kubernetes/ Example manifests (docs/SELF_HOSTING_KUBERNETES.md).docs/ User and operator guides (index: docs/README.md); docs/dev/ has feature design notes.-media/ Exercise images and GIFs, gitignored and fetched at runtime.+catalogue/ The exercise catalogue: one JSON file per exercise, translations in i18n/, and the+ licensed 180 px stills and animations in media/ (catalogue/README.md).```## Running for development```bashcp .env.example .env-docker compose up -d --build # api + web + media on :8080+docker compose up -d --build # api + web on :8080cd frontend && npm install && npm run dev # hot reload, proxies /api to :3000cd frontend && npm test # training logic, locales, components@@ -38,7 +39,12 @@ cd mcp && npm test- **Match the style.** Small components, clear names, comments only where the *why* isn't obvious.State lives in the Zustand store (`src/store`), pure helpers in `src/lib`. There is no linter orformatter config, so follow the surrounding code.-- **Don't commit** `media/` or `data/`; both are gitignored.+- **Don't commit** `data/`; it is gitignored. Don't add or replace anything in+ `catalogue/media/`: the stills and animations are licensed from Gym visual, 180 px at most, and+ not open to contributions (see [NOTICE.md](NOTICE.md)).+- **Exercise fixes and translations go through `catalogue/`**, one JSON file per exercise and one+ per language. [catalogue/README.md](catalogue/README.md) explains the fields and how the app is+ built from them; don't edit the generated `frontend/src/lib/exercises-data.js` by hand.- **Click through what you touched**, including the workout flow, in a browser before opening apull request.- **Training logic gets a unit test.** Anything that decides what you lift next, or reads a logged@@ -79,7 +85,8 @@ should come as a GitHub pull request.## Good first issues- More starter plans-- More languages for the exercise instructions (the dataset ships several)+- Exercise translations: any language in `catalogue/i18n/` with gaps, or a new one+ (see [catalogue/README.md](catalogue/README.md#translating))- Percentage or training-max programming (5/3/1 style) on top of the progression engine in`src/lib/progression.js`; the policy interface is already there- Accessibility passes on the workout and chart screensdiff --git a/README.md b/README.mdindex cd37fd731..5c1e7eb87 100644--- a/README.md+++ b/README.md@@ -196,7 +196,7 @@ Details and build instructions: [docs/MOBILE.md](docs/MOBILE.md).<p align="center"><picture><source media="(prefers-color-scheme: dark)" srcset="docs/diagrams/architecture-dark.png">- <img src="docs/diagrams/architecture.png" alt="Architecture: the phone talks HTTPS to nginx (web), which serves the app and proxies /api to the Node api; the api stores JSON in ./data. A one-shot media service downloads exercise media on first start; the AI coach and MCP server are optional." width="520">+ <img src="docs/diagrams/architecture.png" alt="Architecture: the phone talks HTTPS to nginx (web), which serves the app and proxies /api to the Node api; the api stores JSON in ./data. The exercise media ship inside the web image; the AI coach and MCP server are optional." width="520"></picture></p>diff --git a/contrib/nix/default.nix b/contrib/nix/default.nixindex 6878112ac..abcd1e4e2 100644--- a/contrib/nix/default.nix+++ b/contrib/nix/default.nix@@ -7,13 +7,9 @@ let# The release version is whatever api/package.json says — the same file release:preflight# checks a v* tag against, so the Nix packages can never drift from the release they ship.version = (builtins.fromJSON (builtins.readFile ../../api/package.json)).version;-- datasetRev = import ./dataset.nix;in{opengym-frontend = callPackage ./frontend.nix { inherit version; };opengym-api = callPackage ./api.nix { inherit version; };opengym-mcp = callPackage ./mcp.nix { inherit version; };- opengym-media = callPackage ./media.nix { inherit datasetRev; };- opengym-fetch-media = callPackage ./media-script.nix { inherit datasetRev; };}diff --git a/contrib/nix/flake.nix b/contrib/nix/flake.nixindex a0c75218d..fa71bb8c3 100644--- a/contrib/nix/flake.nix+++ b/contrib/nix/flake.nix@@ -38,7 +38,6 @@environment = {MY_FLAG = "1";};- media.fetchAtBuild = true;};system.stateVersion = "25.05";}@@ -99,14 +98,16 @@nginxTestConfig.config.services.nginx.virtualHosts."localhost".locations."/api/".proxyPassor "missing"}"- echo "nginx /img alias = ${- nginxTestConfig.config.services.nginx.virtualHosts."localhost".locations."/img/".alias or "missing"+ echo "nginx /exercise-media location = ${+ if nginxTestConfig.config.services.nginx.virtualHosts."localhost".locations ? "/exercise-media/" then+ "true"+ else+ "false"}"# Verify frontend/media store paths are exposed for a web serverecho "services.opengym.web.root = ${cfg.web.root}"- echo "services.opengym.media.imageRoot = ${cfg.media.imageRoot}"- echo "services.opengym.media.gifRoot = ${cfg.media.gifRoot}"+ echo "services.opengym.media.root = ${cfg.media.root}"# Verify user existsecho "users.users.opengym exists = ${@@ -124,7 +125,7 @@apps.opengym = {type = "app";- # Runs the full local stack: API + frontend + build-time media behind a throwaway+ # Runs the full local stack: API + frontend (exercise media included) behind a throwaway# Caddy. Defaults to http://localhost:8080; env vars override ports/data/rp.program = "${pkgs.writeShellScript "opengym" ''set -euo pipefail@@ -162,14 +163,6 @@handle /api/* {reverse_proxy 127.0.0.1:$API_PORT}- handle_path /img/* {- root * ${opengymPackages.opengym-media}/images- file_server- }- handle_path /gif/* {- root * ${opengymPackages.opengym-media}/videos- file_server- }handle {root * ${opengymPackages.opengym-frontend}/share/opengymtry_files {path} /index.htmldiff --git a/contrib/nix/frontend.nix b/contrib/nix/frontend.nixindex 033a4fb8a..5dfb65751 100644--- a/contrib/nix/frontend.nix+++ b/contrib/nix/frontend.nix@@ -37,6 +37,11 @@ buildNpmPackage rec {runHook preInstallmkdir -p $out/share/opengymcp -r dist/* $out/share/opengym/+ # The exercise stills and animations come from the source tree (catalogue/media, 180 px,+ # licensed from Gym visual for openGym only: see catalogue/media/NOTICE.md). The same script+ # the demo and Android builds use puts them at exercise-media/ next to the app, which is+ # where the app asks for them. Nothing is downloaded, at build time or at runtime.+ env -u APP_MEDIA_DIR node ../scripts/catalogue/stage-media.mjs $out/share/opengymrunHook postInstall'';diff --git a/contrib/nix/opengym.nix b/contrib/nix/opengym.nixindex 604527399..4bcdd8829 100644--- a/contrib/nix/opengym.nix+++ b/contrib/nix/opengym.nix@@ -35,11 +35,6 @@ letADMIN_UIDS = if cfg.adminUids != "" then cfg.adminUids else null;};- mediaRoot =- if cfg.media.fetchAtBuild then "${packages.opengym-media}/images" else "${cfg.media.dataDir}/img";- mediaGifRoot =- if cfg.media.fetchAtBuild then "${packages.opengym-media}/videos" else "${cfg.media.dataDir}/gif";-# Hardening shared by the API and MCP units. The MCP server reads the same data files,# so it gets the same sandbox.serviceHardening = {@@ -60,8 +55,27 @@ let];};+ # Options that only made sense while the exercise media were downloaded from a third-party+ # dataset. Since v1.4.0 the media ship in the source tree (catalogue/media) and inside the+ # frontend package, so there is nothing left to fetch or point a web server at separately.+ removedMedia =+ name: why:+ lib.mkRemovedOptionModule [+ "services"+ "opengym"+ "media"+ name+ ] why;+in{+ imports = [+ (removedMedia "fetchAtBuild" "The exercise media are part of the frontend package now; nothing is fetched.")+ (removedMedia "dataDir" "The exercise media are part of the frontend package now; there is no runtime media directory.")+ (removedMedia "imageRoot" "Use services.opengym.media.root (stills in still/, animations in clip/).")+ (removedMedia "gifRoot" "Use services.opengym.media.root (stills in still/, animations in clip/).")+ ];+options.services.opengym = {enable = lib.mkEnableOption "openGym self-hosted gym tracker";@@ -198,28 +212,14 @@ in};media = {- fetchAtBuild = lib.mkOption {- type = lib.types.bool;- default = false;- description = "Fetch exercise media at build time (into Nix store). If false, fetch at runtime.";- };-- dataDir = lib.mkOption {- type = lib.types.path;- default = "${cfg.dataDir}/media";- description = "Directory for runtime-fetched exercise media.";- };-- imageRoot = lib.mkOption {- type = lib.types.path;- readOnly = true;- description = "Directory containing exercise images (jpg). For use by a web server.";- };-- gifRoot = lib.mkOption {+ root = lib.mkOption {type = lib.types.path;readOnly = true;- description = "Directory containing exercise GIFs. For use by a web server.";+ description = ''+ Directory with the exercise stills (still/<id>.webp) and animations (clip/<id>.mp4).+ It is the exercise-media/ directory inside web.root, so a web server serving web.root+ already serves it; the option is only there for setups that need the path on its own.+ '';};};@@ -282,7 +282,6 @@ insystemd.tmpfiles.rules = ["d ${cfg.dataDir} 0750 opengym opengym - -"- "d ${cfg.media.dataDir} 0755 opengym opengym - -"];systemd.services.opengym-api = {@@ -310,31 +309,8 @@ in];};- systemd.services.opengym-media = lib.mkIf (!cfg.media.fetchAtBuild) {- description = "Download exercise media for openGym";- after = [ "network-online.target" ];- wants = [ "network-online.target" ];- wantedBy = [ "multi-user.target" ];- serviceConfig = lib.mkMerge [- {- ExecStart = "${packages.opengym-fetch-media}/bin/opengym-fetch-media ${cfg.media.dataDir}";- Type = "oneshot";- RemainAfterExit = true;- User = "opengym";- Group = "opengym";- }- (lib.mkIf (builtins.toString cfg.dataDir == "/var/lib/opengym") {- StateDirectory = "opengym";- })- ];- };-- services.opengym.media = {- imageRoot = mediaRoot;- gifRoot = mediaGifRoot;- };-services.opengym.web.root = "${packages.opengym-frontend}/share/opengym";+ services.opengym.media.root = "${cfg.web.root}/exercise-media";systemd.services.opengym-mcp = lib.mkIf cfg.mcp.enable {description = "openGym MCP server";@@ -384,11 +360,14 @@ inproxy_set_header X-Forwarded-Proto $scheme;'';};- "/img/" = {- alias = "${cfg.media.imageRoot}/";- };- "/gif/" = {- alias = "${cfg.media.gifRoot}/";+ # exercise-media/ is served from root like the rest of the app. The files+ # are named after the exercise and never change within a build, so let+ # browsers keep them.+ "/exercise-media/" = {+ extraConfig = ''+ expires 30d;+ add_header Cache-Control "public";+ '';};};}diff --git a/contrib/nix/tests.nix b/contrib/nix/tests.nixindex 8a0420117..3c4037424 100644--- a/contrib/nix/tests.nix+++ b/contrib/nix/tests.nix@@ -1,5 +1,6 @@# Integration test: boots a NixOS VM with the openGym module (full stack: API + optional-# module-managed nginx vhost + build-time media) and exercises the HTTP contract end to end.+# module-managed nginx vhost + the exercise media shipped in the frontend package) and+# exercises the HTTP contract end to end.## Used through the flake's `checks.opengym-nixos-test` (runs on `nix flake check`) and the# conventional `nixosTests.opengym` output.@@ -20,7 +21,6 @@ pkgs.testers.runNixOSTest {enable = true;rpId = "localhost";origin = "http://localhost:8080";- media.fetchAtBuild = true; # media baked into the store — no network needed in the VMnginx.enable = true; # exercise the module-managed vhost path};@@ -47,5 +47,8 @@ pkgs.testers.runNixOSTest {spa = machine.succeed("curl -fsS http://localhost/")assert 'id="root"' in spa, "SPA index.html not served by nginx root"++ # The exercise media ship inside the frontend package (catalogue/media), no download involved.+ machine.succeed("curl -fsS -o /dev/null http://localhost/exercise-media/NOTICE.md")'';}\ No newline at end of filediff --git a/docs/FAQ.md b/docs/FAQ.mdindex 1e732582c..be10aa331 100644--- a/docs/FAQ.md+++ b/docs/FAQ.md@@ -40,8 +40,8 @@ everything as one file at any time under **Settings → Data & backup**.### Does the app send anything anywhere?-Your instance has no telemetry and phones home to nobody. On first start it downloads the exercise-images and animations from the upstream dataset, once. The AI coach, if an admin turns it on, sends+Your instance has no telemetry and phones home to nobody. The exercise pictures and animations ship+inside the web image, so not even those are downloaded. The AI coach, if an admin turns it on, sendsthe training data it needs to the provider you configured; [AI_COACH.md](AI_COACH.md) lists exactlywhat. Push notifications go through your browser's push service, as all web push does.@@ -99,9 +99,10 @@ an exercise and something measured. See [DATA_IMPORTS.md](DATA_IMPORTS.md).### Can I reuse the exercise images in my own project?-Not on openGym's say-so. The images and animations aren't covered by openGym's license and their-ownership is disputed; openGym only downloads them for your instance. Details in-[NOTICE.md](../NOTICE.md).+No. They are © Aliaksandr Makatserchyk, Gym visual, licensed for use in openGym only and not covered+by openGym's license. Anything outside openGym needs your own licence from+[gymvisual.com](https://gymvisual.com/). Details in [NOTICE.md](../NOTICE.md). The exercise text in+[catalogue/](../catalogue/README.md) is a different story: that's openGym's, and fixes are welcome.### Where do I ask something that isn't here?diff --git a/docs/MOBILE.md b/docs/MOBILE.mdindex 88193d85e..e0e2c81f4 100644--- a/docs/MOBILE.md+++ b/docs/MOBILE.md@@ -17,7 +17,7 @@ openGym ships in two flavors from the same codebase:| Accounts | passkey sign-in, one profile per person | none — the phone *is* the account || Data | synced to your server, readable on desktop | stays on the device (file in the app's private storage) || Reminders | Web Push from your server | native local notifications, no server involved |-| Exercise media | served by your server (`img/`, `gif/`) | loaded from the jsDelivr CDN |+| Exercise media | served by your server (`exercise-media/`) | packed into the app (`exercise-media/`) |The mobile flavor never talks to a backend by default: no sign-in screen, no sync, notelemetry. State is mirrored from `localStorage` into `opengym-state.json` in the app'sdiff --git a/docs/NIX.md b/docs/NIX.mdindex 736ae549b..6d1b4caa4 100644--- a/docs/NIX.md+++ b/docs/NIX.md@@ -1,8 +1,8 @@# openGym on NixOS — Flake & NixOS ModuleopenGym can run natively on NixOS through its **Nix flake** and **NixOS module** — no Docker, no-`docker compose`. The flake builds every openGym component (frontend, API, MCP server, exercise-media) as reproducible Nix packages; the module declares the whole stack as systemd services+`docker compose`. The flake builds every openGym component (frontend with the exercise media, API,+MCP server) as reproducible Nix packages; the module declares the whole stack as systemd servicesmanaged by your NixOS configuration. This document covers both.## 1. Technical introduction@@ -14,17 +14,15 @@ managed by your NixOS configuration. This document covers both.| Output | What it is || --- | --- |-| `packages.opengym-frontend` | The React/Vite PWA, built with `buildNpmPackage`. Static files land in `$out/share/opengym`. |+| `packages.opengym-frontend` | The React/Vite PWA, built with `buildNpmPackage`. Static files land in `$out/share/opengym`, with the exercise stills and animations from `catalogue/media` in `exercise-media/` next to them. || `packages.opengym-api` | The Node.js API (`node server.js`, wrapped as `bin/opengym-api`). || `packages.opengym-mcp` | The read-only MCP server for LLM clients (`bin/opengym-mcp`). |-| `packages.opengym-media` | The exercise image/GIF dataset, pinned via `fetchFromGitHub`. Only fetched when `media.fetchAtBuild = true`. |-| `packages.opengym-fetch-media` | A shell script that downloads the pinned dataset at **runtime** (used by default). || `packages.default` | Alias for `opengym-frontend`. |-| `apps.opengym` | Runs the **full local stack** — API + frontend + pinned media behind a throwaway Caddy (`nix run .#opengym`, default `http://localhost:8080`). |+| `apps.opengym` | Runs the **full local stack** — API + frontend (exercise media included) behind a throwaway Caddy (`nix run .#opengym`, default `http://localhost:8080`). || `apps.default` | Alias for `opengym`. || `devShells.default` | Development shell: Node.js 22, coreutils, git. || `checks.nixos-module-eval` | Evaluates the module against a smoke-test config and asserts the resulting services/users/nginx state and extra environment. |-| `checks.opengym-nixos-test` *(Linux)* | Boots a NixOS VM and exercises the HTTP contract end to end (API health, nginx vhost proxy, SPA fallback). |+| `checks.opengym-nixos-test` *(Linux)* | Boots a NixOS VM and exercises the HTTP contract end to end (API health, nginx vhost proxy, SPA, exercise media). || `nixosTests.opengym` | The same VM test under the conventional `nixosTests` output. || `nixosModules.opengym` | The NixOS module (`nixosModules.default` aliases it). |@@ -34,15 +32,14 @@ managed by your NixOS configuration. This document covers both.- a system `opengym` user/group and the data directory (`/var/lib/opengym` by default),- `systemd.services.opengym-api` — a **hardened** API unit (see [Systemd hardening](#systemd-hardening)),-- `systemd.services.opengym-media` — a one-shot media downloader (only in runtime-media mode),- `systemd.services.opengym-mcp` — the MCP server, **only if `mcp.enable` is set**,- read-only options exposing the built frontend and media directories so *your* web server canserve them (or `nginx.enable = true` for the module to manage one — see §4),- `environment` / `environmentFile` — escape hatches to pass extra environment variables to theAPI (for variables openGym doesn't know about yet). See [Module options reference](#6-module-options-reference).-The module **does not own a web server by default**: it hands you the `web.root`, `media.imageRoot`-and `media.gifRoot` store paths to wire into your own reverse proxy (Caddy, nginx, Traefik, …).+The module **does not own a web server by default**: it hands you the `web.root` store path (the+exercise media are inside it) to wire into your own reverse proxy (Caddy, nginx, Traefik, …).openGym needs everything on **one origin** (passkeys require it), and NixOS deployments already runa proxy — so the module integrates openGym into *yours* instead of re-implementing a web serveritself. See §4. If you'd rather have openGym's web server managed for you, set@@ -53,10 +50,9 @@ itself. See §4. If you'd rather have openGym's web server managed for you, set```textbrowser ── HTTPS ──▶ your web server (Caddy / nginx / …) everything on ONE origin- ├─ / → web.root (built SPA, SPA fallback to /index.html)- ├─ /api/* → opengym-api (systemd, hardened, :3000 internally)- ├─ /img/* → media.imageRoot (exercise images)- └─ /gif/* → media.gifRoot (exercise GIFs)+ ├─ / → web.root (built SPA, SPA fallback to /index.html;+ │ exercise media under /exercise-media/)+ └─ /api/* → opengym-api (systemd, hardened, :3000 internally)│opengym-api ──reads/writes──▶ dataDir (/var/lib/opengym)```@@ -68,20 +64,17 @@ contrib/nix/flake.nix Flake entry point — packages, apps, devShell, module aliasflake.lock Locked inputsopengym.nix The NixOS module (options + systemd/nginx wiring)- frontend.nix buildNpmPackage → $out/share/opengym+ frontend.nix buildNpmPackage → $out/share/opengym (+ exercise-media/ from catalogue/media)api.nix buildNpmPackage → bin/opengym-apimcp.nix buildNpmPackage → bin/opengym-mcp- media.nix fetchFromGitHub pin of the exercise dataset (build-time)- media-script.nix runtime media-fetch shell script- dataset.nix pinned exercise-dataset commit (both media packages share it)default.nix package-set aggregator (used by both the flake and the module); reads therelease version from api/package.json```Everything Nix lives under `contrib/nix/` so the flake stays out of the way of the project's own-build (Docker, CI, the Node packages). The flake reads its sources — `api/`, `frontend/`, `mcp/`-— from the repository root two levels up, so it must be evaluated *from a checkout of the whole-repo*, never from a sparse copy of `contrib/nix` alone.+build (Docker, CI, the Node packages). The flake reads its sources — `api/`, `frontend/`, `mcp/`,+`catalogue/` — from the repository root two levels up, so it must be evaluated *from a checkout of+the whole repo*, never from a sparse copy of `contrib/nix` alone.## 3. Building and using the packages@@ -91,7 +84,7 @@ Requirements: Nix with flakes enabled (`nix.conf`: `experimental-features = nix-# the flake lives in contrib/nix — start there (from the repo root: nix build ./contrib/nix#… )cd contrib/nix-nix build .#opengym-frontend # static site → result/share/opengym+nix build .#opengym-frontend # static site + exercise media → result/share/opengymnix build .#opengym-api # API → result/bin/opengym-apinix build .#opengym-mcpnix run .#opengym # full local stack on http://localhost:8080 (see below)@@ -100,8 +93,8 @@ nix flake check # eval check + (on Linux) the VM integrationix build .#nixosTests.opengym # run just the VM integration test```-`nix run .#opengym` starts the API, the built frontend and the pinned media behind a throwaway-Caddy — open `http://localhost:8080` and use it (passkeys work on `localhost`). Overrides via env+`nix run .#opengym` starts the API and the built frontend (exercise media included) behind a+throwaway Caddy — open `http://localhost:8080` and use it (passkeys work on `localhost`). Overrides via envvars: `OPENGYM_DATA_DIR` (default `/tmp/opengym-data`), `OPENGYM_API_PORT` (3000),`OPENGYM_WEB_PORT` (8080), `OPENGYM_RP_ID`/`OPENGYM_ORIGIN` (local defaults). Bear in mind the APIand frontend ports are just defaults — like any local dev server, don't point it at the internet.@@ -122,9 +115,8 @@ always on a **single origin** — at the store paths the module exposes:| Read-only option | Value | Contains || --- | --- | --- |-| `config.services.opengym.web.root` | `…-opengym-frontend/share/opengym` | the built SPA |-| `config.services.opengym.media.imageRoot` | `…/opengym-media/images` (build) **or** `…/media/img` (runtime) | `.jpg` images |-| `config.services.opengym.media.gifRoot` | `…/opengym-media/videos` (build) **or** `…/media/gif` (runtime) | `.gif` animations |+| `config.services.opengym.web.root` | `…-opengym-frontend/share/opengym` | the built SPA, exercise media included |+| `config.services.opengym.media.root` | `${web.root}/exercise-media` | `still/<id>.webp` and `clip/<id>.mp4`, 180 px |The URL contract the frontend expects ([`frontend/src/lib/exercises.js`](../frontend/src/lib/exercises.js)):@@ -132,8 +124,12 @@ The URL contract the frontend expects ([`frontend/src/lib/exercises.js`](../fron| --- | --- | --- || `/` | `web.root` | SPA — any unknown path falls back to `/index.html` || `/api/*` | `opengym-api` (the `apiPort` you configured) | reverse proxy, keep `/api` on the URL |-| `/img/*` | `media.imageRoot` | strip the `/img/` prefix |-| `/gif/*` | `media.gifRoot` | strip the `/gif/` prefix |+| `/exercise-media/*` | `web.root` | plain static files; nothing extra to map |++The exercise media come from `catalogue/media` in the source tree, copied next to the app at build+time by `scripts/catalogue/stage-media.mjs` (the same step the demo and app builds use). Nothing is+downloaded, at build time or at runtime. They are licensed from Gym visual for openGym only and+stay at 180 px; don't publish that directory on its own (see [`NOTICE.md`](../NOTICE.md)).### Caddy@@ -151,14 +147,6 @@ module (where `config` is in scope) so the store paths resolve from the module'shandle /api/* {reverse_proxy 127.0.0.1:${toString config.services.opengym.apiPort}}- handle_path /img/* {- root * ${config.services.opengym.media.imageRoot}- file_server- }- handle_path /gif/* {- root * ${config.services.opengym.media.gifRoot}- file_server- }handle {root * ${config.services.opengym.web.root}try_files {path} /index.html@@ -170,10 +158,10 @@ module (where `config` is in scope) so the store paths resolve from the module's}```-`handle_path` strips the matched prefix, so `/gif/bench.gif` resolves to-`${gifRoot}/bench.gif`. The API must **keep** its `/api` prefix (openGym routes on it), so `/api`-uses a plain `handle` that passes the full URI through. Order matters: `/api`, `/img` and `/gif`-must be handled before the catch-all `handle` that serves the SPA.+The API must **keep** its `/api` prefix (openGym routes on it), so `/api` uses a plain `handle`+that passes the full URI through. Order matters: `/api` must be handled before the catch-all+`handle` that serves the SPA. The exercise media are files under `web.root`, so `file_server`+serves them; `try_files` only falls back to `/index.html` for paths that don't exist.### nginx@@ -197,7 +185,7 @@ manage one:```That renders a `services.nginx.virtualHosts."gym.example.com"` with the SPA root + fallback, the-`/api` proxy, `/img` and `/gif` aliases, gzip/optimisation settings, and — when `enableACME` — TLS.+`/api` proxy, a cache header on `/exercise-media/`, gzip/optimisation settings, and — when `enableACME` — TLS.It's ordinary `services.nginx` config afterwards, so you can still extend the vhost or add your ownvirtualHosts alongside it.@@ -281,10 +269,9 @@ inputs).```This gives you the `opengym` system user, `/var/lib/opengym` (created via `StateDirectory` +-tmpfiles — the default `dataDir`), the `opengym-api` service listening on `:3000`, and — since-`media.fetchAtBuild` defaults to `false` — the `opengym-media` one-shot that downloads the exercise-dataset (~140 MB, once) into `/var/lib/opengym/media`. Pair it with the Caddy or nginx config from-§4 pointing at the exposed roots.+tmpfiles — the default `dataDir`) and the `opengym-api` service listening on `:3000`. The exercise+media are already in the frontend package. Pair it with the Caddy or nginx config from §4 pointing+at `web.root`.### A realistic production example@@ -304,10 +291,6 @@ dataset (~140 MB, once) into `/var/lib/opengym/media`. Pair it with the Caddy orauditLog = true;auditIp = "net"; # record masked network address only- media = {- fetchAtBuild = true; # bake media into the Nix store instead of runtime download- };-mcp.enable = false; # off unless you use an LLM client};@@ -349,11 +332,10 @@ variables, so entries there can still override).| Piece | When | Details || --- | --- | --- || `users.users.opengym`, `users.groups.opengym` | always | system user/group |-| tmpfiles rules | always | `dataDir` (`0750`), `media.dataDir` (`0755`) |+| tmpfiles rules | always | `dataDir` (`0750`) || `systemd.services.opengym-api` | always | `Restart=on-failure`, runs as `opengym`, hardened |-| `systemd.services.opengym-media` | only when `media.fetchAtBuild = false` | one-shot (`Type=oneshot`, `RemainAfterExit`) media downloader || `systemd.services.opengym-mcp` | only when `mcp.enable = true` | stdio bridge, runs as `opengym`, same sandbox as the API |-| `services.nginx` vhost | only when `nginx.enable = true` | managed virtualHost (SPA + `/api` + `/img` + `/gif`) |+| `services.nginx` vhost | only when `nginx.enable = true` | managed virtualHost (SPA + `/api`, exercise media from the SPA root) || `services.nginx.enable = false` | only when `nginx.enable = false` | force-disabled — bring your own web server |<span id="systemd-hardening"></span>@@ -375,7 +357,7 @@ for other modules to consume — setting them yourself is an error.| Option | Type | Default | Description || --- | --- | --- | --- || `enable` | `bool` | `false` | Enable openGym (user, services, directories). |-| `package` | `attrsOf package` | packages built from source | The package set: `{ opengym-frontend, opengym-api, opengym-mcp, opengym-media, opengym-fetch-media }`. Override to serve pre-built binaries (e.g. from a cache). |+| `package` | `attrsOf package` | packages built from source | The package set: `{ opengym-frontend, opengym-api, opengym-mcp }`. Override to serve pre-built binaries (e.g. from a cache). || `dataDir` | `path` | `/var/lib/opengym` | Persistent data directory — `db.json`, per-user `state-<uid>.json`, `secret`, `vapid.json`, `audit.log`. With the default `/var/lib/opengym`, systemd's `StateDirectory` creates (and cleans up) it; a custom path is created by a tmpfiles rule and `ReadWritePaths` points at it instead. || `apiPort` | `port` | `3000` | Port the API listens on (internal — reachable via your reverse proxy, front it yourself if you open the firewall). || `rpId` | `str` | `localhost` | WebAuthn Relying Party ID. Bare hostname, must match the address bar exactly. |@@ -397,7 +379,7 @@ for other modules to consume — setting them yourself is an error.| Option | Type | Default | Description || --- | --- | --- | --- |-| `nginx.enable` | `bool` | `false` | Have the module configure an nginx virtualHost for openGym via `services.nginx` (SPA root + fallback, `/api` proxy, `/img` + `/gif` aliases, gzip/optimisation). When `false` (Caddy-native default) the module force-disables `services.nginx`. |+| `nginx.enable` | `bool` | `false` | Have the module configure an nginx virtualHost for openGym via `services.nginx` (SPA root + fallback, `/api` proxy, cache header on `/exercise-media/`, gzip/optimisation). When `false` (Caddy-native default) the module force-disables `services.nginx`. || `nginx.hostName` | `str` | `"${rpId}"` | Server name the virtualHost listens on. || `nginx.enableACME` | `bool` | `false` | Serve over TLS: `enableACME` + `forceSSL` on the vhost. Requires `security.acme.acceptTerms = true`. |@@ -405,10 +387,13 @@ for other modules to consume — setting them yourself is an error.| Option | Type | Default | Description || --- | --- | --- | --- |-| `media.fetchAtBuild` | `bool` | `false` | Fetch the exercise dataset **at build time** into the Nix store (pinned, offline-capable). `false` = fetch at runtime with the `opengym-media` one-shot. |-| `media.dataDir` | `path` | `"${dataDir}/media"` | Directory for runtime-fetched media (`img/` + `gif/` inside). |-| `media.imageRoot` *(read-only)* | `path` | — | Directory of `.jpg` images. `…/opengym-media/images` when `fetchAtBuild`, else `…/media/img`. Serve at `/img/`. |-| `media.gifRoot` *(read-only)* | `path` | — | Directory of `.gif` animations. `…/opengym-media/videos` when `fetchAtBuild`, else `…/media/gif`. Serve at `/gif/`. |+| `media.root` *(read-only)* | `path` | — | `${web.root}/exercise-media`: the stills (`still/<id>.webp`) and animations (`clip/<id>.mp4`). Serving `web.root` already serves it; the option is there for setups that need the path on its own. |++`media.fetchAtBuild`, `media.dataDir`, `media.imageRoot` and `media.gifRoot` were removed in+v1.4.0, when the media moved into the repository. A configuration that still sets one fails to+evaluate with a message saying what to do: delete `fetchAtBuild` and `dataDir`, and replace+`imageRoot`/`gifRoot` (and the `/img/`, `/gif/` routes built on them) with `web.root` alone. An+old `/var/lib/opengym/media` directory is no longer used and can be deleted.### `web.*` suboptions@@ -460,7 +445,7 @@ nix flake update opengymsudo nixos-rebuild switch --flake .#myhost```-Your data and the runtime media directory are untouched. Changing `rpId`/`origin` is *not* a+Your data is untouched; the exercise media come with the new frontend package. Changing `rpId`/`origin` is *not* aroutine update — see the passkey caveat in §4.## 8. Troubleshooting@@ -468,30 +453,19 @@ routine update — see the passkey caveat in §4.| Symptom | Fix || --- | --- || No passkey prompt / "verification failed" | `rpId`/`origin` don't match the address bar. Ask the server what it loaded: `journalctl -u opengym-api -b \| grep 'gym-api on'`. See §4 and `docs/SELF_HOSTING.md`. |-| App loads but exercises show no image/animation | The `/img` and `/gif` routes aren't mapped to `imageRoot`/`gifRoot` in your web server, or runtime media hasn't downloaded yet — check `systemctl status opengym-media` / `journalctl -u opengym-media`. |+| App loads but exercises show no image/animation | Your web server doesn't serve `web.root` for `/exercise-media/*`, for example because an older config still routes `/img/` and `/gif/` or sends everything unknown to `index.html` without trying the file first. `curl -I https://your-host/exercise-media/NOTICE.md` should answer 200. || `/api` returns 502/404 | Your proxy's `apiPort` (`services.opengym.apiPort`) differs from what `reverse_proxy`/`proxy_pass` targets. || `nginx` is silently gone after enabling the module | Expected on the Caddy-native default (`nginx.enable = false`): the module sets `services.nginx.enable = false`. Set `services.opengym.nginx.enable = true` to have the module configure nginx for openGym (or `lib.mkForce true` to manage it yourself). || Service won't start | `journalctl -u opengym-api -xe`. Common: custom `dataDir` not created/owned correctly (the tmpfiles rule should handle it; check `systemd-tmpfiles --create`). || Eval fails: `environment and environmentFile are mutually exclusive` | Pick one. Set extra vars either as a Nix attrset (`environment`) or in a file (`environmentFile`), never both. || You expected a binary cache | The flake builds from source; override `services.opengym.package` (or `packages.*` via a cache/overlay) to substitute binaries. |-| Exercise media licensing | openGym ships none of it; it's fetched from [hasaneyldrm/exercises-dataset](https://github.com/hasaneyldrm/exercises-dataset) (third-party, ownership disputed). See [`NOTICE.md`](../NOTICE.md) |+| Exercise media licensing | © Aliaksandr Makatserchyk, Gym visual, licensed for use in openGym only and not covered by the AGPL. They ship at 180 px; don't re-host them on their own. See [`NOTICE.md`](../NOTICE.md) || `nix run .#opengym` serves a blank site | The app now serves frontend + API + media behind a local Caddy. If something's off, check the log line it prints (ports/`DATA_DIR`) and that nothing else already binds `:3000`/`:8080` — pass `OPENGYM_API_PORT`/`OPENGYM_WEB_PORT` to move them. |-### Media modes in detail--- **`media.fetchAtBuild = true`** — the dataset is fetched once via `fetchFromGitHub` (pinned to- the same commit the Docker build uses) and stored in the Nix store. `imageRoot`/`gifRoot` point- into `/nix/store`. No `opengym-media` service is created. Ideal for air-gapped/immutable systems;- you pay the ~140 MB fetch on every switch that rebuilds the media derivation.-- **`media.fetchAtBuild = false`** (default) — the `opengym-media` one-shot downloads the pinned- dataset tarball (a GitHub `/archive/<rev>.tar.gz` of the **same commit** `media.nix` pins) on first- boot into `media.dataDir`, then skips while files are present. `imageRoot`/`gifRoot` point under- `dataDir`, so backups cover media too.-## See also- [`docs/SELF_HOSTING.md`](SELF_HOSTING.md) — the general self-hosting guide (Docker but the domain,passkey and admin/audit details apply unchanged).- [`docs/MOBILE.md`](MOBILE.md) — the stand-alone Android app, an alternative to self-hosting.- [`docs/DATA_IMPORTS.md`](DATA_IMPORTS.md) — importing from FitNotes/Strong/Hevy/Apple Health.-- [`NOTICE.md`](../NOTICE.md) — third-party notices, including the exercise-media situation.+- [`NOTICE.md`](../NOTICE.md) — third-party notices, including the exercise-media licence.diff --git a/docs/SELF_HOSTING.md b/docs/SELF_HOSTING.mdindex 0112fbb08..b92245b02 100644--- a/docs/SELF_HOSTING.md+++ b/docs/SELF_HOSTING.md@@ -670,8 +670,8 @@ git pulldocker compose up -d --build```-The app shell is versioned (`?v=N`) so clients pick up changes on next load. Your `./data` and the-downloaded media are untouched.+The app shell is versioned (`?v=N`) so clients pick up changes on next load. Your `./data` is+untouched; the exercise media come with the new image.## Passkeys fail even though `RP_ID` looks right@@ -803,7 +803,7 @@ browser (see section 2).| The app says "Your server answered with an error (HTTP …)" | The code is what the server or its proxy sent: 502/504 usually means the API container is down or unreachable from `web`, 413 that the proxy's upload limit is too small. Changes stay on the device and go through once the server answers. || `docker compose pull` fails with "denied" / "unauthorized" | The prebuilt images aren't published yet, or need to be, or the GHCR package is still private — build from source instead (`docker compose up -d --build`). || Exercise images/GIFs blank when a routine is open | Fixed in current images (issue #79). On an older build, see the note below. |-| An exercise shows a plain tile instead of its animation when offline | The web app installed on the home screen keeps the media of every exercise in your plan and your current workout, fetched in the background once the app has settled (not on a cellular or Data Saver connection, where the browser says so), plus everything it has shown you, up to 150 MB, across updates. In an ordinary browser tab nothing is fetched ahead: only what it has shown you is kept. An exercise outside your plan that was never shown while online has nothing to show offline. The phone app loads media from a CDN and is not covered by this. |+| An exercise shows a plain tile instead of its animation when offline | The web app installed on the home screen keeps the media of every exercise in your plan and your current workout, fetched in the background once the app has settled (not on a cellular or Data Saver connection, where the browser says so), plus everything it has shown you, up to 150 MB, across updates. In an ordinary browser tab nothing is fetched ahead: only what it has shown you is kept. An exercise outside your plan that was never shown while online has nothing to show offline. The phone app carries its exercise media inside the package, so it has them offline anyway. |### `VITE_IMG_BASE` / `VITE_GIF_BASE` are build-time, not run-timediff --git a/docs/SELF_HOSTING_KUBERNETES.md b/docs/SELF_HOSTING_KUBERNETES.mdindex f6cd84f24..657ed2cd9 100644--- a/docs/SELF_HOSTING_KUBERNETES.md+++ b/docs/SELF_HOSTING_KUBERNETES.md@@ -5,11 +5,10 @@ cert-manager. Read [SELF_HOSTING.md](SELF_HOSTING.md) first: the passkey require`RP_ID`, `ORIGIN`), the settings in `.env.example` and the backup advice apply here unchanged.openGym is pretty simple — a frontend and an API backend. The API keeps everything in plain JSON-files on a volume. The Docker Compose file also has a third container that downloads the exercise-media once; here that is an initContainer. There are only a few resources to create:+files on a volume. The exercise pictures and animations are part of the web image, so nothing is+downloaded at start-up. There are only a few resources to create:-- 2 PVCs: `opengym-data` (users, passkeys, workouts, uploads — **back this one up**) and- `opengym-media` (the exercise images, downloaded again if lost).+- 1 PVC: `opengym-data` (users, passkeys, workouts, uploads, **back this one up**).- 1 Deployment running the API and the web container in a single pod, for simplicity. It stays atone replica with the `Recreate` strategy: the API's data is files on a `ReadWriteOnce` volume,and two API processes must never write them at once.@@ -38,6 +37,9 @@ Notes:- The images are pinned to a release (`1.3.10`), the API and the web image always to the sameone. To update, read the release notes, set the new version on both and apply again; pinningto `latest` instead means a restarted pod can come back on a version you never chose.+- Coming from a version before 1.4.0: the `media-download` initContainer and the `opengym-media`+ PVC are gone, since the media now ship in the web image. Once the new pod runs, delete the old+ claim with `kubectl delete pvc opengym-media -n fitness` (`kubectl apply -k` leaves it in place).- Settings are environment variables on the `api` container, named as in `.env.example`. Keepsecrets such as the push keys in a Kubernetes Secret and load them with `envFrom`.- **Client addresses.** The web container overwrites `X-Forwarded-For` with the address it wasdiff --git a/docs/diagrams/architecture-dark.png b/docs/diagrams/architecture-dark.pngindex 765198e9a..e35a33ce4 100644Binary files a/docs/diagrams/architecture-dark.png and b/docs/diagrams/architecture-dark.png differdiff --git a/docs/diagrams/architecture.mmd b/docs/diagrams/architecture.mmdindex 431a2eb8c..80079af56 100644--- a/docs/diagrams/architecture.mmd+++ b/docs/diagrams/architecture.mmd@@ -3,19 +3,15 @@ flowchart TBsubgraph host["Your server"]direction TB- media["media<br/>one-shot download"]- web["web<br/>nginx: serves the app,<br/>proxies /api"]+ web["web<br/>nginx: serves the app<br/>and exercise media,<br/>proxies /api"]api["api<br/>Node + WebAuthn"]data[("./data<br/>JSON files")]mcp["MCP server<br/>optional, read-only"]end- upstream["Exercise media<br/>upstream dataset"]ai["AI provider<br/>optional, your key"]phone -- HTTPS --> web- upstream -. first start .-> media- media -- shared volume --> webweb -- /api --> apiapi --> datadata -.-> mcpdiff --git a/docs/diagrams/architecture.png b/docs/diagrams/architecture.pngindex 770a86f79..e32374c87 100644Binary files a/docs/diagrams/architecture.png and b/docs/diagrams/architecture.png differdiff --git a/helm/README.md b/helm/README.mdindex 30825434c..2900db0a9 100644--- a/helm/README.md+++ b/helm/README.md@@ -1,6 +1,6 @@# openGym Helm chart-Installs openGym on Kubernetes: the API and the web container in a single pod, two PVCs, a+Installs openGym on Kubernetes: the API and the web container in a single pod, a PVC for the data, aService, and optionally an Ingress or a Gateway API HTTPRoute with a cert-manager certificate. Itdeploys the same thing as the plain manifests in [`kubernetes/`](../kubernetes), but lets you seteverything from values.@@ -116,12 +116,15 @@ choose the address that gets recorded.| Key | Default | ||---|---|---|| `persistence.data.size` | `2Gi` | Accounts, passkeys, workouts, uploads, session secret. **Back this up.** |-| `persistence.media.size` | `2Gi` | Exercise images and GIFs (~140 MB). The init container downloads them again if they are lost. |-| `persistence.*.storageClass` | `""` | `""` uses the cluster default. |-| `persistence.*.existingClaim` | `""` | Uses a PVC you already have instead of creating one. |+| `persistence.data.storageClass` | `""` | `""` uses the cluster default. |+| `persistence.data.existingClaim` | `""` | Uses a PVC you already have instead of creating one. |-The chart keeps both PVCs on `helm uninstall` (`helm.sh/resource-policy: keep`). To get rid of-the data, delete them by hand.+The chart keeps the PVC on `helm uninstall` (`helm.sh/resource-policy: keep`). To get rid of+the data, delete it by hand.++The exercise stills and animations are part of the web image, so there is no media volume. Charts+before openGym 1.4.0 created a `<release>-media` PVC for a download; after upgrading it is no+longer mounted, and since Helm keeps it, delete it by hand once the new pod runs.### Images@@ -131,9 +134,8 @@ image from different releases aren't meant to run side by side.### Other values`imagePullSecrets`, `serviceAccount`, `podAnnotations`, `podLabels`, `podSecurityContext`,-`securityContext`, `nodeSelector`, `tolerations`, `affinity`, `api/web.resources`,-`api/web.livenessProbe`/`readinessProbe` and `mediaDownload.image`/`resources` work the way they-do in any Helm chart. See [`values.yaml`](values.yaml) for the full list.+`securityContext`, `nodeSelector`, `tolerations`, `affinity`, `api/web.resources`+and `api/web.livenessProbe`/`readinessProbe` work the way they do in any Helm chart. See [`values.yaml`](values.yaml) for the full list.## Always one replica@@ -144,15 +146,16 @@ a second writer to the same files.## Moving from `kubectl apply -k kubernetes/`Helm refuses to take over resources it didn't create. Remove the old Deployment, Service,-HTTPRoute, Certificate and ReferenceGrant, but **keep the PVCs**: deleting them deletes the data.-Point the chart at the existing claims instead:+HTTPRoute, Certificate and ReferenceGrant, but **keep the `opengym-data` PVC**: deleting it deletes+the data. Point the chart at the existing claim instead:```bashkubectl -n fitness delete deployment/opengym service/opengym httproute/opengym \certificate/opengym-tls referencegrant/allow-gatewayhelm install opengym ./helm -n fitness -f my-values.yaml \- --set persistence.data.existingClaim=opengym-data \- --set persistence.media.existingClaim=opengym-media+ --set persistence.data.existingClaim=opengym-data```+The old `opengym-media` claim is not needed any more; delete it after the move.+The site is unreachable between the delete and the moment the new pod is ready.diff --git a/helm/templates/deployment.yaml b/helm/templates/deployment.yamlindex 6087d436c..4235fc3b3 100644--- a/helm/templates/deployment.yaml+++ b/helm/templates/deployment.yaml@@ -34,26 +34,6 @@ spec:serviceAccountName: {{ include "helm.serviceAccountName" . }}securityContext:{{- toYaml .Values.podSecurityContext | nindent 8 }}- initContainers:- # The exercise images and GIFs, one time (~140 MB) — the same download as the media- # service in docker-compose.yml. They are © Gym visual (https://gymvisual.com/), used- # under the exercises-dataset's terms and fetched from upstream, not redistributed by- # openGym; see NOTICE.md.- - name: media-download- image: {{ .Values.mediaDownload.image }}- command: [ "/bin/sh", "-c" ]- args:- - |- mkdir -p /out/img /out/gif- if [ -z "$(ls -A /out/img 2>/dev/null)" ]; then- git clone --depth 1 https://github.com/hasaneyldrm/exercises-dataset /tmp/ds- cp /tmp/ds/images/*.jpg /out/img/ && cp /tmp/ds/videos/*.gif /out/gif/- fi- volumeMounts:- - name: media- mountPath: /out- resources:- {{- toYaml .Values.mediaDownload.resources | nindent 12 }}containers:- name: apisecurityContext:@@ -96,20 +76,12 @@ spec:{{- toYaml .Values.web.readinessProbe | nindent 12 }}resources:{{- toYaml .Values.web.resources | nindent 12 }}- volumeMounts:- - name: media- mountPath: /usr/share/nginx/html/img- subPath: img- - name: media- mountPath: /usr/share/nginx/html/gif- subPath: gif+ # No volume: the exercise stills and animations (180 px) are part of the web image since+ # v1.4.0. They are licensed from Gym visual for openGym only; see NOTICE.md.volumes:- name: datapersistentVolumeClaim:claimName: {{ .Values.persistence.data.existingClaim | default (printf "%s-data" (include "helm.fullname" .)) }}- - name: media- persistentVolumeClaim:- claimName: {{ .Values.persistence.media.existingClaim | default (printf "%s-media" (include "helm.fullname" .)) }}{{- with .Values.nodeSelector }}nodeSelector:{{- toYaml . | nindent 8 }}diff --git a/helm/templates/pvc.yaml b/helm/templates/pvc.yamlindex c8e00ed85..253a15776 100644--- a/helm/templates/pvc.yaml+++ b/helm/templates/pvc.yaml@@ -1,4 +1,4 @@-{{- range $name := list "data" "media" }}+{{- range $name := list "data" }}{{- $p := index $.Values.persistence $name }}{{- if not $p.existingClaim }}---diff --git a/helm/values.yaml b/helm/values.yamlindex ec14eb672..6e131a184 100644--- a/helm/values.yaml+++ b/helm/values.yaml@@ -29,7 +29,7 @@ service:type: ClusterIPport: 80-# Both PVCs are kept on `helm uninstall` (helm.sh/resource-policy: keep). Delete them by hand+# The PVC is kept on `helm uninstall` (helm.sh/resource-policy: keep). Delete it by hand# if you really mean to.persistence:# Accounts, passkeys, per-user state, session secret, uploads. BACK THIS UP.@@ -38,12 +38,8 @@ persistence:storageClass: "" # "" = cluster defaultaccessModes: [ReadWriteOnce]size: 2Gi- # Exercise images and GIFs (~140 MB), downloaded once by the init container.- media:- existingClaim: ""- storageClass: ""- accessModes: [ReadWriteOnce]- size: 2Gi+ # There is no media volume any more: the exercise stills and animations ship in the web image+ # since v1.4.0. A `media` block left here from an older values file is ignored.# Classic Ingress. Passkeys need HTTPS and a host equal to api.env.RP_ID.ingress:@@ -96,15 +92,6 @@ tolerations: []affinity: {}-# Init container that fetches the exercise media once into the media volume.-mediaDownload:- image: alpine/git:2.52.0- resources:- requests:- memory: 128Mi- limits:- memory: 256Mi-api:image:repository: ghcr.io/duartesantos8/opengym-apidiff --git a/kubernetes/deployment.yaml b/kubernetes/deployment.yamlindex f2cab8d2d..ad911b42a 100644--- a/kubernetes/deployment.yaml+++ b/kubernetes/deployment.yaml@@ -16,29 +16,6 @@ spec:labels:app: opengymspec:- initContainers:- # The exercise images and GIFs, one time (~140 MB) — the same download as the media- # service in docker-compose.yml. They are © Gym visual (https://gymvisual.com/), used- # under the exercises-dataset's terms and fetched from upstream, not redistributed by- # openGym; see NOTICE.md.- - name: media-download- image: alpine/git:2.52.0- command: ["/bin/sh", "-c"]- args:- - |- mkdir -p /out/img /out/gif- if [ -z "$(ls -A /out/img 2>/dev/null)" ]; then- git clone --depth 1 https://github.com/hasaneyldrm/exercises-dataset /tmp/ds- cp /tmp/ds/images/*.jpg /out/img/ && cp /tmp/ds/videos/*.gif /out/gif/- fi- volumeMounts:- - name: opengym-media- mountPath: /out- resources:- requests:- memory: 128Mi- limits:- memory: 256Micontainers:- name: api# Pin both images to one release and move them together: a tag names what you run and@@ -111,13 +88,8 @@ spec:path: /port: 80initialDelaySeconds: 30- volumeMounts:- - name: opengym-media- mountPath: /usr/share/nginx/html/img- subPath: img- - name: opengym-media- mountPath: /usr/share/nginx/html/gif- subPath: gif+ # No volume: the exercise stills and animations (180 px) are part of the web image since+ # v1.4.0. They are licensed from Gym visual for openGym only; see NOTICE.md.resources:requests:memory: 32Mi@@ -127,6 +99,3 @@ spec:- name: opengym-datapersistentVolumeClaim:claimName: opengym-data- - name: opengym-media- persistentVolumeClaim:- claimName: opengym-mediadiff --git a/kubernetes/pvc.yaml b/kubernetes/pvc.yamlindex 263fe8d34..972a04e3b 100644--- a/kubernetes/pvc.yaml+++ b/kubernetes/pvc.yaml@@ -9,14 +9,3 @@ spec:resources:requests:storage: 2Gi-----apiVersion: v1-kind: PersistentVolumeClaim-metadata:- name: opengym-media-spec:- accessModes:- - ReadWriteOnce- resources:- requests:- storage: 2Gidiff --git a/scripts/build-de-exercise-names.mjs b/scripts/build-de-exercise-names.mjsdeleted file mode 100644index cb818f2bf..000000000--- a/scripts/build-de-exercise-names.mjs+++ /dev/null@@ -1,46 +0,0 @@-#!/usr/bin/env node-// Regenerates frontend/src/exercise-names/de.js from the curated source in-// scripts/exercise-name-sources/de.json.-//-// node scripts/build-de-exercise-names.mjs-//-// German ships as a stage: the 999 catalogue entries that use equipment, and not the 325-// body-weight ones, whose names keep their English title through the per-exercise fallback in-// exerciseNameFor. The coverage gate below is therefore not "how many" but "exactly which" —-// a pack that quietly lost a dumbbell entry, or gained a body-weight one, is a different-// promise from the one the README makes.--import { mkdirSync, readFileSync, writeFileSync } from 'node:fs'-import { dirname, join } from 'node:path'-import { fileURLToPath, pathToFileURL } from 'node:url'-import { AWAITING_REVIEW, BODY_WEIGHT, stagedExercises } from './de-name-rules.mjs'--const root = join(dirname(fileURLToPath(import.meta.url)), '..')-const sourcePath = join(root, 'scripts', 'exercise-name-sources', 'de.json')-const outputPath = join(root, 'frontend', 'src', 'exercise-names', 'de.js')-const exercisesPath = join(root, 'frontend', 'src', 'lib', 'exercises-data.js')--const source = JSON.parse(readFileSync(sourcePath, 'utf8'))-const { EXDB } = await import(pathToFileURL(exercisesPath))-const staged = stagedExercises(EXDB)-const expected = new Set(staged.map(exercise => exercise.id))-const known = new Map(EXDB.map(exercise => [exercise.id, exercise]))--for (const id of Object.keys(source)) {- const exercise = known.get(id)- if (!exercise) throw new Error(`Unknown exercise ID: ${id}`)- if (typeof source[id] !== 'string' || !source[id].trim()) throw new Error(`${id}: name must be a non-empty string`)- if (!expected.has(id)) throw new Error(`${id} (${exercise.n}) is ${exercise.eq || 'equipment-free'} — outside the staged equipment set`)-}-const missing = staged.filter(exercise => !source[exercise.id])-if (missing.length) {- const sample = missing.slice(0, 5).map(exercise => `${exercise.id} (${exercise.n})`).join(', ')- throw new Error(`Incomplete de exercise names: ${Object.keys(source).length}/${staged.length} — missing ${missing.length}, e.g. ${sample}`)-}--const ordered = {}-for (const exercise of staged) ordered[exercise.id] = source[exercise.id].trim()-mkdirSync(dirname(outputPath), { recursive: true })-writeFileSync(outputPath, '// generated by scripts/build-de-exercise-names.mjs — edit scripts/exercise-name-sources/de.json\nexport default ' + JSON.stringify(ordered) + '\n')-const bodyWeight = EXDB.filter(exercise => !exercise.eq || exercise.eq === BODY_WEIGHT).length-console.log(`Generated ${staged.length}/${EXDB.length} de exercise names (reviewed equipment exercises; ${bodyWeight} body-weight and ${AWAITING_REVIEW.size} awaiting-review names keep their English title).`)diff --git a/scripts/build-es-exercise-names.mjs b/scripts/build-es-exercise-names.mjsdeleted file mode 100644index 63673a866..000000000--- a/scripts/build-es-exercise-names.mjs+++ /dev/null@@ -1,28 +0,0 @@-#!/usr/bin/env node--import { mkdirSync, readFileSync, writeFileSync } from 'node:fs'-import { dirname, join } from 'node:path'-import { fileURLToPath, pathToFileURL } from 'node:url'--const root = join(dirname(fileURLToPath(import.meta.url)), '..')-const sourcePath = join(root, 'scripts', 'exercise-name-sources', 'es.json')-const outputPath = join(root, 'frontend', 'src', 'exercise-names', 'es.js')-const exercisesPath = join(root, 'frontend', 'src', 'lib', 'exercises-data.js')--const source = JSON.parse(readFileSync(sourcePath, 'utf8'))-const { EXDB } = await import(pathToFileURL(exercisesPath))-const known = new Set(EXDB.map(exercise => exercise.id))--for (const id of Object.keys(source)) {- if (!known.has(id)) throw new Error(`Unknown exercise ID: ${id}`)- if (typeof source[id] !== 'string' || !source[id].trim()) throw new Error(`${id}: name must be a non-empty string`)-}-if (Object.keys(source).length !== EXDB.length) {- throw new Error(`Incomplete es exercise names: ${Object.keys(source).length}/${EXDB.length}`)-}--const ordered = {}-for (const exercise of EXDB) ordered[exercise.id] = source[exercise.id].trim()-mkdirSync(dirname(outputPath), { recursive: true })-writeFileSync(outputPath, '// generated by scripts/build-es-exercise-names.mjs — edit scripts/exercise-name-sources/es.json\nexport default ' + JSON.stringify(ordered) + '\n')-console.log(`Generated ${EXDB.length}/${EXDB.length} es exercise names.`)diff --git a/scripts/build-fr-exercise-names.mjs b/scripts/build-fr-exercise-names.mjsdeleted file mode 100644index de047deec..000000000--- a/scripts/build-fr-exercise-names.mjs+++ /dev/null@@ -1,28 +0,0 @@-#!/usr/bin/env node--import { mkdirSync, readFileSync, writeFileSync } from 'node:fs'-import { dirname, join } from 'node:path'-import { fileURLToPath, pathToFileURL } from 'node:url'--const root = join(dirname(fileURLToPath(import.meta.url)), '..')-const sourcePath = join(root, 'scripts', 'exercise-name-sources', 'fr.json')-const outputPath = join(root, 'frontend', 'src', 'exercise-names', 'fr.js')-const exercisesPath = join(root, 'frontend', 'src', 'lib', 'exercises-data.js')--const source = JSON.parse(readFileSync(sourcePath, 'utf8'))-const { EXDB } = await import(pathToFileURL(exercisesPath))-const known = new Set(EXDB.map(exercise => exercise.id))--for (const id of Object.keys(source)) {- if (!known.has(id)) throw new Error(`Unknown exercise ID: ${id}`)- if (typeof source[id] !== 'string' || !source[id].trim()) throw new Error(`${id}: name must be a non-empty string`)-}-if (Object.keys(source).length !== EXDB.length) {- throw new Error(`Incomplete fr exercise names: ${Object.keys(source).length}/${EXDB.length}`)-}--const ordered = {}-for (const exercise of EXDB) ordered[exercise.id] = source[exercise.id].trim()-mkdirSync(dirname(outputPath), { recursive: true })-writeFileSync(outputPath, '// generated by scripts/build-fr-exercise-names.mjs — edit scripts/exercise-name-sources/fr.json\nexport default ' + JSON.stringify(ordered) + '\n')-console.log(`Generated ${EXDB.length}/${EXDB.length} fr exercise names.`)\ No newline at end of filediff --git a/scripts/build-hu-exercise-names.mjs b/scripts/build-hu-exercise-names.mjsdeleted file mode 100644index 556c646c3..000000000--- a/scripts/build-hu-exercise-names.mjs+++ /dev/null@@ -1,28 +0,0 @@-#!/usr/bin/env node--import { mkdirSync, readFileSync, writeFileSync } from 'node:fs'-import { dirname, join } from 'node:path'-import { fileURLToPath, pathToFileURL } from 'node:url'--const root = join(dirname(fileURLToPath(import.meta.url)), '..')-const sourcePath = join(root, 'scripts', 'exercise-name-sources', 'hu.json')-const outputPath = join(root, 'frontend', 'src', 'exercise-names', 'hu.js')-const exercisesPath = join(root, 'frontend', 'src', 'lib', 'exercises-data.js')--const source = JSON.parse(readFileSync(sourcePath, 'utf8'))-const { EXDB } = await import(pathToFileURL(exercisesPath))-const known = new Set(EXDB.map(exercise => exercise.id))--for (const id of Object.keys(source)) {- if (!known.has(id)) throw new Error(`Unknown exercise ID: ${id}`)- if (typeof source[id] !== 'string' || !source[id].trim()) throw new Error(`${id}: name must be a non-empty string`)-}-if (Object.keys(source).length !== EXDB.length) {- throw new Error(`Incomplete hu exercise names: ${Object.keys(source).length}/${EXDB.length}`)-}--const ordered = {}-for (const exercise of EXDB) ordered[exercise.id] = source[exercise.id].trim()-mkdirSync(dirname(outputPath), { recursive: true })-writeFileSync(outputPath, '// generated by scripts/build-hu-exercise-names.mjs — edit scripts/exercise-name-sources/hu.json\nexport default ' + JSON.stringify(ordered) + '\n')-console.log(`Generated ${EXDB.length}/${EXDB.length} hu exercise names.`)diff --git a/scripts/build-instructions.mjs b/scripts/build-instructions.mjsdeleted file mode 100644index f8fa84ed4..000000000--- a/scripts/build-instructions.mjs+++ /dev/null@@ -1,51 +0,0 @@-#!/usr/bin/env node-// Regenerates the per-language exercise instruction packs in frontend/src/instr/-// from the upstream dataset (hasaneyldrm/exercises-dataset). English stays inline-// in exercises-data.js; every other language ships as its own lazy-loaded pack.-//-// node scripts/build-instructions.mjs [path-to-exercises.json]-//-// Without an argument the dataset is downloaded from the upstream repo.-// Brazilian Portuguese is curated separately; see instruction-sources/README.md.--import { readFileSync, writeFileSync, mkdirSync } from 'node:fs'-import { dirname, join } from 'node:path'-import { fileURLToPath } from 'node:url'--const UPSTREAM = 'https://raw.githubusercontent.com/hasaneyldrm/exercises-dataset/main/data/exercises.json'-// Arabic is not listed yet: its steps live in hasaneyldrm/exercises-dataset#82, which upstream-// has not merged, so frontend/src/instr/ar.js was built from that branch. Add 'ar' here once the-// steps are on upstream main.-const LANGS = ['es', 'fr', 'it', 'tr', 'ru', 'zh', 'hi', 'pl', 'ko']--const root = join(dirname(fileURLToPath(import.meta.url)), '..')-const outDir = join(root, 'frontend', 'src', 'instr')--let raw-if (process.argv[2]) {- raw = readFileSync(process.argv[2], 'utf8')-} else {- console.log('Downloading upstream dataset…')- const res = await fetch(UPSTREAM)- if (!res.ok) throw new Error('Download failed: HTTP ' + res.status)- raw = await res.text()-}-const data = JSON.parse(raw)--mkdirSync(outDir, { recursive: true })-for (const lang of LANGS) {- const pack = {}- for (const ex of data) {- const steps = ex.instruction_steps && ex.instruction_steps[lang]- if (steps && steps.length) pack[ex.id] = steps- }- const file = join(outDir, lang + '.js')- // A language the dataset carries no steps for leaves its pack alone: writing it anyway would- // swap a working pack for an empty one, and every exercise would quietly fall back to English.- if (!Object.keys(pack).length) {- console.log(`${file}: no ${lang} steps in the dataset — pack left as it is`)- continue- }- writeFileSync(file, '// generated by scripts/build-instructions.mjs — do not edit\nexport default ' + JSON.stringify(pack) + '\n')- console.log(`${file}: ${Object.keys(pack).length} exercises`)-}diff --git a/scripts/build-it-exercise-names.mjs b/scripts/build-it-exercise-names.mjsdeleted file mode 100644index 65998423d..000000000--- a/scripts/build-it-exercise-names.mjs+++ /dev/null@@ -1,28 +0,0 @@-#!/usr/bin/env node--import { mkdirSync, readFileSync, writeFileSync } from 'node:fs'-import { dirname, join } from 'node:path'-import { fileURLToPath, pathToFileURL } from 'node:url'--const root = join(dirname(fileURLToPath(import.meta.url)), '..')-const sourcePath = join(root, 'scripts', 'exercise-name-sources', 'it.json')-const outputPath = join(root, 'frontend', 'src', 'exercise-names', 'it.js')-const exercisesPath = join(root, 'frontend', 'src', 'lib', 'exercises-data.js')--const source = JSON.parse(readFileSync(sourcePath, 'utf8'))-const { EXDB } = await import(pathToFileURL(exercisesPath))-const known = new Set(EXDB.map(exercise => exercise.id))--for (const id of Object.keys(source)) {- if (!known.has(id)) throw new Error(`Unknown exercise ID: ${id}`)- if (typeof source[id] !== 'string' || !source[id].trim()) throw new Error(`${id}: name must be a non-empty string`)-}-if (Object.keys(source).length !== EXDB.length) {- throw new Error(`Incomplete it exercise names: ${Object.keys(source).length}/${EXDB.length}`)-}--const ordered = {}-for (const exercise of EXDB) ordered[exercise.id] = source[exercise.id].trim()-mkdirSync(dirname(outputPath), { recursive: true })-writeFileSync(outputPath, '// generated by scripts/build-it-exercise-names.mjs — edit scripts/exercise-name-sources/it.json\nexport default ' + JSON.stringify(ordered) + '\n')-console.log(`Generated ${EXDB.length}/${EXDB.length} it exercise names.`)\ No newline at end of filediff --git a/scripts/build-pl-exercise-names.mjs b/scripts/build-pl-exercise-names.mjsdeleted file mode 100644index 3e00dda17..000000000--- a/scripts/build-pl-exercise-names.mjs+++ /dev/null@@ -1,28 +0,0 @@-#!/usr/bin/env node--import { mkdirSync, readFileSync, writeFileSync } from 'node:fs'-import { dirname, join } from 'node:path'-import { fileURLToPath, pathToFileURL } from 'node:url'--const root = join(dirname(fileURLToPath(import.meta.url)), '..')-const sourcePath = join(root, 'scripts', 'exercise-name-sources', 'pl.json')-const outputPath = join(root, 'frontend', 'src', 'exercise-names', 'pl.js')-const exercisesPath = join(root, 'frontend', 'src', 'lib', 'exercises-data.js')--const source = JSON.parse(readFileSync(sourcePath, 'utf8'))-const { EXDB } = await import(pathToFileURL(exercisesPath))-const known = new Set(EXDB.map(exercise => exercise.id))--for (const id of Object.keys(source)) {- if (!known.has(id)) throw new Error(`Unknown exercise ID: ${id}`)- if (typeof source[id] !== 'string' || !source[id].trim()) throw new Error(`${id}: name must be a non-empty string`)-}-if (Object.keys(source).length !== EXDB.length) {- throw new Error(`Incomplete pl exercise names: ${Object.keys(source).length}/${EXDB.length}`)-}--const ordered = {}-for (const exercise of EXDB) ordered[exercise.id] = source[exercise.id].trim()-mkdirSync(dirname(outputPath), { recursive: true })-writeFileSync(outputPath, '// generated by scripts/build-pl-exercise-names.mjs — edit scripts/exercise-name-sources/pl.json\nexport default ' + JSON.stringify(ordered) + '\n')-console.log(`Generated ${EXDB.length}/${EXDB.length} pl exercise names.`)diff --git a/scripts/build-pt-br-exercise-names.mjs b/scripts/build-pt-br-exercise-names.mjsdeleted file mode 100644index 099eb6ccc..000000000--- a/scripts/build-pt-br-exercise-names.mjs+++ /dev/null@@ -1,28 +0,0 @@-#!/usr/bin/env node--import { mkdirSync, readFileSync, writeFileSync } from 'node:fs'-import { dirname, join } from 'node:path'-import { fileURLToPath, pathToFileURL } from 'node:url'--const root = join(dirname(fileURLToPath(import.meta.url)), '..')-const sourcePath = join(root, 'scripts', 'exercise-name-sources', 'pt-BR.json')-const outputPath = join(root, 'frontend', 'src', 'exercise-names', 'pt-BR.js')-const exercisesPath = join(root, 'frontend', 'src', 'lib', 'exercises-data.js')--const source = JSON.parse(readFileSync(sourcePath, 'utf8'))-const { EXDB } = await import(pathToFileURL(exercisesPath))-const known = new Set(EXDB.map(exercise => exercise.id))--for (const id of Object.keys(source)) {- if (!known.has(id)) throw new Error(`Unknown exercise ID: ${id}`)- if (typeof source[id] !== 'string' || !source[id].trim()) throw new Error(`${id}: name must be a non-empty string`)-}-if (Object.keys(source).length !== EXDB.length) {- throw new Error(`Incomplete pt-BR exercise names: ${Object.keys(source).length}/${EXDB.length}`)-}--const ordered = {}-for (const exercise of EXDB) ordered[exercise.id] = source[exercise.id].trim()-mkdirSync(dirname(outputPath), { recursive: true })-writeFileSync(outputPath, '// generated by scripts/build-pt-br-exercise-names.mjs — edit scripts/exercise-name-sources/pt-BR.json\nexport default ' + JSON.stringify(ordered) + '\n')-console.log(`Generated ${EXDB.length}/${EXDB.length} pt-BR exercise names.`)diff --git a/scripts/build-pt-br-instructions.mjs b/scripts/build-pt-br-instructions.mjsdeleted file mode 100644index 73f210a3d..000000000--- a/scripts/build-pt-br-instructions.mjs+++ /dev/null@@ -1,33 +0,0 @@-#!/usr/bin/env node--import { readFileSync, writeFileSync } from 'node:fs'-import { dirname, join } from 'node:path'-import { fileURLToPath, pathToFileURL } from 'node:url'--const root = join(dirname(fileURLToPath(import.meta.url)), '..')-const sourcePath = join(root, 'scripts', 'instruction-sources', 'pt-BR.json')-const outputPath = join(root, 'frontend', 'src', 'instr', 'pt-BR.js')-const exercisesPath = join(root, 'frontend', 'src', 'lib', 'exercises-data.js')--const translations = JSON.parse(readFileSync(sourcePath, 'utf8'))-const { EXDB } = await import(pathToFileURL(exercisesPath))-const exercises = new Map(EXDB.map(exercise => [exercise.id, exercise]))--for (const [id, steps] of Object.entries(translations)) {- const exercise = exercises.get(id)- if (!exercise) throw new Error(`Unknown exercise ID: ${id}`)- if (!Array.isArray(steps) || steps.length === 0) throw new Error(`${id}: translation must contain steps`)- if (steps.length !== exercise.st.length) {- throw new Error(`${id}: expected ${exercise.st.length} steps, received ${steps.length}`)- }- steps.forEach((step, index) => {- if (typeof step !== 'string' || !step.trim()) throw new Error(`${id}: empty step ${index + 1}`)- if (step === exercise.st[index]) throw new Error(`${id}: step ${index + 1} is still English`)- })-}--const ordered = Object.fromEntries(EXDB.filter(exercise => translations[exercise.id]).map(exercise => [exercise.id, translations[exercise.id]]))-writeFileSync(outputPath, '// generated by scripts/build-pt-br-instructions.mjs — edit scripts/instruction-sources/pt-BR.json\nexport default ' + JSON.stringify(ordered) + '\n')--const stepCount = Object.values(ordered).reduce((total, steps) => total + steps.length, 0)-console.log(`${outputPath}: ${Object.keys(ordered).length}/${EXDB.length} exercises, ${stepCount} steps`)diff --git a/scripts/build-ru-exercise-names.mjs b/scripts/build-ru-exercise-names.mjsdeleted file mode 100644index 59e52dd5e..000000000--- a/scripts/build-ru-exercise-names.mjs+++ /dev/null@@ -1,28 +0,0 @@-#!/usr/bin/env node--import { mkdirSync, readFileSync, writeFileSync } from 'node:fs'-import { dirname, join } from 'node:path'-import { fileURLToPath, pathToFileURL } from 'node:url'--const root = join(dirname(fileURLToPath(import.meta.url)), '..')-const sourcePath = join(root, 'scripts', 'exercise-name-sources', 'ru.json')-const outputPath = join(root, 'frontend', 'src', 'exercise-names', 'ru.js')-const exercisesPath = join(root, 'frontend', 'src', 'lib', 'exercises-data.js')--const source = JSON.parse(readFileSync(sourcePath, 'utf8'))-const { EXDB } = await import(pathToFileURL(exercisesPath))-const known = new Set(EXDB.map(exercise => exercise.id))--for (const id of Object.keys(source)) {- if (!known.has(id)) throw new Error(`Unknown exercise ID: ${id}`)- if (typeof source[id] !== 'string' || !source[id].trim()) throw new Error(`${id}: name must be a non-empty string`)-}-if (Object.keys(source).length !== EXDB.length) {- throw new Error(`Incomplete ru exercise names: ${Object.keys(source).length}/${EXDB.length}`)-}--const ordered = {}-for (const exercise of EXDB) ordered[exercise.id] = source[exercise.id].trim()-mkdirSync(dirname(outputPath), { recursive: true })-writeFileSync(outputPath, '// generated by scripts/build-ru-exercise-names.mjs — edit scripts/exercise-name-sources/ru.json\nexport default ' + JSON.stringify(ordered) + '\n')-console.log(`Generated ${EXDB.length}/${EXDB.length} ru exercise names.`)diff --git a/scripts/translate-de-exercise-names.mjs b/scripts/translate-de-exercise-names.mjsdeleted file mode 100644index 5e18c8a06..000000000--- a/scripts/translate-de-exercise-names.mjs+++ /dev/null@@ -1,209 +0,0 @@-#!/usr/bin/env node-// Translates a stage of English exercise titles into German, in schema-validated, checkpointed-// batches. Mirrors translate-pt-br-exercise-names.mjs, with the rule check and correction loop-// translate-de-stage.mjs proved necessary; see exercise-name-sources/README.md.-//-// node scripts/translate-de-exercise-names.mjs --equipment=dumbbell [--limit=40] [--apply]-// node scripts/translate-de-exercise-names.mjs --ids=0025,1234 --max-retries=2-//-// Without --apply nothing is written: the batch is translated, checked and printed English-// beside German, which is the cheap way to judge a prompt or model change before a whole stage-// rides on it. Body-weight exercises are outside the staged set and are never offered here.--import { spawnSync } from 'node:child_process'-import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'-import { tmpdir } from 'node:os'-import { dirname, join } from 'node:path'-import { fileURLToPath, pathToFileURL } from 'node:url'-import { checkName, promptGlossary, stagedExercises } from './de-name-rules.mjs'--const root = join(dirname(fileURLToPath(import.meta.url)), '..')-const sourcePath = join(root, 'scripts', 'exercise-name-sources', 'de.json')-const exercisesPath = join(root, 'frontend', 'src', 'lib', 'exercises-data.js')-const claude = process.env.CLAUDE_BIN || 'claude'-const codex = process.env.CODEX_BIN || 'codex'--const option = name => process.argv.find(arg => arg.startsWith(`--${name}=`))?.split('=').slice(1).join('=')-const equipment = option('equipment')-// Named exercises, for re-running the handful a review rejected without touching the rest.-const ids = option('ids')?.split(',').map(id => id.trim()).filter(Boolean)-const provider = option('provider') || 'claude'-const limit = Number(option('limit') || (ids ? ids.length : 40))-const batchSize = Number(option('batch-size') || 40)-const maxRetries = Number(option('max-retries') ?? 2)-const apply = process.argv.includes('--apply')--if (!equipment && !ids) throw new Error('Usage: translate-de-exercise-names.mjs (--equipment=dumbbell|all | --ids=0025,1234) [--limit=40] [--batch-size=40] [--max-retries=2] [--provider=claude|codex] [--model=NAME] [--apply]')-if (equipment && ids) throw new Error('Pass --equipment or --ids, not both')-if (!['claude', 'codex'].includes(provider)) throw new Error('provider must be claude or codex')-const model = option('model') || (provider === 'claude' ? 'sonnet' : '')-if (!Number.isInteger(limit) || limit < 1 || !Number.isInteger(batchSize) || batchSize < 1) {- throw new Error('limit and batch-size must be positive integers')-}--// The first stage of a language creates the source file; every later one extends it.-const translations = existsSync(sourcePath) ? JSON.parse(readFileSync(sourcePath, 'utf8')) : {}-const { EXDB } = await import(pathToFileURL(exercisesPath))-const staged = stagedExercises(EXDB)-const inStage = new Map(staged.map(exercise => [exercise.id, exercise]))--const selected = ids- ? ids.map(id => {- const exercise = inStage.get(id)- // Loud, because a typo'd or body-weight ID would otherwise just shorten the sample silently.- if (!exercise) throw new Error(`${id} is not in the staged equipment set (unknown, or body weight)`)- return exercise- })- : equipment === 'all' ? staged : staged.filter(exercise => exercise.eq === equipment)--if (!selected.length) throw new Error(`No staged exercises for --equipment=${equipment}. Values are the catalogue's own, e.g. dumbbell, cable, barbell, "leverage machine".`)-const pending = selected.filter(exercise => !translations[exercise.id]).slice(0, limit)-const skipped = selected.length - selected.filter(exercise => !translations[exercise.id]).length-if (skipped) console.log(`Skipping ${skipped} of ${selected.length} selected: already in de.json.`)-if (!pending.length) {- console.log('Everything selected is already translated.')- process.exit(0)-}--const next = { ...translations }-// One request to whichever provider, returning the parsed { translations: [...] } envelope.-// Extracted so the caller can retry it with a correction prompt without duplicating any of it.-// Async like its sibling in translate-de-stage.mjs, so a provider that speaks HTTP rather than-// a subprocess slots in without turning the loop below inside out.-const requestStructured = async (prompt, batch) => {- let structured- const schema = {- type: 'object',- properties: {- translations: {- type: 'array', minItems: batch.length, maxItems: batch.length,- items: {- type: 'object',- properties: { id: { type: 'string' }, name: { type: 'string', minLength: 1 } },- required: ['id', 'name'], additionalProperties: false- }- }- },- required: ['translations'], additionalProperties: false- }- if (provider === 'claude') {- const result = spawnSync(claude, [- '-p', '--model', model, '--effort', 'high', '--no-session-persistence',- '--permission-mode', 'dontAsk', '--disallowedTools', 'Bash', 'Edit', 'Write', 'Read',- '--output-format', 'json', '--max-budget-usd', '2', '--json-schema', JSON.stringify(schema)- ], { input: prompt, encoding: 'utf8', maxBuffer: 16 * 1024 * 1024 })- if (result.status !== 0) throw new Error(result.stderr || result.stdout || `Claude exited ${result.status}`)- const envelope = JSON.parse(result.stdout)- if (envelope.is_error || !envelope.structured_output) throw new Error(envelope.result || 'Claude returned no structured output')- structured = envelope.structured_output- } else {- const temp = mkdtempSync(join(tmpdir(), 'opengym-de-names-'))- const schemaPath = join(temp, 'schema.json')- const outputPath = join(temp, 'output.json')- try {- writeFileSync(schemaPath, JSON.stringify(schema))- const result = spawnSync(codex, [- 'exec', '--skip-git-repo-check', '--ephemeral', '--ignore-user-config',- '--sandbox', 'read-only', '--output-schema', schemaPath,- '--output-last-message', outputPath, '-'- ], { input: prompt, encoding: 'utf8', cwd: temp, maxBuffer: 16 * 1024 * 1024 })- if (result.status !== 0) throw new Error(result.stderr || result.stdout || `Codex exited ${result.status}`)- structured = JSON.parse(readFileSync(outputPath, 'utf8'))- } finally {- rmSync(temp, { recursive: true, force: true })- }- }- return structured-}--for (let start = 0; start < pending.length; start += batchSize) {- const batch = pending.slice(start, start + batchSize)- const input = batch.map(({ id, n, bp, eq, tg }) => ({ id, english: n, bodyPart: bp, equipment: eq, target: tg }))- const basePrompt = `Translate every exercise title below into concise, natural German for a gym app.--Rules:-- Return only the structured JSON required by the schema, with every ID exactly once and in input order.-- Return only the German title in "name". Do not append, repeat or bracket the English title — the app shows it itself.-- A title is a noun phrase, not a sentence: no final full stop, and German noun capitalisation ("Bankdrücken mit Langhantel", "Rudern am Kabelzug").-- Capitalise the first word whatever it is. A leading adjective is capitalised here even though German would lowercase it mid-sentence: "Abwechselnder Latzug am Kabelzug", "Assistierter Klimmzug an der Hebelmaschine". Every LATER adjective stays lowercase: "Assistiertes hängendes Knieheben", never "Assistiertes Hängendes Knieheben".-- Name the movement first and put the equipment in a trailing phrase, or join it into one hyphenated compound. Do NOT copy the English order, which leads with the equipment. "dumbbell incline one arm fly" is "Einarmige Fliegende auf der Schrägbank mit Kurzhantel" or "Einarmige Schrägbank-Fliegende mit Kurzhantel" — never "Kurzhantel Schrägbank einarmige Fliegende". German joins nouns with a hyphen or a preposition; it does not stack them with spaces.-- Preserve exercise identity: equipment, stance, grip, direction, side, assisted/weighted status and version qualifiers all distinguish one catalogue entry from another.-- Prefer established German gym terminology (Bankdrücken, Kniebeuge, Kreuzheben, Rudern, Latzug, Klimmzug, Liegestütz, Ausfallschritt, Wadenheben, Beinpresse, Fliegende, Nackendrücken).-- Use standard German ß (Gesäß, Fuß), not the Swiss ss — the app derives the Swiss spelling from this pack.-- Avoid unnecessary anglicisms: no Glutes, Hamstrings, Core. Established loanwords such as Kettlebell, Burpee, Crunch and Plank are fine.-- Do not repair or reinterpret questionable source mechanics; translate the title faithfully.-- Use the metadata only to disambiguate the English title.--TERMINOLOGY:-${promptGlossary()}--INPUT:-${JSON.stringify(input)}`-- console.log(`Translating names ${start + 1}-${start + batch.length} of ${pending.length} with ${provider} (${batch[0].id}…${batch.at(-1).id})`)-- // Validate and retry. The rules are the ones CI enforces (scripts/de-name-rules.mjs), so- // checking them here turns a failure discovered hours later into a correction the model can act- // on while it still has the batch in hand. A batch that cannot be fixed is never written.- let prompt = basePrompt- let accepted- // A name that has passed the rules once is kept, and the model is never asked for it again.- // Without this the loop oscillates: told only about what is broken *now*, the model rewrites- // the batch from scratch and silently reverts the corrections it made on the previous attempt,- // so a batch can fail after three attempts having had every name clean at some point in them.- const pinned = new Map()- for (let attempt = 0; ; attempt++) {- const structured = await requestStructured(prompt, batch)- const received = new Map(structured.translations.map(row => [row.id, row.name.trim()]))- if (received.size !== batch.length) throw new Error(`${provider} returned duplicate or missing IDs`)- for (const [id, name] of pinned) received.set(id, name)-- const problems = []- for (const exercise of batch) {- const name = received.get(exercise.id)- if (!name) throw new Error(`${exercise.id}: missing translated name`)- const broken = checkName(exercise, name)- if (broken.length) problems.push({ id: exercise.id, name, broken })- else pinned.set(exercise.id, name)- }-- if (!problems.length) {- accepted = received- if (attempt) console.log(` clean after ${attempt} correction${attempt > 1 ? 's' : ''}`)- break- }-- const summary = problems.map(p => ` ${p.id}: ${p.broken.map(v => v.rule).join(', ')}\n ${p.name}`).join('\n')- if (attempt >= maxRetries) {- throw new Error(`${problems.length} rule violation(s) still present after ${maxRetries + 1} attempts:\n${summary}`)- }- console.log(` ${problems.length} violation(s), correcting (${attempt + 1}/${maxRetries}):\n${summary}`)-- // Only the broken names are quoted back. Re-sending the whole batch as "wrong" invites the- // model to rewrite names that were already fine, which loses good work and breaks other rules.- // The settled names are still listed, because a model that is not shown them invents new ones- // for those IDs — harmless now that they are pinned, but it spends the batch's attention on- // work that will be discarded instead of on the names that are actually still wrong.- const settled = [...pinned].map(([id, name]) => `- ${id}: ${JSON.stringify(name)}`).join('\n')- prompt = `${basePrompt}-${settled ? `\nThese names are already accepted. Return them back exactly as they are:\n${settled}\n` : ''}-Your previous answer broke these rules. Return the FULL JSON for every ID again, changing only the names listed here:-${problems.map(p => `- ${p.id} was: ${JSON.stringify(p.name)}\n${p.broken.map(v => ` ${v.fix}`).join('\n')}`).join('\n')}`- }-- for (const exercise of batch) next[exercise.id] = accepted.get(exercise.id)- if (apply) {- writeFileSync(sourcePath, JSON.stringify(next, null, 2) + '\n')- console.log(`Checkpoint: ${Object.keys(next).length}/${staged.length} names`)- }-}--if (!apply) {- // A dry run exists to be read: a bare count leaves nothing to judge a new model or a changed- // prompt by, which is the whole reason for running without --apply.- for (const exercise of pending) console.log(`\n${exercise.id}\n EN ${exercise.n}\n DE ${next[exercise.id]}`)- console.log(`\nValidated ${pending.length} names. Re-run with --apply to update ${sourcePath}.`)- process.exit(0)-}--console.log(`Updated ${sourcePath}: ${Object.keys(next).length}/${staged.length} names`)diff --git a/scripts/translate-pt-br-exercise-names.mjs b/scripts/translate-pt-br-exercise-names.mjsdeleted file mode 100644index 06bbfe966..000000000--- a/scripts/translate-pt-br-exercise-names.mjs+++ /dev/null@@ -1,87 +0,0 @@-#!/usr/bin/env node--import { spawnSync } from 'node:child_process'-import { readFileSync, writeFileSync } from 'node:fs'-import { dirname, join } from 'node:path'-import { fileURLToPath, pathToFileURL } from 'node:url'--const root = join(dirname(fileURLToPath(import.meta.url)), '..')-const sourcePath = join(root, 'scripts', 'exercise-name-sources', 'pt-BR.json')-const glossaryPath = join(root, 'scripts', 'instruction-sources', 'GLOSSARY.md')-const exercisesPath = join(root, 'frontend', 'src', 'lib', 'exercises-data.js')-const claude = process.env.CLAUDE_BIN || 'claude'-const option = name => process.argv.find(arg => arg.startsWith(`--${name}=`))?.split('=').slice(1).join('=')-const limit = Number(option('limit') || 1324)-const batchSize = Number(option('batch-size') || 80)-const apply = process.argv.includes('--apply')--if (!Number.isInteger(limit) || limit < 1 || !Number.isInteger(batchSize) || batchSize < 1) {- throw new Error('limit and batch-size must be positive integers')-}--const existing = JSON.parse(readFileSync(sourcePath, 'utf8'))-const glossary = readFileSync(glossaryPath, 'utf8')-const { EXDB } = await import(pathToFileURL(exercisesPath))-const pending = EXDB.filter(exercise => !existing[exercise.id]).slice(0, limit)-const next = { ...existing }--for (let start = 0; start < pending.length; start += batchSize) {- const batch = pending.slice(start, start + batchSize)- const schema = {- type: 'object',- properties: {- translations: {- type: 'array', minItems: batch.length, maxItems: batch.length,- items: {- type: 'object',- properties: { id: { type: 'string' }, name: { type: 'string', minLength: 1 } },- required: ['id', 'name'], additionalProperties: false- }- }- },- required: ['translations'], additionalProperties: false- }- const input = batch.map(({ id, n, bp, eq, tg }) => ({ id, english: n, bodyPart: bp, equipment: eq, target: tg }))- const prompt = `Translate every exercise title below into concise, natural Brazilian Portuguese for a gym app.--Rules:-- Return only the structured JSON required by the schema, with every ID exactly once and in input order.-- Return only the Portuguese title in "name". Do not append or repeat the English title.-- Preserve exercise identity, equipment, stance, grip, direction, side, assisted/weighted status and version qualifiers.-- Prefer established Brazilian gym terminology (for example: supino, agachamento, remada, puxada, rosca, elevação, extensão, flexão de braços, barra fixa, afundo, levantamento terra).-- Keep accepted equipment or exercise names such as kettlebell, Smith, hack squat, leg press and Romanian deadlift when that is the clearest Brazilian usage.-- Use sentence case, not Title Case. Do not use Portuguese (Portugal) terms.-- Do not repair or reinterpret questionable source mechanics; translate the title faithfully.-- Use the metadata only to disambiguate the English title.--GLOSSARY:-${glossary}--INPUT:-${JSON.stringify(input)}`-- console.log(`Translating names ${start + 1}-${start + batch.length} of ${pending.length} (${batch[0].id}…${batch.at(-1).id})`)- const result = spawnSync(claude, [- '-p', '--model', 'sonnet', '--effort', 'high', '--no-session-persistence',- '--permission-mode', 'dontAsk', '--disallowedTools', 'Bash', 'Edit', 'Write', 'Read',- '--output-format', 'json', '--max-budget-usd', '2', '--json-schema', JSON.stringify(schema)- ], { input: prompt, encoding: 'utf8', maxBuffer: 16 * 1024 * 1024 })- if (result.status !== 0) throw new Error(result.stderr || result.stdout || `Claude exited ${result.status}`)- const envelope = JSON.parse(result.stdout)- if (envelope.is_error || !envelope.structured_output) throw new Error(envelope.result || 'Claude returned no structured output')- const rows = envelope.structured_output.translations- const received = new Map(rows.map(row => [row.id, row.name.trim()]))- if (received.size !== batch.length) throw new Error('Claude returned duplicate or missing IDs')- for (const exercise of batch) {- const name = received.get(exercise.id)- if (!name) throw new Error(`${exercise.id}: missing translated name`)- next[exercise.id] = name- }- if (apply) {- writeFileSync(sourcePath, JSON.stringify(next, null, 2) + '\n')- console.log(`Checkpoint: ${Object.keys(next).length}/${EXDB.length} names`)- }-}--if (!apply) console.log(`Validated ${pending.length} names. Re-run with --apply to update the source.`)-else console.log(`Updated ${sourcePath}: ${Object.keys(next).length}/${EXDB.length} names`)diff --git a/scripts/translate-pt-br-stage.mjs b/scripts/translate-pt-br-stage.mjsdeleted file mode 100644index 50c8acb3b..000000000--- a/scripts/translate-pt-br-stage.mjs+++ /dev/null@@ -1,148 +0,0 @@-#!/usr/bin/env node--import { spawnSync } from 'node:child_process'-import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'-import { tmpdir } from 'node:os'-import { dirname, join } from 'node:path'-import { fileURLToPath, pathToFileURL } from 'node:url'--const root = join(dirname(fileURLToPath(import.meta.url)), '..')-const sourcePath = join(root, 'scripts', 'instruction-sources', 'pt-BR.json')-const glossaryPath = join(root, 'scripts', 'instruction-sources', 'GLOSSARY.md')-const exercisesPath = join(root, 'frontend', 'src', 'lib', 'exercises-data.js')-const claude = process.env.CLAUDE_BIN || 'claude'-const codex = process.env.CODEX_BIN || 'codex'-const stageOrder = ['chest', 'back', 'shoulders', 'upper arms', 'lower arms', 'upper legs', 'lower legs', 'cardio', 'neck']--const option = name => process.argv.find(arg => arg.startsWith(`--${name}=`))?.split('=').slice(1).join('=')-const bodyPart = option('body-part')-const provider = option('provider') || 'claude'-const limit = Number(option('limit') || 10)-const batchSize = Number(option('batch-size') || 10)-const apply = process.argv.includes('--apply')--if (!bodyPart) throw new Error('Usage: translate-pt-br-stage.mjs --body-part=waist|all [--limit=10] [--batch-size=10] [--apply]')-if (!['claude', 'codex'].includes(provider)) throw new Error('provider must be claude or codex')-if (!Number.isInteger(limit) || limit < 1 || !Number.isInteger(batchSize) || batchSize < 1) {- throw new Error('limit and batch-size must be positive integers')-}--const translations = JSON.parse(readFileSync(sourcePath, 'utf8'))-const glossary = readFileSync(glossaryPath, 'utf8')-const { EXDB } = await import(pathToFileURL(exercisesPath))-const requestedParts = bodyPart === 'all' ? stageOrder : [bodyPart]-const pending = requestedParts- .flatMap(part => EXDB.filter(exercise => exercise.bp === part && !translations[exercise.id]))- .slice(0, limit)--if (!pending.length) {- console.log(`No untranslated ${bodyPart} exercises remain.`)- process.exit(0)-}--const next = { ...translations }-for (let start = 0; start < pending.length; start += batchSize) {- const batch = pending.slice(start, start + batchSize)- const schema = {- type: 'object',- properties: {- translations: {- type: 'array', minItems: batch.length, maxItems: batch.length,- items: {- oneOf: batch.map(exercise => ({- type: 'object',- properties: {- id: { const: exercise.id },- steps: { type: 'array', minItems: exercise.st.length, maxItems: exercise.st.length, items: { type: 'string', minLength: 1 } }- },- required: ['id', 'steps'], additionalProperties: false- }))- }- }- },- required: ['translations'], additionalProperties: false- }- const input = batch.map(({ id, n, st }) => ({ id, name: n, steps: st }))- const prompt = `Translate every instruction step below from English into natural Brazilian Portuguese for a fitness app.--Rules:-- Return only the structured JSON required by the schema, with every ID exactly once and in input order.-- Preserve the exact number, order, movement meaning and safety cues of the English steps.-- Use Brazilian você conventions and neutral imperatives: mantenha, contraia, eleve, retorne.-- Follow the glossary. In particular, translate "engage your core/abs" as "contraia o abdômen", never "ative o core".-- Do not use Portuguese (Portugal) wording. Do not add explanations or repair source mechanics.-- Translate only instruction steps; IDs remain unchanged.--GLOSSARY:-${glossary}--INPUT:-${JSON.stringify(input)}`-- console.log(`Translating ${start + 1}-${start + batch.length} of ${pending.length} with ${provider} (${batch[0].id}…${batch.at(-1).id})`)- let structured- if (provider === 'claude') {- const result = spawnSync(claude, [- '-p', '--model', 'sonnet', '--effort', 'high', '--no-session-persistence',- '--permission-mode', 'dontAsk', '--disallowedTools', 'Bash', 'Edit', 'Write', 'Read',- '--output-format', 'json', '--max-budget-usd', '2', '--json-schema', JSON.stringify(schema)- ], { input: prompt, encoding: 'utf8', maxBuffer: 16 * 1024 * 1024 })- if (result.status !== 0) throw new Error(result.stderr || result.stdout || `Claude exited ${result.status}`)- const envelope = JSON.parse(result.stdout)- if (envelope.is_error || !envelope.structured_output) throw new Error(envelope.result || 'Claude returned no structured output')- structured = envelope.structured_output- } else {- const temp = mkdtempSync(join(tmpdir(), 'opengym-pt-br-'))- const schemaPath = join(temp, 'schema.json')- const outputPath = join(temp, 'output.json')- const codexSchema = {- type: 'object',- properties: {- translations: {- type: 'array', minItems: batch.length, maxItems: batch.length,- items: {- type: 'object',- properties: {- id: { type: 'string' },- steps: { type: 'array', items: { type: 'string' } }- },- required: ['id', 'steps'], additionalProperties: false- }- }- },- required: ['translations'], additionalProperties: false- }- try {- writeFileSync(schemaPath, JSON.stringify(codexSchema))- const result = spawnSync(codex, [- 'exec', '--skip-git-repo-check', '--ephemeral', '--ignore-user-config',- '--sandbox', 'read-only', '--output-schema', schemaPath,- '--output-last-message', outputPath, '-'- ], { input: prompt, encoding: 'utf8', cwd: temp, maxBuffer: 16 * 1024 * 1024 })- if (result.status !== 0) throw new Error(result.stderr || result.stdout || `Codex exited ${result.status}`)- structured = JSON.parse(readFileSync(outputPath, 'utf8'))- } finally {- rmSync(temp, { recursive: true, force: true })- }- }-- const rows = structured.translations- const received = new Map(rows.map(row => [row.id, row.steps]))- if (received.size !== batch.length) throw new Error(`${provider} returned duplicate or missing IDs`)- for (const exercise of batch) {- const steps = received.get(exercise.id)- if (!steps || steps.length !== exercise.st.length) throw new Error(`${exercise.id}: invalid step count`)- next[exercise.id] = steps- }- if (apply) {- writeFileSync(sourcePath, JSON.stringify(next, null, 2) + '\n')- console.log(`Checkpoint: ${Object.keys(next).length}/${EXDB.length} exercises`)- }-}--if (!apply) {- console.log(`Validated ${pending.length} translations. Re-run with --apply to update ${sourcePath}.`)- process.exit(0)-}--console.log(`Updated ${sourcePath}: ${Object.keys(next).length}/${EXDB.length} exercises`)diff --git a/scripts/translate-ru-exercise-names.mjs b/scripts/translate-ru-exercise-names.mjsdeleted file mode 100644index cddb07c3e..000000000--- a/scripts/translate-ru-exercise-names.mjs+++ /dev/null@@ -1,89 +0,0 @@-#!/usr/bin/env node--import { spawnSync } from 'node:child_process'-import { readFileSync, writeFileSync } from 'node:fs'-import { dirname, join } from 'node:path'-import { fileURLToPath, pathToFileURL } from 'node:url'--const root = join(dirname(fileURLToPath(import.meta.url)), '..')-const sourcePath = join(root, 'scripts', 'exercise-name-sources', 'ru.json')-const glossaryPath = join(root, 'scripts', 'exercise-name-sources', 'GLOSSARY.ru.md')-const exercisesPath = join(root, 'frontend', 'src', 'lib', 'exercises-data.js')-const claude = process.env.CLAUDE_BIN || 'claude'-const option = name => process.argv.find(arg => arg.startsWith(`--${name}=`))?.split('=').slice(1).join('=')-const limit = Number(option('limit') || 1324)-const batchSize = Number(option('batch-size') || 80)-const apply = process.argv.includes('--apply')--if (!Number.isInteger(limit) || limit < 1 || !Number.isInteger(batchSize) || batchSize < 1) {- throw new Error('limit and batch-size must be positive integers')-}--const existing = JSON.parse(readFileSync(sourcePath, 'utf8'))-const glossary = readFileSync(glossaryPath, 'utf8')-const { EXDB } = await import(pathToFileURL(exercisesPath))-const pending = EXDB.filter(exercise => !existing[exercise.id]).slice(0, limit)-const next = { ...existing }--for (let start = 0; start < pending.length; start += batchSize) {- const batch = pending.slice(start, start + batchSize)- const schema = {- type: 'object',- properties: {- translations: {- type: 'array', minItems: batch.length, maxItems: batch.length,- items: {- type: 'object',- properties: { id: { type: 'string' }, name: { type: 'string', minLength: 1 } },- required: ['id', 'name'], additionalProperties: false- }- }- },- required: ['translations'], additionalProperties: false- }- const input = batch.map(({ id, n, bp, eq, tg }) => ({ id, english: n, bodyPart: bp, equipment: eq, target: tg }))- const prompt = `Translate every exercise title below into concise, natural Russian for a gym app.--Rules:-- Return only the structured JSON required by the schema, with every ID exactly once and in input order.-- Return only the Russian title in "name". Do not append or repeat the English title.-- Preserve exercise identity, equipment, stance, grip, direction, side, assisted/weighted status and version qualifiers.-- Prefer the terminology a Russian-speaking gym actually uses (for example: жим, тяга, приседание, сгибание, разгибание, подъём, выпад, отжимание, подтягивание, становая тяга, махи).-- Keep established loanwords where they are the normal spoken term: бёрпи, пилатес, кроссовер, гакк-приседание, EZ-гриф, машина Смита. Do not invent a calque where the loanword is what people say.-- Use sentence case, not Title Case, and no final full stop.-- Keep the English word order — equipment, then movement, then qualifiers — so the list stays scannable beside the English original the app shows in parentheses.-- Use ё where it belongs: подъём, лёжа, бёрпи.-- Do not repair or reinterpret questionable source mechanics; translate the title faithfully.-- Use the metadata only to disambiguate the English title.--GLOSSARY:-${glossary}--INPUT:-${JSON.stringify(input)}`-- console.log(`Translating names ${start + 1}-${start + batch.length} of ${pending.length} (${batch[0].id}…${batch.at(-1).id})`)- const result = spawnSync(claude, [- '-p', '--model', 'sonnet', '--effort', 'high', '--no-session-persistence',- '--permission-mode', 'dontAsk', '--disallowedTools', 'Bash', 'Edit', 'Write', 'Read',- '--output-format', 'json', '--max-budget-usd', '2', '--json-schema', JSON.stringify(schema)- ], { input: prompt, encoding: 'utf8', maxBuffer: 16 * 1024 * 1024 })- if (result.status !== 0) throw new Error(result.stderr || result.stdout || `Claude exited ${result.status}`)- const envelope = JSON.parse(result.stdout)- if (envelope.is_error || !envelope.structured_output) throw new Error(envelope.result || 'Claude returned no structured output')- const rows = envelope.structured_output.translations- const received = new Map(rows.map(row => [row.id, row.name.trim()]))- if (received.size !== batch.length) throw new Error('Claude returned duplicate or missing IDs')- for (const exercise of batch) {- const name = received.get(exercise.id)- if (!name) throw new Error(`${exercise.id}: missing translated name`)- next[exercise.id] = name- }- if (apply) {- writeFileSync(sourcePath, JSON.stringify(next, null, 2) + '\n')- console.log(`Checkpoint: ${Object.keys(next).length}/${EXDB.length} names`)- }-}--if (!apply) console.log(`Validated ${pending.length} names. Re-run with --apply to update the source.`)-else console.log(`Updated ${sourcePath}: ${Object.keys(next).length}/${EXDB.length} names`)diff --git a/website/README.md b/website/README.mdindex 0c88e5da2..1f5647959 100644--- a/website/README.md+++ b/website/README.md@@ -12,10 +12,12 @@ Not in this folder (added at deploy time):icons the PWA uses, so the browser tab, home screen and app all match)- `openGym.apk` — the signed release build (see `../docs/MOBILE.md`)- `demo/` — the browser-only demo build of the app, embedded in the `#demo` section and- reachable on its own at `/demo/`. Built from `../frontend` with `VITE_DEMO=1` and the- jsDelivr media bases (see the `pages` job in `../.gitlab-ci.yml`), so the ~140 MB- of exercise media stays out of it. It has to live on this host: the site frames it, and- `X-Frame-Options: SAMEORIGIN` would block it from anywhere else.+ reachable on its own at `/demo/`. Built from `../frontend` with `VITE_DEMO=1`, with the+ 180 px exercise media from `../catalogue/media` staged into `demo/exercise-media/` by+ `../scripts/catalogue/stage-media.mjs` (see the `pages` job in `../.gitlab-ci.yml`).+ Never put larger media here (see `../catalogue/media/NOTICE.md`). It has to live on+ this host: the site frames it, and `X-Frame-Options: SAMEORIGIN` would block it from+ anywhere else.Every page has the same top bar. Pages with a table of contents (home, docs, about, API)also have a contents drawer (`.side`), opened by the green **Contents** pill in thediff --git a/website/docs.html b/website/docs.htmlindex 43e0a3702..7b741c76c 100644--- a/website/docs.html+++ b/website/docs.html@@ -29,7 +29,7 @@<!-- Umami web analytics for opengym.duarte-santos.ch (self-hosted, cookieless). --><script defer src="https://stats.duarte-santos.ch/script.js" data-website-id="db36019e-50f4-453c-9c56-d0588aefe233"></script><script type="application/ld+json">-{"@context": "https://schema.org", "@type": "FAQPage", "mainEntity": [{"@type": "Question", "name": "Is openGym really free?", "acceptedAnswer": {"@type": "Answer", "text": "Yes — free as in cost and as in freedom (AGPL-3.0). No pro tier, no locked features, no ads, and the license keeps every fork open source too."}}, {"@type": "Question", "name": "Why isn't openGym on the Play Store or App Store?", "acceptedAnswer": {"@type": "Answer", "text": "By choice (and on iOS, by Apple's rules for sideloading). Store accounts cost money, impose terms that sit badly with the AGPL, and put a gatekeeper between you and an app whose whole point is that your data is yours. The signed Android APK is a direct download."}}, {"@type": "Question", "name": "Should I pick the mobile app or self-host?", "acceptedAnswer": {"@type": "Answer", "text": "To simply track your training: the mobile app. For data on your own hardware, synced across devices, with profiles for the people you train with: self-host with Docker. The backup file migrates everything between the two, or pair the app to your server."}}, {"@type": "Question", "name": "What's on the openGym roadmap?", "acceptedAnswer": {"@type": "Answer", "text": "A small, themed release roughly every two weeks: a session queue, programmes and phases, AMRAP/%1RM/5-3-1 progression, cardio intervals, then database storage (v1.4.0), better search, OIDC login, a trainer role and an App Store build. The full plan is in ROADMAP.md on GitHub."}}, {"@type": "Question", "name": "Was openGym written with AI?", "acceptedAnswer": {"@type": "Answer", "text": "openGym is developed with Claude Code, Anthropic's coding agent; a large share of the code, tests and docs is drafted that way, and every change is reviewed, tested and released by the maintainer. The app itself calls no AI service unless an admin switches on the optional AI coach."}}, {"@type": "Question", "name": "Where does the exercise database come from?", "acceptedAnswer": {"@type": "Answer", "text": "From hasaneyldrm/exercises-dataset: 1,324 exercises with animations and instructions. The metadata and instruction text are MIT; the images and animations are third-party media that openGym never redistributes — your instance downloads them from upstream on first run."}}, {"@type": "Question", "name": "What does the AGPL license mean for me?", "acceptedAnswer": {"@type": "Answer", "text": "You can self-host, use, modify and share openGym freely. Only if you run a modified version as a network service must you offer that version's source under the same license. Using or self-hosting it unmodified obliges you to nothing."}}]}+{"@context": "https://schema.org", "@type": "FAQPage", "mainEntity": [{"@type": "Question", "name": "Is openGym really free?", "acceptedAnswer": {"@type": "Answer", "text": "Yes — free as in cost and as in freedom (AGPL-3.0). No pro tier, no locked features, no ads, and the license keeps every fork open source too."}}, {"@type": "Question", "name": "Why isn't openGym on the Play Store or App Store?", "acceptedAnswer": {"@type": "Answer", "text": "By choice (and on iOS, by Apple's rules for sideloading). Store accounts cost money, impose terms that sit badly with the AGPL, and put a gatekeeper between you and an app whose whole point is that your data is yours. The signed Android APK is a direct download."}}, {"@type": "Question", "name": "Should I pick the mobile app or self-host?", "acceptedAnswer": {"@type": "Answer", "text": "To simply track your training: the mobile app. For data on your own hardware, synced across devices, with profiles for the people you train with: self-host with Docker. The backup file migrates everything between the two, or pair the app to your server."}}, {"@type": "Question", "name": "What's on the openGym roadmap?", "acceptedAnswer": {"@type": "Answer", "text": "A small, themed release roughly every two weeks: a session queue, programmes and phases, AMRAP/%1RM/5-3-1 progression, cardio intervals, then database storage (v1.4.0), better search, OIDC login, a trainer role and an App Store build. The full plan is in ROADMAP.md on GitHub."}}, {"@type": "Question", "name": "Was openGym written with AI?", "acceptedAnswer": {"@type": "Answer", "text": "openGym is developed with Claude Code, Anthropic's coding agent; a large share of the code, tests and docs is drafted that way, and every change is reviewed, tested and released by the maintainer. The app itself calls no AI service unless an admin switches on the optional AI coach."}}, {"@type": "Question", "name": "Where does the exercise database come from?", "acceptedAnswer": {"@type": "Answer", "text": "The exercise text lives in openGym's own catalogue in the repository, open to fixes and translations by pull request; the oldest entries came from ExerciseDB under MIT. The pictures and animations are licensed from Gym visual for use in openGym only and ship with it at 180 px. Reusing them anywhere else needs your own licence from gymvisual.com."}}, {"@type": "Question", "name": "What does the AGPL license mean for me?", "acceptedAnswer": {"@type": "Answer", "text": "You can self-host, use, modify and share openGym freely. Only if you run a modified version as a network service must you offer that version's source under the same license. Using or self-hosting it unmodified obliges you to nothing."}}]}</script></head><body class="topnav dock">@@ -476,8 +476,8 @@ cp .env.example .envdocker compose pull # prebuilt images (amd64 + arm64) — skip to build from sourcedocker compose up -d</code></pre><p>Open <code>http://localhost:8080</code>, tap <b>Create profile</b>, and you're in. The- first launch downloads the exercise media (~140 MB) once into <code>media/img</code>- and <code>media/gif</code>. Check it's healthy:</p>+ exercise pictures and animations are part of the web image, so there's nothing else to+ download. Check it's healthy:</p><pre><code>docker compose pscurl http://localhost:8080/api/health # {"ok":true,...}</code></pre><p>Logs: <code>docker compose logs -f</code> · stop: <code>docker compose down</code> ·@@ -882,12 +882,12 @@ Leg Day,Leg Press,2026-08-21,200,1</code></pre>and each release is tested on a staging instance and on real phones first. The app itselfneeds no AI service — the <a href="#coach">AI coach</a> and the <a href="#mcp">MCP server</a>are opt-in. <a href="https://github.com/DuarteSantos8/openGym#how-opengym-is-built" rel="noopener">More on this in the README</a>.</p>- <p>The exercise database comes from- <a href="https://github.com/hasaneyldrm/exercises-dataset" rel="noopener">hasaneyldrm/exercises-dataset</a>:- 1,324 exercises with animations and instructions. The metadata and instruction text are- MIT; the images and animations are third-party media that openGym never redistributes —- your instance downloads them from upstream on first run (see the- <a href="#faq">FAQ</a> for the licensing details).</p>+ <p>The exercise catalogue lives in the repository as one JSON file per exercise+ (<a href="https://github.com/DuarteSantos8/openGym/blob/main/catalogue/README.md" rel="noopener">catalogue/</a>),+ with its translations next to it, and anyone can fix or translate an entry with a pull+ request. The pictures and animations are licensed from+ <a href="https://gymvisual.com/" rel="noopener">Gym visual</a> for openGym and ship with it at+ 180 px (see the <a href="#faq">FAQ</a> for the licensing details).</p><h2 id="build">Build it yourself</h2><p>Everything on this page is built from the public repo:</p>@@ -930,7 +930,7 @@ Leg Day,Leg Press,2026-08-21,200,1</code></pre><table class="cfg"><tr><td>No passkey prompt on my phone</td><td>You're on <code>http://</code> or a bare IP. Passkeys need HTTPS or localhost — set up a domain, or use guest mode / the mobile app.</td></tr><tr><td>"verification failed" on login</td><td><code>RP_ID</code>/<code>ORIGIN</code> don't match the address bar — see the checklist above, starting with what the server logged.</td></tr>- <tr><td>Media didn't download</td><td><code>docker compose logs media</code>, re-run <code>docker compose up -d</code>, or run <code>./scripts/fetch-media.sh</code>.</td></tr>+ <tr><td>Exercise pictures missing</td><td>You're on an image older than v1.4.0 or a custom build: <code>docker compose pull && docker compose up -d</code>. A source build needs <code>catalogue/media/</code> checked out.</td></tr><tr><td>Port 8080 already used</td><td><code>WEB_PORT=9090</code> in <code>.env</code> (and update <code>ORIGIN</code> for local testing).</td></tr><tr><td>No "Reminders" page in Settings</td><td>Needs a signed-in profile and HTTPS (or localhost) — guest mode and plain HTTP over LAN can't subscribe.</td></tr><tr><td>Day reminder fires at the wrong time</td><td>Toggle it off and on so it re-detects your browser's timezone (also happens on every app load).</td></tr>@@ -995,19 +995,18 @@ Leg Day,Leg Press,2026-08-21,200,1</code></pre>reviewed, tested and released by the maintainer. The app itself calls no AI service unlessyou switch the coach on. See <a href="#arch">How it's built</a>.</p><h3>Where does the exercise database come from?</h3>- <p>From <a href="https://github.com/hasaneyldrm/exercises-dataset" rel="noopener">hasaneyldrm/exercises-dataset</a>:- 1,324 exercises with animations and instructions, localized in 12 of openGym's 17 UI- languages — including openGym's separately curated Brazilian Portuguese translation.- That dataset licenses the two halves differently, and so does openGym: the exercise- metadata and instruction text are <b>MIT</b>, while the images and animations are- third-party media used under the dataset's terms rather than openGym's AGPL — their- ownership is currently disputed between- <a href="https://gymvisual.com/" rel="noopener">Gym visual</a> and ExerciseDB, and a- clarification has been requested.</p>- <p>openGym does not redistribute that media — your instance downloads it from the upstream- source on first run. If you want to reuse it yourself, commercially or otherwise, clear- it with the rights holder first. Full third-party notices, including the body-diagram- geometry, are in+ <p>The text is openGym's own: one JSON file per exercise in+ <a href="https://github.com/DuarteSantos8/openGym/blob/main/catalogue/README.md" rel="noopener">catalogue/</a>,+ translations next to it, and fixes welcome as pull requests. The 1,324 exercises openGym+ started with came from ExerciseDB by way of hasaneyldrm/exercises-dataset, and their+ original text stays under <b>MIT</b>; everything written since is AGPL like the rest of+ openGym.</p>+ <p>The pictures and animations are a different matter: they are © Aliaksandr+ Makatserchyk, <a href="https://gymvisual.com/" rel="noopener">Gym visual</a>, licensed for+ use in openGym only, at 180 px in the repository and on servers and larger only inside+ the app packages. They are not covered by the AGPL, and there's no media pack or CDN to+ pull them from. Reusing them anywhere else needs your own licence from gymvisual.com.+ Full third-party notices, including the body-diagram geometry, are in<a href="https://github.com/DuarteSantos8/openGym/blob/main/NOTICE.md" rel="noopener">NOTICE.md</a>.</p><h3>What does the AGPL mean for me?</h3><p>You can self-host, use, modify and share openGym freely. If you run a <i>modified</i>