fitness-web/AGENTS.md
Jacob Hinkle 5584022a23 Single-container AI coach with agent API endpoints and UI polish
- Merge opencode-serve into the web container via entrypoint script
- Add /api/agent/* JSON endpoints for workouts, sets, checkins
- Rewrite fitness-trainer.md to use API instead of markdown files
- Pass recent workouts and check-ins as chat context to the coach
- Show current training phase on dashboard
- Clarify check-ins as morning check-ins (calories/steps = yesterday)
- Add NixOS deployment section to README
- Make all check-in fields explicitly optional in UI
2026-06-29 10:50:01 -04:00

2.5 KiB

Fitness Web Agent Notes

Project Overview

Multi-user fitness tracking web app with AI coaching. Replaces the fitness-agent markdown-based training repo.

  • ~/git/fitness-agent — Training markdown logs, agent config, historical data, Juggernaut cycles
  • This repo (fitness-web) is the web app successor. When this is fully operational, the old repo can be archived.

Architecture

  • FastAPI — async Python web framework
  • Jinja2 + Pico.css — server-rendered templates with minimal CSS framework (CDN)
  • SQLite + SQLAlchemy 2.0 async — database with aiosqlite driver
  • opencode serve — AI coach service (Big Pickle model, free). Runs alongside uvicorn in the same container, managed by a shell entrypoint.

Key Files

  • app/main.py — App factory, route registration, lifespan
  • app/config.py — Environment-based configuration
  • app/auth.py — Password hashing, session management, get_current_user dependency
  • app/models/ — SQLAlchemy ORM models
  • app/routers/ — Route handlers (one per feature)
  • app/routers/agent_api.py — JSON API for the AI coach to create workouts/check-ins
  • scripts/schema.py — DB initialization
  • scripts/seed.py — Seed data (exercises, phases)
  • opencode/fitness-trainer.md — Agent config for AI coach (copied from fitness-agent)

Commands

uv sync                          # Install deps
uv run python scripts/schema.py  # Create DB tables
uv run python scripts/seed.py    # Seed initial data
uv run uvicorn app.main:app --reload  # Dev server on :8000

Key Decisions

  • Session-based auth with DB-backed tokens (simple, no OAuth dependencies)
  • SQLAlchemy async with aiosqlite (works well with FastAPI async handlers)
  • SSE streaming for chat responses
  • Pico.css from CDN (no build step)
  • Chat messages stored in DB per session for history
  • Docker Compose for deployment (opencode serve runs as background process in same container)

Next Steps / TODOs

  1. Seed exercises and phases (done via python scripts/seed.py)
  2. Add exercise progress chart (matplotlib or chart.js)
  3. Enable opencode serve integration (Dockerfile + entrypoint done, single-container approach)
  4. Add agent API for DB writes (endpoints + agent config done)
  5. Migrate existing markdown logs from fitness-agent repo into DB
  6. Migrate Juggernaut training xlsx data into DB
  7. Add calendar view for training history
  8. Update fitness-trainer.md agent config to work with DB-backed context instead of markdown files (done)