- TypeScript 94.9%
- JavaScript 2.2%
- CSS 2%
- Dockerfile 0.9%
The unlayered .glass rule set position: relative and beat Tailwind's layered utilities, so the portalled menu (and toasts, the chart tooltip) lost their fixed/absolute positioning. Moving the glass styles into @layer components lets utilities win again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|---|---|---|
| drizzle | ||
| public | ||
| scripts | ||
| src | ||
| .dockerignore | ||
| .env.example | ||
| .gitignore | ||
| docker-compose.yml | ||
| Dockerfile | ||
| drizzle.config.ts | ||
| next.config.ts | ||
| package-lock.json | ||
| package.json | ||
| postcss.config.mjs | ||
| README.md | ||
| tsconfig.json | ||
motzworkout
A small, self-hosted workout planner and tracker: build an exercise library, plan workouts on any day
(Push-ups 3×10, Bench press 5×5 @ 60 kg, Plank 3×45s), copy them to other days, then check off sets
as you train. Username/password login, everything in one SQLite file.
Next.js 16 (App Router) · TypeScript · Tailwind v4 · SQLite (better-sqlite3 + Drizzle) · argon2id. Same stack and look as motzlist.
Features
- Workouts (
/): an agenda with today first, upcoming days below, past workouts above. Scroll up to load older ones. Cards expand to edit; a strip shows this week's status at a glance. - Calendar (
/calendar): month and week views. Click a day to plan, edit or track it in a side panel. On desktop, drag a workout to another day to move it (hold Alt/Ctrl to copy). Keys: ← → T M W. - Plan mode: add exercises by typing.
Squats 3x12 @ 40,Plank 3x45sandRun 5kmparse into sets, and unknown names can be created on the spot. Use "same for every set" (3×10) or customize each set (pyramids such as12/10/8). - Track mode: check off sets and adjust what you actually did (reps/time/distance and weight). Shows "last time" for each exercise. A rest timer starts when you check off a set (per-exercise rest, beeps and vibrates at the end). The screen stays on while you track today's workout.
- Copy / move: copy a workout's plan to any number of days, with "next week" / "weekly ×4 / ×8" shortcuts. Copies keep the plan and reset the tracking.
- Templates: save any workout as a template, then plan it on one or many days at once.
- Exercises (
/exercises): library with default sets/target/weight/rest, history per exercise and a progress chart. Exercises used in workouts are archived instead of deleted, so history stays intact. - Stats (
/stats): weekly streak, this week's completion, last-30-days adherence, a 26-week training heatmap, sessions per week and personal bests. - CSV export of everything (
/api/export, linked on the Exercises page), dark mode, installable to the home screen (web manifest), bottom tab bar on phones.
Run with Docker
cp .env.example .env
# set SESSION_SECRET to a random string of 32+ chars, e.g.:
# openssl rand -base64 48
# and TZ to your time zone (decides what "today" is for stats), e.g. Europe/Berlin
docker compose up -d --build
docker compose exec app npm run create-user -- alice # prompts for the password
Open http://localhost:3001 and sign in. The port is published on 127.0.0.1 only; set
BIND_ADDRESS=0.0.0.0 (and ALLOW_INSECURE_COOKIES=true) in .env to try it from another device over plain
http.
Database migrations run automatically every time the container starts.
Environment
| Variable | Default | Notes |
|---|---|---|
SESSION_SECRET |
— (required) | 32+ chars. Session IDs are stored as HMACs keyed with it; changing it signs everyone out. |
PORT |
3001 |
Port the app listens on and is published on (3001 so it can run next to motzlist). |
BIND_ADDRESS |
127.0.0.1 |
Host address the port is published on. Loopback = only reachable via the reverse proxy. |
ALLOW_INSECURE_COOKIES |
false |
true drops the Secure cookie flag on plain-http requests. Only for local/LAN testing. |
SQLITE_JOURNAL_MODE |
WAL |
Use DELETE if the DB file lives on a network filesystem (NFS); run a single instance. |
TZ |
UTC |
Server time zone. The browser decides "today" for planning; the server uses this for stats. |
DATABASE_PATH |
/data/motzworkout.db |
Set in the image; the motzworkout-data volume is mounted at /data. |
Behind a reverse proxy
Terminate TLS at the proxy and forward to 127.0.0.1:$PORT. The proxy must set Host and
X-Forwarded-Proto. The app uses them for Secure cookies, redirects and its same-origin check.
It must also overwrite X-Forwarded-For with the client address, because login throttling is keyed on it.
Sessions last 90 days and roll forward when used (re-issued at most once a day). Logging out deletes the session server-side.
Users
No public signup. Manage users with the CLI inside the container:
docker compose exec app npm run create-user -- alice # new user (password prompt)
docker compose exec app npm run create-user -- alice --reset # new password, signs out all sessions
docker compose exec -e PASSWORD='…' app npm run create-user -- bob # non-interactive
Usernames are lowercase a-z 0-9 . _ -. Passwords need at least 8 characters and are hashed with argon2id.
Each user only ever sees their own exercises, workouts and templates.
Backup & restore
The backup uses SQLite's online backup API, so it's consistent while the app is running:
docker compose exec app npm run backup -- /data/motzworkout-backup.db
docker compose cp app:/data/motzworkout-backup.db ./motzworkout-backup.db
docker compose exec app rm /data/motzworkout-backup.db
Without an argument the backup is written to /data/backup-<timestamp>.db.
Restore (the volume is named <project>_motzworkout-data, here motzworkout_motzworkout-data):
docker compose stop app
docker run --rm -v motzworkout_motzworkout-data:/data -v "$PWD":/backup alpine sh -c \
'cp /backup/motzworkout-backup.db /data/motzworkout.db && rm -f /data/motzworkout.db-wal /data/motzworkout.db-shm && chown 1001:1001 /data/motzworkout.db'
docker compose start app
Note: docker compose down keeps the data volume. docker compose down -v deletes it.
Development
npm install
SESSION_SECRET=dev-secret-dev-secret-dev-secret-123 npm run migrate
SESSION_SECRET=dev-secret-dev-secret-dev-secret-123 npm run dev
npm run create-user -- alice
Locally the DB lives in ./data/motzworkout.db. After changing src/db/schema.ts, run
npm run db:generate and commit the new file in drizzle/.
How it fits together
A workout is saved as one document (workout → entries → sets) with PUT /api/workouts/:id. The client
keeps a small store (src/components/store.tsx) shared by all pages. Edits apply immediately and are
saved in the background, debounced per workout and in order. Unsaved changes are flushed when the tab is
hidden, and a "Not saved · Retry" button appears in the header if a save fails.
src/app/ pages (/, /calendar, /exercises, /stats, /login), JSON API (/api/...), /healthz
src/proxy.ts auth gate + rolling session refresh
src/db/ Drizzle schema and connection
src/lib/ sessions, auth, workouts/exercises/templates/stats queries, dates, set formatting
src/components/ views, the workout card (plan/track), sheets, store, rest timer
scripts/ migrate / create-user / backup (plain Node, run inside the image)
drizzle/ generated SQL migrations