dudi/CLAUDE.md
Simon Kühn fd473f00af Initial commit: Dudi habit tracker
Symfony 8 SPA with Doctrine ORM, Symfony Security, vanilla JS frontend.
Migrated from plain PHP (delight-im/auth + raw SQL) to full Symfony stack.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-29 15:40:57 +02:00

2.6 KiB
Raw Blame History

Dudi Claude Context

What this is

Habit & goal tracking PWA. Users set goals (e.g. "50 push-ups/day for 30 days"), log sets daily, and see progress. Invite-only registration. German UI.

Stack

  • Symfony 8 + Doctrine ORM (src/)
  • Vanilla JS SPA — no build step, no npm (public/app.js)
  • HTML <template> elements in templates/app.html.twig (rendered once, JS clones them)
  • MariaDB, session auth + remember-me 24h

Local dev

  • URL: http://dudi.local/
  • DB: zieltracker / zieltracker (see .env.local, gitignored)
  • php bin/console cache:clear after config changes
  • public/app.js is the authoritative JS file — also copy to public/ after edits to app.js at root (root copy is legacy, will be removed)

Server

  • ssh -p 30183 root@miniweb.kuehn.home
  • App: /var/www/tracker/, DB: dd/dd
  • Deploy: bash deploy.sh (rsync + remote composer install + cache:clear)
  • Remember-me table must exist: rememberme_token (already created)

Key files

  • src/Controller/AuthController.php — login, register, password reset, name change
  • src/Controller/GoalController.php — goals CRUD
  • src/Controller/InviteController.php — invite creation + listing
  • src/Security/JsonLoginAuthenticator.php — JSON POST /api/login
  • config/packages/security.yaml — firewall, remember-me, access control
  • templates/app.html.twig — SPA shell + all tpl-* templates
  • public/app.js — all frontend logic

Data model

  • goals.sets is a JSON object: {"2026-04-01": [20, 30], "2026-04-02": [50]} — keys are dates, values are arrays of logged amounts per session
  • Users table schema is compatible with the old delight-im/auth library (bcrypt hashes work unchanged)
  • Password resets use users_resets table directly (raw SQL) — Symfony doesn't manage this table

Conventions

  • API responses: { ok: true, ... } on success, { error: "message" } on failure
  • All API routes prefixed /api/, catch-all route in AppController renders SPA
  • No Twig cache (cache: false in index.php, now handled by Symfony kernel in prod)
  • JS uses tpl(id) helper to clone <template> elements, fills via querySelector with semantic class names
  • No comments in JS unless non-obvious; no trailing summaries in responses

Pending cleanup

  • api.php, index.php, include/, app.js, style.css at project root are legacy pre-Symfony files — safe to delete once miniweb is migrated to Symfony
  • Legacy DB tables that can be dropped: users_throttling, users_confirmations, schema_migrations
  • miniweb still runs old non-Symfony code — Symfony deploy + Apache config update pending