- TypeScript 81.8%
- JavaScript 15%
- HTML 2.2%
- Batchfile 0.4%
- Shell 0.3%
- Other 0.2%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
|
||
| .claude | ||
| .github/workflows | ||
| .impeccable | ||
| docs | ||
| e2e | ||
| evals | ||
| fixtures | ||
| prisma | ||
| prompts | ||
| public | ||
| scripts | ||
| src | ||
| .dockerignore | ||
| .env.example | ||
| .gitattributes | ||
| .gitignore | ||
| .prettierignore | ||
| .prettierrc.json | ||
| .vercelignore | ||
| bun.lock | ||
| CLAUDE.md | ||
| compose.yaml | ||
| DESIGN.md | ||
| Dockerfile | ||
| eslint.config.js | ||
| package.json | ||
| playwright.config.ts | ||
| prisma.config.ts | ||
| PRODUCT.md | ||
| README.md | ||
| tsconfig.json | ||
| vite.config.ts | ||
Trainer
Personal cycling-training app with strength work alongside the bike. An AI coach builds a periodised plan, every ride gets a TSS, and the plan re-plans itself after each session. Single user, sign-up closed.
Spec: docs/requirements.md. Working rules: CLAUDE.md. Session state: docs/PROGRESS.md.
Local setup
Needs Bun 1.4.x and Docker: the local database is Postgres 17 in a container (compose.yaml).
bun install # also runs `prisma generate`
cp .env.example .env # then set BETTER_AUTH_SECRET (openssl rand -base64 32)
bun run db:dev # start the local Postgres (restarts with Docker; data in a volume)
bun run db:migrate # apply migrations, regenerate the client
bun run db:seed # 45-exercise strength library
bun run user:create # the one owner account (name, email, password)
bun dev # http://localhost:3000
Sign in with your password, then register a passkey under Settings.
Everyday commands
| Command | What it does |
|---|---|
bun dev |
Vite dev server on port 3000 |
bun test |
Unit tests; DB-backed tests skip without DATABASE_URL |
bun run typecheck / lint / format |
Bun check, ESLint, Bun fmt |
bun run format:check / audit |
Bun format check, dependency advisories (both run in CI) |
bun run test:e2e |
Playwright flows on a production build (needs bun run db:dev) |
bun run build then bun run start |
Production build, served locally with Bun |
bun run db:migrate |
New migration from schema changes, then regenerate the client |
bun run db:reset |
Wipe the local database, re-migrate and re-seed |
bun run db:studio |
Prisma Studio |
Environment variables
| Variable | Local (.env) |
Vercel Preview | Vercel Production |
|---|---|---|---|
DATABASE_URL |
localhost:5432 (.env.example) |
Preview database (Prisma Console, direct postgres:// URL) |
Its own database, not shared with Preview |
BETTER_AUTH_SECRET |
random, 32+ bytes | random, set as Sensitive | random, different from Preview |
BETTER_AUTH_URL |
http://localhost:3000 |
not set: derived from VERCEL_BRANCH_URL / VERCEL_URL |
the production URL |
ANTHROPIC_API_KEY, AI_* |
from session 11 | from session 11 | from session 11 |
Keep DATABASE_URL out of Vercel's Development environment. vercel env pull writes it to .env.local, which Bun loads ahead of .env, so local work would quietly hit the cloud database.
Passkeys are tied to one hostname. On previews they work on the URL the app derives (the branch URL when there is one, else the deployment URL). Password sign-in works on any of the deployment's URLs.
Deploy
The code is on a private GitHub repo (chris-kreidl/trainer). .github/workflows/ci.yml runs typecheck, lint, format check, the dependency audit and bun test (DB tests against Postgres 17) on every pull request and on main.
Production deploys from Git. The Vercel project is connected to the repo with main as its production branch, so merging a pull request deploys it to production (https://trainer.kreidl.org). vercel.json git.deploymentEnabled builds main only: session branches and PRs get no automatic preview, since every preview build would run its migrations against the one shared preview database. Roll back with vercel rollback or Instant Rollback in the dashboard; a rollback doesn't undo migrations, which is one reason they stay additive.
For a preview, deploy from the CLI:
vercel deploy --target preview --yes
Always pass --target. Vercel's docs say a bare vercel deploy makes a preview, but in session 05, before the project was connected to Git, a bare deploy here made a production deployment.
A Vercel build runs bun run build:vercel:
prisma generate, because Bun can skippostinstallon a cached install.prisma migrate deployagainst that environment's ownDATABASE_URL(Preview and Production have separate databases).vite build, where Nitro's Vercel preset writes.vercel/output.scripts/check-vercel-runtime.ts, which fails the build unless the function runtime isbun1.4.x.
To create the owner on a cloud database, run this from your own terminal so the URL and password stay local:
DATABASE_URL='<direct postgres:// URL>' bun run db:seed
DATABASE_URL='<direct postgres:// URL>' bun run user:create
Previews sit behind Vercel's Deployment Protection. For scripted requests, use vercel curl <path> --deployment <url>.
Development bot
Label an issue ready and roboziggy, the owner's GitHub bot, picks it up: it asks questions on the issue or opens a pull request. The bot:* labels show where it is; see CLAUDE.md for what they mean.
Why the server runs on Bun
The requirements started on Node 22 with a Bun spike (session 05, branch spike/bun-vercel). Measured on the same preview from iad1:
| Node 22 | Bun 1.4.1 | |
|---|---|---|
Cold /login, first request on a fresh deployment |
0.98 s, 1.02 s | 0.90 s, 1.30 s |
Warm /login, median of 10 |
0.32 s | 0.27 s |
| Warm server function, median of 10 | 0.25 s | 0.26 s |
A static file took 0.20–0.25 s, so most of each request is network. Auth, cookies, passkeys, the Prisma pg adapter and password hashing all worked on Bun. With no speed difference either way, the owner chose Bun: this is a personal app, and running it on Bun end to end is the point.
The catch is configuration. "bunVersion": "1.4.x" alone gives Bun 1.3.14, because Nitro writes runtime: "bun1.x" into the function config. engines.node in package.json overrides bunVersion entirely. So vite.config.ts pins Nitro's Vercel runtime to bun1.4.x, package.json has no engines, and the build check above catches any regression. To go back to Node, set the Nitro runtime to nodejs22.x, remove bunVersion, and drop the check.