No description
  • TypeScript 99.8%
  • Dockerfile 0.1%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-10-19 10:37:30 +02:00
.scratch docs: document surface flow overhaul and graphical redesign (ADR 0001) 2026-10-19 10:37:15 +02:00
docs docs: document surface flow overhaul and graphical redesign (ADR 0001) 2026-10-19 10:37:15 +02:00
prototype feat(prototype): add the fatigue model and scheduler prototype 2026-09-17 08:56:05 +02:00
web feat(web): add faceted catalog atlas, settings workbench, and login styling 2026-10-19 10:37:30 +02:00
.gitignore docs: document surface flow overhaul and graphical redesign (ADR 0001) 2026-10-19 10:37:15 +02:00
README.md Change Fitbod Alt container host port to 4714 2026-10-08 05:42:34 +02:00

fitbod-alt

A personal, self-hosted alternative to Fitbod, built to sit beside SparkyFitness.

Fitbod decides what to train from a recovery model and a set of preferences. That model is proprietary and unpublished. This project replaces the planning half only: it reads workout history out of SparkyFitness, decides what to train from a per-muscle fatigue model, generates a session from a typed or dictated sentence, and writes the completed session back to SparkyFitness. Tracking, nutrition, and body metrics stay in SparkyFitness, which already does them.

The full reasoning is in docs/v1-spec.md, which is decision-complete, and in the wayfinder map at .scratch/fitbod-alt/map.md, which traces every decision to the ticket that produced it. docs/backlog.md holds everything deferred past version one.

What it does

  • Imports the free-exercise-db catalog (678 resistance-category exercises) into Postgres.
  • Models fatigue per muscle group as a sum of exponential decay terms over volume load, and shows freshness against a threshold.
  • Generates a session from a focus mode (split, fresh muscle groups, or explicit targets), a duration, avoidances, and an equipment filter, with a stated reason per exercise.
  • Parses a sentence into editable chips with the OpenAI Responses API. Every chip is editable, so a partial parse is still usable.
  • Prescribes sets, reps, load, rest, and warmups from logged history, using e1RM and double progression.
  • Logs sets, restarts the split on completion, and pushes the session to SparkyFitness.
  • Runs single-user behind one shared password.

Stack

Next.js 16 (App Router) in TypeScript, React 19, Tailwind 4, Drizzle ORM, Postgres 17, deployed as one container. Bun is the runtime and package manager.

Develop locally

This path runs the app from source with hot reload, so it suits editing the code. To run the built app instead, use Deploy, which starts both containers.

Prerequisites: Bun and Docker.

cd web
cp .env.example .env      # fill in the values; APP_PASSWORD is required
docker compose up -d postgres
bun install
bun run db:migrate
bun run seed
bun run dev               # http://localhost:3000

db:up starts every service in the compose file, including the app container on host port 4714. For local development with bun run dev, start the postgres service as above.

seed is idempotent and safe to re-run. It creates the taxonomy, the single profile row, the default split plan, and the exercise catalog.

Environment variables

web/.env is gitignored. web/.env.example lists all of them.

Variable Required Purpose
APP_PASSWORD Yes The shared password. Without it the app fails closed: every request goes to the login form and no password is accepted.
DATABASE_URL Yes Postgres connection for the app. In compose this is set by the compose file.
TEST_DATABASE_URL For tests A separate database for the test suite.
OPENAI_API_KEY For sentence parsing Server-side only. Without it the parse returns a clear message and the chips stay empty, so you fill them by hand.
SPARKY_URL For sync Base URL of the SparkyFitness instance.
SPARKY_API_KEY For sync API key for the same instance.

Tests

cd web
bun run test          # vitest, needs Postgres and TEST_DATABASE_URL
bun run typecheck     # tsc --noEmit
bun run build         # production build

The suite covers the pure models (fatigue, capability, scheduler, intent, auth, SparkyFitness client) and the repositories against the test database. Two live suites are skipped by default and make real network calls:

RUN_LIVE_OPENAI=1 bun run test   # real intent extraction, 7 cases
RUN_LIVE_SPARKY=1 bun run test   # creates and deletes its own data

Deploy

cd web
docker compose up -d --build

The image is built in two stages (oven/bun:1 to install and build, oven/bun:1-slim to run). The container applies migrations and then serves on container port 3000, published at http://localhost:4714. SPARKY_URL must be reachable from the container; use the public address or attach the service to the SparkyFitness network.

Repository layout

  • web/ — the application. src/lib/ holds the pure models, src/db/ the repositories and schema, src/app/ the screens and the one route handler.
  • prototype/ — a disposable prototype that answered whether the freshness numbers and the session surface feel right. It is not the app and shares no code with it.
  • docs/ — the version one spec and the backlog.
  • .scratch/ — the wayfinder map, its issue tickets, and the research notes. The map is frozen once its destination is reached.

Status

Version one is built. All eight build tickets are complete, including SparkyFitness sync, authentication, and container deployment. Deferred features are tracked in docs/backlog.md.