# CLAUDE.md This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. ## What this is KuentaGYM is a self-hosted gym & body-weight tracker PWA. Two containers (`api` + `web`) plus a `./data` folder the user owns — no third-party account, no telemetry. Passkey (WebAuthn) login, installable as a home-screen app, optional Capacitor shells for standalone Android/iOS builds. License: AGPL-3.0-or-later. It is a rebranded fork of [openGym](https://gitlab.com/DuarteSantos8/opengym) by Duarte Santos: the same code under the same AGPL-3.0-or-later, with this fork's name on it (see NOTICE.md). The fork's own repository — issues, pull requests, Actions — is the Gitea instance at , and the live instance runs at . ## Project layout ``` frontend/ React 19 + Vite app (src/views, src/components, src/store, src/lib). Builds to static files. android/ + ios/ are the Capacitor shells for the standalone mobile app (docs/MOBILE.md). api/ backend — server.js (Node, no framework), deps: @simplewebauthn/server, web-push. web/ multi-stage Dockerfile (builds frontend → nginx) + nginx.conf.template (serves app, proxies /api). mcp/ optional MCP server — read-only stdio bridge exposing a user's workouts/1RM/muscle balance to LLM clients (Claude Desktop, Cursor…). Not part of the Docker build; only runs when an LLM client spawns it. media/ exercise img/gif, gitignored, fetched at runtime by the `media` compose service. website/ static marketing site (plain HTML/CSS/JS) — not deployed for this fork; built by hand when someone wants it (node scripts/build-api-docs.mjs fills in api.html). docs/ SELF_HOSTING.md, MOBILE.md, AI_COACH.md, HEALTH.md (Apple Health ingest), RADIO.md (live stations), PODCASTS.md (Spanish-language episodes). ``` ## Commands ```bash # Local stack (api + web + media, prebuilt or built from source) cp .env.example .env docker compose up -d --build # Frontend dev server (hot reload), proxies /api to :3000 cd frontend && npm install && npm run dev # Frontend tests (training logic: progression, 1RM, session read-back) cd frontend && npm test # vitest run cd frontend && npm run test:watch npx vitest run src/lib/progression.test.js # single file npx vitest run -t "some test name" # single test by name # MCP server tests cd mcp && npm test # Production build cd frontend && npm run build cd frontend && npm run build:mobile # + cap sync, points media at the CDN dataset ``` There is no linter/formatter configured (no ESLint/Prettier config in the repo) and no TypeScript — match the existing style by hand. The CI gate is Gitea Actions on `git.dploy.lol`, configured in `.gitea/workflows/`: `test.yml` runs the `frontend/` suite on Node 22 — the same version as `web/Dockerfile` / `api/Dockerfile` (`node:22-alpine`) — and `docker-publish.yml` builds and pushes both images to the Gitea registry on `main` and on a published release. The `mcp/` and `api/` suites are not run by CI, so run them yourself (`cd mcp && npm test`, `cd api && npm test`). No job packages the Android APK and none deploys the website. `.gitlab-ci.yml`, `.gitlab/` and `.github/workflows/` are dormant copies of upstream's pipeline — no host runs them, they are not this fork's gate, and a change that only they would catch is a change nothing checks here. ## Architecture ### Frontend (`frontend/src`) - **`store/useStore.js`** — single Zustand store holding the entire client-side app state (`S`), persisted to `localStorage` (`gym_state_v1`) and debounce-pushed to the server when signed in (`pushState`, see `lib/api.js`). On the Capacitor mobile build it's also mirrored to a file via `lib/mobile.js` (`nativeSave`), since WebView storage can be evicted. `store/useUI.js` holds ephemeral UI state (modals, active sheet, etc.) separately from persisted data. - **`lib/`** — pure, framework-free helpers, each paired with a same-directory `*.test.js`. This is where the domain logic lives, most importantly: - `progression.js` — the progression-rule engine (linear, Greyskull LP, double progression, time-based). Rules implement a shared policy interface; adding a new one plugs in here. - `onerm.js` — estimated 1RM from logged sets. - `finish-workout.js` — reduces a completed session back into state (weights advance, PRs, etc). - `recovery.js` / `recovery-view.js` — fatigue/muscle-recovery model. - `workout-model.js`, `supersetFlow.js` — in-session workout state machine, incl. supersets. - `exercises.js` / `exercises-data.js` — the exercise library (1,324 built-ins + user-defined). - `vitals-view.js` — the Apple Health metric catalogue and card model (labels, units, which aggregate a card shows, the hour rows and day history behind a card, workout rows). The server stores numbers; this decides how they read. - `music.js` — reading and validating the Apple Music share links a profile keeps. Apple has no API for somebody else's public playlists, so a playlist here is a link, not an integration. - `player.js` — the single `