From 3dd10d3dc7e03074655daa7013ab74407909294a Mon Sep 17 00:00:00 2001 From: Lars Date: Thu, 26 Mar 2026 21:49:07 +0100 Subject: [PATCH] docs: Phase 0a completion - comprehensive documentation CLAUDE.md: - Version updated to v9e+ (Phase 0a Goal System Complete) - Added Phase 0a feature section with full details - Updated 'Letzte Updates' with Phase 0a completion - Links to new documentation files docs/issues/issue-50-phase-0a-goal-system.md (NEW): - Complete Phase 0a implementation documentation - Technical details: Migration 022, goals.py, GoalsPage - 4 commits documented (337667f to 5be52bc) - Lessons learned section - Basis for Phase 0b documented - Testing checklist + acceptance criteria docs/NEXT_STEPS_2026-03-26.md (NEW): - Comprehensive planning document - Option A: Issue #49 - Prompt Page Assignment (6-8h) - Option B: Phase 0b - Goal-Aware Placeholders (16-20h) - Option C: Issue #47 - Value Table Refinement (4-6h) - Recommendation: Szenario 1 (Quick Wins first) - Detailed technical breakdown for both options - Timeline estimates (4h/day vs 8h/day) - 120+ placeholder categorization for Phase 0b All documentation reflects current state post Phase 0a. Next decision: Choose between Issue #49 or Phase 0b. Co-Authored-By: Claude Opus 4.6 --- CLAUDE.md | 83 +++- docs/NEXT_STEPS_2026-03-26.md | 460 +++++++++++++++++++ docs/issues/issue-50-phase-0a-goal-system.md | 245 ++++++++++ 3 files changed, 780 insertions(+), 8 deletions(-) create mode 100644 docs/NEXT_STEPS_2026-03-26.md create mode 100644 docs/issues/issue-50-phase-0a-goal-system.md diff --git a/CLAUDE.md b/CLAUDE.md index 3b040c5..d7a7f52 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -76,16 +76,24 @@ frontend/src/ └── technical/ # MEMBERSHIP_SYSTEM.md ``` -## Aktuelle Version: v9e (Unified Prompts + Value Table Complete) 🚀 Ready for Production 26.03.2026 +## Aktuelle Version: v9e+ (Phase 0a Goal System Complete) 🎯 Ready for Phase 0b - 26.03.2026 -### Letzte Updates (26.03.2026) 🆕 -- ✅ **circ_summary erweitert:** Best-of-Each Strategie mit Altersangaben (heute, gestern, vor X Tagen) -- ✅ **Stage Outputs Fix:** Debug-Info enthält jetzt alle Stage-Outputs für Experten-Modus -- ✅ **Collapsible JSON:** Stage-Rohdaten als aufklappbare Details im Experten-Modus -- ✅ **Gitea #28 geschlossen:** AI-Prompts Flexibilisierung abgeschlossen +### Letzte Updates (26.03.2026 - Phase 0a) 🆕 +- ✅ **Phase 0a: Minimal Goal System:** Strategic + Tactical Layers implementiert +- ✅ **Migration 022:** goal_mode, goals, training_phases, fitness_tests tables +- ✅ **Backend Router:** goals.py mit vollständigem CRUD (490 Zeilen) +- ✅ **Frontend:** GoalsPage mit mobile-friendly Design (570 Zeilen) +- ✅ **Navigation:** Goals Preview (Dashboard) + Ziele Button (Analysis) +- ✅ **Basis geschaffen:** Für 120+ goal-aware Platzhalter (Phase 0b) +- ✅ **Dokumentation:** issue-50, NEXT_STEPS_2026-03-26.md, GOALS_SYSTEM_UNIFIED_ANALYSIS.md + +### Frühere Updates (26.03.2026 - Vormittag) +- ✅ **circ_summary erweitert:** Best-of-Each Strategie mit Altersangaben +- ✅ **Stage Outputs Fix:** Debug-Info für Experten-Modus +- ✅ **Collapsible JSON:** Stage-Rohdaten aufklappbar +- ✅ **Gitea #28 geschlossen:** AI-Prompts Flexibilisierung - ✅ **Gitea #44 geschlossen:** Analysen löschen behoben -- ✅ **Gitea #47 erstellt:** Wertetabelle Optimierung (Refinement) -- ✅ **Issue-Management:** Claude Code übernimmt Gitea Issue-Verwaltung +- ✅ **Gitea #47 erstellt:** Wertetabelle Optimierung ### Implementiert ✅ - Login (E-Mail + bcrypt), Auth-Middleware alle Endpoints, Rate Limiting @@ -382,6 +390,65 @@ frontend/src/ 📚 Details: `.claude/docs/functional/AI_PROMPTS.md` +### Phase 0a: Minimal Goal System ✅ (Completed 26.03.2026) +> **Gitea:** Issue #50 (zu erstellen) - COMPLETED +> **Dokumentation:** `docs/issues/issue-50-phase-0a-goal-system.md`, `docs/GOALS_SYSTEM_UNIFIED_ANALYSIS.md` + +**Zwei-Ebenen-Ziel-Architektur für goal-aware KI-Analysen:** + +- ✅ **Strategic Layer (Goal Modes):** + - `goal_mode` in profiles table (weight_loss, strength, endurance, recomposition, health) + - Bestimmt Score-Gewichtung für alle KI-Analysen + - UI: 5 Goal Mode Cards mit Icons und Beschreibungen + +- ✅ **Tactical Layer (Concrete Goals):** + - `goals` table mit vollständigem Progress-Tracking + - 8 Goal-Typen: weight, body_fat, lean_mass, vo2max, strength, flexibility, bp, rhr + - Auto-calculated progress percentage + - Linear projection für target_date + - Primary/Secondary goal concept + - UI: Goal CRUD mit Fortschrittsbalken, mobile-friendly + +- ✅ **Training Phases Framework:** + - `training_phases` table (Auto-Detection vorbereitet) + - 5 Phase-Typen: calorie_deficit, calorie_surplus, deload, maintenance, periodization + - Status-Flow: suggested → accepted → active → completed + - Confidence scoring für KI-basierte Erkennung + +- ✅ **Fitness Tests:** + - `fitness_tests` table für standardisierte Tests + - 8 Test-Typen: Cooper, Step Test, Pushups, Plank, VO2Max, Strength (Squat/Bench) + - Norm-Kategorisierung vorbereitet + +**Backend:** +- Migration 022: goal_mode, goals, training_phases, fitness_tests tables +- Router: `routers/goals.py` (490 Zeilen) - vollständiges CRUD +- API Endpoints: `/api/goals/*` (mode, list, create, update, delete, phases, tests) + +**Frontend:** +- GoalsPage: `frontend/src/pages/GoalsPage.jsx` (570 Zeilen) +- Mobile-friendly Design (full-width inputs, labels above) +- Navigation: Dashboard (Goals Preview Card) + Analysis (🎯 Ziele Button) +- api.js: 15+ neue Goal-Funktionen + +**Commits:** +- `337667f` - feat: Phase 0a - Minimal Goal System +- `906a3b7` - fix: Migration 022 tracking +- `75f0a5d` - refactor: mobile-friendly design +- `5be52bc` - feat: goals navigation + UX + +**Basis für Phase 0b:** +- Foundation für 120+ goal-aware Platzhalter +- Score-Berechnungen abhängig von goal_mode +- Intelligente Coaching-Funktionen +- Automatische Trainingsphasen-Erkennung + +**Nächste Schritte:** +- Option A: Issue #49 - Prompt Page Assignment (6-8h, Quick Win) +- Option B: Phase 0b - Goal-Aware Placeholders (16-20h, Strategic) + +📚 Details: `docs/NEXT_STEPS_2026-03-26.md` + ## Feature-Roadmap > 📋 **Detaillierte Roadmap:** `.claude/docs/ROADMAP.md` (Phasen 0-3, Timeline, Abhängigkeiten) diff --git a/docs/NEXT_STEPS_2026-03-26.md b/docs/NEXT_STEPS_2026-03-26.md new file mode 100644 index 0000000..3528257 --- /dev/null +++ b/docs/NEXT_STEPS_2026-03-26.md @@ -0,0 +1,460 @@ +# Nächste Schritte nach Phase 0a + +**Stand:** 26. März 2026, nach Completion von Phase 0a (Goal System) +**Aktueller Branch:** `develop` +**Deployed:** `dev.mitai.jinkendo.de` + +--- + +## Aktueller Stand ✅ + +### Abgeschlossen +- ✅ **Phase 0a:** Minimal Goal System (Strategic + Tactical) + - Migration 022, goals.py Router, GoalsPage UI + - Navigation von Dashboard + Analysis + - Mobile-friendly Design + - **Basis vorhanden für 120+ goal-aware Platzhalter** + +### Offene Gitea Issues +- 🔲 **#49:** Prompt-Zuordnung zu Verlaufsseiten (6-8h) +- 🔲 **#47:** Wertetabelle Optimierung (4-6h) +- 🔲 **#46:** KI Prompt-Ersteller (später) +- 🔲 **#45:** KI Prompt-Optimierer (später) +- 🔲 **#43, #42:** Enhanced Debug UI (später) + +--- + +## Option A: Issue #49 - Prompt Page Assignment ⚡ + +**Aufwand:** 6-8 Stunden +**Priorität:** Medium +**Typ:** UX Enhancement +**Labels:** feature, ux, enhancement + +### Beschreibung +KI-Prompts flexibel auf verschiedenen Verlaufsseiten verfügbar machen. Jeder Prompt kann auf mehreren Seiten gleichzeitig angeboten werden (Mehrfachauswahl). + +### Problem +**Aktuell:** +- Prompts nur über zentrale Analyse-Seite verfügbar +- Kein kontextbezogener Zugriff auf relevante Analysen +- User muss immer zur Analyse-Seite navigieren + +**Beispiel-Szenario:** +``` +User ist auf: Gewicht → Verlauf +Will: Gewichtstrend analysieren +Muss: Zur Analyse-Seite → Prompt auswählen → Zurück +``` + +**Wünschenswert:** +``` +User ist auf: Gewicht → Verlauf +Sieht: "🤖 KI-Analyse" Widget mit relevanten Prompts +Kann: Direkt "Gewichtstrend-Analyse" starten +``` + +### Technische Umsetzung + +**Backend (2h):** +```sql +-- Migration 023 +ALTER TABLE ai_prompts ADD COLUMN available_on JSONB DEFAULT '["analysis"]'; + +-- Beispiel: +{ + "slug": "weight_trend", + "available_on": ["analysis", "weight_history"] +} +``` + +**API:** +```python +# Neuer Endpoint +GET /api/prompts/for-page/{page_slug} + → Returns: List[Prompt] where available_on contains page_slug + +# CRUD erweitern +PUT /api/prompts/unified/{id} + → Body: {..., "available_on": ["analysis", "weight_history"]} +``` + +**Frontend (4h):** +```javascript +// Wiederverwendbare Komponente + + +// UnifiedPromptModal erweitern +const PAGE_OPTIONS = [ + { value: 'analysis', label: '📊 Analyse (Hauptseite)', default: true }, + { value: 'weight_history', label: '⚖️ Gewicht → Verlauf' }, + { value: 'nutrition_history', label: '🍎 Ernährung → Verlauf' }, + // ... 9 Optionen total +] + +// Multi-select checkboxes in Prompt-Editor +``` + +**Integration in Verlaufsseiten (2h):** +- WeightPage, NutritionPage, ActivityPage erweitern +- Widget unterhalb Charts einfügen +- Modal für Inline-Analyse + +### Vorteile +- ✅ Schneller Nutzen (UX-Verbesserung sofort sichtbar) +- ✅ Nutzt bestehendes Unified Prompt System (Issue #28) +- ✅ Relativ einfache Implementierung +- ✅ Bereitet vor für Phase 0b (neue Platzhalter dann sofort auf allen Seiten nutzbar) + +### Nachteile +- ⚠️ Verzögert strategische Tiefe (goal-aware Analysen) +- ⚠️ Erst sinnvoll wenn mehr Prompts existieren + +**Dokumentation:** Siehe `docs/issues/issue-51-prompt-page-assignment.md` + +--- + +## Option B: Phase 0b - Goal-Aware Placeholders 🎯 + +**Aufwand:** 16-20 Stunden +**Priorität:** High (strategisch kritisch) +**Typ:** Core Feature +**Labels:** feature, ai, goal-system + +### Beschreibung +Implementierung von 120+ neuen KI-Platzhaltern die `goal_mode` berücksichtigen. Verwandelt System von "Datensammler" zu "intelligentem Coach". + +### Problem +**Aktuell:** +- Ziele existieren, aber KI-Analysen ignorieren sie +- Gleiche Daten werden für alle goal_modes gleich interpretiert +- Keine goal-spezifischen Score-Berechnungen + +**Beispiel:** +```python +# Gleiche Messung: -5kg FM, -2kg LBM +# Aktuell: Generischer Score (z.B. 50/100) + +# Mit Phase 0b: +goal_mode = "weight_loss" → 78/100 (FM↓ gut!) +goal_mode = "strength" → 32/100 (LBM↓ Katastrophe!) +goal_mode = "recomposition" → 65/100 (beides relevant) +``` + +### Technische Umsetzung + +**1. Placeholder Functions (8-10h):** + +**Kategorie: KÖRPER (18 neue):** +```python +def weight_7d_rolling_median(profile_id, goal_mode): + """Rolling median statt avg für Stabilität""" + +def weight_28d_trend_slope(profile_id, goal_mode): + """Linear regression slope - kg/Woche""" + +def fm_28d_delta(profile_id, goal_mode): + """Fettmasse-Veränderung 28 Tage""" + +def lbm_28d_delta(profile_id, goal_mode): + """Magermasse-Veränderung 28 Tage""" + +def recomposition_score(profile_id, goal_mode): + """FM↓ + LBM↑ Balance-Score""" + # Nur relevant wenn goal_mode = "recomposition" + +def waist_to_hip_ratio(profile_id): + """WHR - Bauchfettverteilung""" + +def waist_to_height_ratio(profile_id): + """WHtR - Gesundheitsrisiko""" +``` + +**Kategorie: ERNÄHRUNG (15 neue):** +```python +def protein_g_per_kg(profile_id, goal_mode): + """Protein pro kg Körpergewicht""" + # Target abhängig von goal_mode: + # strength: 2.0-2.2g/kg + # weight_loss: 1.8-2.0g/kg + # endurance: 1.4-1.6g/kg + +def protein_g_per_kg_lbm(profile_id): + """Protein pro kg Magermasse (präziser)""" + +def nutrition_adherence_score(profile_id, goal_mode): + """Wie gut hält User seine Makro-Ziele ein?""" + # Ziele abhängig von goal_mode + +def energy_availability_status(profile_id): + """kcal - activity_kcal - BMR = verfügbare Energie""" + # RED-S Warnung wenn < 30 kcal/kg LBM +``` + +**Kategorie: AKTIVITÄT (25 neue):** +```python +def activity_quality_avg_28d(profile_id): + """Durchschnittliche Trainingsqualität""" + +def activity_strain_28d(profile_id): + """Kumulierte Belastung (Monotonie-Detektion)""" + +def activity_monotony_28d(profile_id): + """Variation im Training (Plateaus erkennen)""" + +def ability_balance_score(profile_id, goal_mode): + """Balance zwischen Fähigkeiten (Strength/Cardio/Mobility)""" + # Gewichtung abhängig von goal_mode +``` + +**Kategorie: RECOVERY (12 neue):** +```python +def recovery_score(profile_id): + """ + Kombiniert: RHR + HRV + Sleep Quality + Rest Days + Score: 0-100 + """ + +def sleep_regularity_index(profile_id): + """Wie regelmäßig sind Schlafzeiten? (0-100)""" + +def sleep_debt_hours(profile_id): + """Kumulierte Schlafdifferenz zu Ziel""" +``` + +**Kategorie: KORRELATIONEN (8 neue):** +```python +def corr_energy_weight_lag(profile_id): + """ + Korrelation Kaloriendefizit → Gewicht + Mit Lag-Analysis (verzögerte Effekte) + Confidence-Score basierend auf Datenmenge + """ + +def plateau_detected(profile_id): + """ + Boolean: Gewicht stagniert trotz Defizit? + Trigger für Interventionen + """ +``` + +**Kategorie: META (6 neue):** +```python +def goal_mode(profile_id): + """Aktueller goal_mode (für Prompts verfügbar)""" + +def data_quality_score(profile_id): + """Wie vollständig/konsistent sind Daten? (0-100)""" + +def profile_age_years(profile_id): + """Alter für altersabhängige Normen""" +``` + +**2. Score-Gewichtung (4-6h):** + +```python +# backend/score_calculator.py (NEU) + +SCORE_WEIGHTS = { + "weight_loss": { + "body_progress": 0.30, # FM↓ wichtig + "nutrition": 0.25, # Defizit wichtig + "training_quality": 0.15, # Moderat wichtig + "recovery": 0.15, # Moderat wichtig + "adherence": 0.15 # Konsistenz wichtig + }, + "strength": { + "body_progress": 0.35, # LBM↑ KRITISCH + "nutrition": 0.30, # Surplus + Protein + "training_quality": 0.25, # Progressive Overload + "recovery": 0.10 # Weniger wichtig + }, + "endurance": { + "training_quality": 0.40, # VO2Max, Pace wichtig + "recovery": 0.25, # Übertraining vermeiden + "body_progress": 0.15, # Gewicht sekundär + "nutrition": 0.20 # Energie-Verfügbarkeit + }, + # ... recomposition, health +} + +def calculate_overall_score(profile_id, goal_mode): + """Berechnet Gesamt-Score basierend auf goal_mode Gewichtung""" + weights = SCORE_WEIGHTS[goal_mode] + + scores = { + "body_progress": calculate_body_progress_score(profile_id, goal_mode), + "nutrition": calculate_nutrition_score(profile_id, goal_mode), + "training_quality": calculate_training_score(profile_id, goal_mode), + "recovery": calculate_recovery_score(profile_id), + "adherence": calculate_adherence_score(profile_id, goal_mode) + } + + overall = sum(scores[key] * weights[key] for key in weights) + return { + "overall": round(overall, 1), + "breakdown": scores, + "weights": weights + } +``` + +**3. Baseline-Berechnungen (2-3h):** + +```python +def calculate_baselines(profile_id): + """ + Berechnet persönliche Referenzwerte: + - 7d baseline (kurzfristig) + - 28d baseline (mittelfristig) + - 90d baseline (langfristig) + + Für: Gewicht, RHR, HRV, Kalorien, Protein, etc. + """ + +def detect_anomalies(profile_id, metric, value): + """ + Ist Wert außerhalb von ±2 SD vom Baseline? + → Warnung für User + """ +``` + +**4. Integration in Prompts (1-2h):** + +```python +# Beispiel Prompt-Template: +""" +Du bist ein KI-Coach für {{goal_mode}} Training. + +Aktueller Status: +- Gewichtstrend: {{weight_28d_trend_slope}} kg/Woche +- Fettmasse Δ28d: {{fm_28d_delta}} kg +- Magermasse Δ28d: {{lbm_28d_delta}} kg +- Rekompositions-Score: {{recomposition_score}}/100 + +Ernährung: +- Protein/kg: {{protein_g_per_kg}} g/kg (Ziel: {{protein_target_for_mode}}) +- Adherence: {{nutrition_adherence_score}}/100 + +Training: +- Qualität (28d): {{activity_quality_avg_28d}}/5.0 +- Monotonie: {{activity_monotony_28d}} (Warnung bei >2.0) + +Recovery: +- Recovery Score: {{recovery_score}}/100 +- Schlafschuld: {{sleep_debt_hours}}h + +Gesamt-Score ({{goal_mode}}-optimiert): {{overall_score}}/100 + +Analyse den Fortschritt aus Sicht eines {{goal_mode}} Ziels... +""" +``` + +### Vorteile +- ✅ Größter strategischer Impact (System wird intelligent) +- ✅ Ziele werden tatsächlich genutzt (nicht nur Display) +- ✅ Basis für alle zukünftigen Features +- ✅ Automatische Trainingsphasen-Erkennung möglich + +### Nachteile +- ⚠️ Hoher Aufwand (16-20h) +- ⚠️ Komplexe Logik (viel Testing nötig) +- ⚠️ Erfordert mehr Daten für sinnvolle Scores + +--- + +## Option C: Issue #47 - Value Table Refinement 🔬 + +**Aufwand:** 4-6 Stunden +**Priorität:** Low (Polishing) +**Typ:** Enhancement + +### Beschreibung +Wertetabelle übersichtlicher gestalten - Normal-Modus nur Einzelwerte, Experten-Modus mit Stage-Rohdaten. + +### Vorteile +- ✅ Bessere UX für Value Table +- ✅ Weniger Überforderung im Normal-Modus + +### Nachteile +- ⚠️ Kosmetisch, kein funktionaler Impact +- ⚠️ Besser warten bis Phase 0b (dann 120+ Platzhalter) + +**Empfehlung:** Später (nach Phase 0b) + +--- + +## Empfehlung 🎯 + +### Szenario 1: "Quick Wins first" +``` +1. Issue #49 - Prompt Assignment (6-8h) + → Bessere UX sofort + +2. Phase 0b - Goal-Aware Placeholders (16-20h) + → Neue Platzhalter profitieren von Page Assignment + → Volle Power mit beiden Features + +Total: 22-28h +``` + +### Szenario 2: "Strategic Depth first" +``` +1. Phase 0b - Goal-Aware Placeholders (16-20h) + → System wird intelligent + +2. Issue #49 - Prompt Assignment (6-8h) + → Intelligente Prompts dann auf allen Seiten + +Total: 22-28h +``` + +### Persönliche Empfehlung: **Szenario 1** + +**Begründung:** +- Issue #49 ist relativ einfach und bringt sofort UX-Nutzen +- Nutzt bestehendes Unified Prompt System optimal +- Phase 0b profitiert dann von besserer Navigation +- User kann neue Platzhalter (Phase 0b) direkt auf relevanten Seiten nutzen +- Psychologisch: Zwei Erfolgserlebnisse statt einem großen + +--- + +## Nächste Session: Action Items + +**Falls Issue #49 gewählt:** +1. [ ] Migration 023 erstellen (available_on JSONB) +2. [ ] Backend: `/api/prompts/for-page/{slug}` Endpoint +3. [ ] Backend: CRUD erweitern (available_on in PUT) +4. [ ] Frontend: PAGE_OPTIONS in UnifiedPromptModal +5. [ ] Frontend: PagePrompts Komponente (wiederverwendbar) +6. [ ] Integration: WeightPage, NutritionPage, ActivityPage +7. [ ] Testing: Multi-select, Modal-Inline-Analyse + +**Falls Phase 0b gewählt:** +1. [ ] Placeholder-Funktionen kategorieweise implementieren (KÖRPER → ERNÄHRUNG → AKTIVITÄT → RECOVERY → KORRELATIONEN → META) +2. [ ] Score-Gewichtung pro goal_mode definieren +3. [ ] Backend: score_calculator.py erstellen +4. [ ] Baseline-Berechnungen implementieren +5. [ ] Integration in bestehende Prompts +6. [ ] Testing mit verschiedenen goal_modes + +--- + +## Metriken & Timeline + +**Geschätzte Timeline (bei 4h/Tag Entwicklung):** + +| Szenario | Dauer | Fertig bis | +|----------|-------|------------| +| Issue #49 | 1.5-2 Tage | ~28.03.2026 | +| Phase 0b | 4-5 Tage | ~31.03.2026 | +| Szenario 1 (Quick Wins first) | 5.5-7 Tage | ~02.04.2026 | +| Szenario 2 (Strategic first) | 5.5-7 Tage | ~02.04.2026 | + +**Bei 8h/Tag Entwicklung:** Timeline halbiert sich (~01.04.2026) + +--- + +**Erstellt:** 26. März 2026 +**Status:** Aktiv - Wartet auf Entscheidung +**Nächste Aktualisierung:** Nach Completion von gewähltem Path diff --git a/docs/issues/issue-50-phase-0a-goal-system.md b/docs/issues/issue-50-phase-0a-goal-system.md new file mode 100644 index 0000000..11cf137 --- /dev/null +++ b/docs/issues/issue-50-phase-0a-goal-system.md @@ -0,0 +1,245 @@ +# Phase 0a: Minimal Goal System (Strategic + Tactical) + +**Status:** ✅ ABGESCHLOSSEN (26.03.2026) +**Labels:** feature, enhancement, goal-system +**Priority:** High (Foundation for Phase 0b) +**Aufwand:** 3-4h (geschätzt) / ~4h (tatsächlich) + +--- + +## Beschreibung + +Implementierung des minimalen Zielsystems als Basis für goal-aware KI-Analysen. Zwei-Ebenen-Architektur: +- **Strategic Layer:** Goal Modes (beeinflusst Score-Gewichtung) +- **Tactical Layer:** Konkrete Zielwerte mit Progress-Tracking + +--- + +## Implementiert ✅ + +### Strategic Layer (Goal Modes) +- `goal_mode` in `profiles` table +- 5 Modi: `weight_loss`, `strength`, `endurance`, `recomposition`, `health` +- Bestimmt Score-Gewichtung für alle KI-Analysen +- **UI:** 5 Goal Mode Cards mit Beschreibungen und Icons + +### Tactical Layer (Concrete Goals) +- `goals` table mit vollständigem Tracking: + - Target/Current/Start values + - Progress percentage (auto-calculated) + - Projection date & on-track status + - Primary/Secondary goal concept + - 8 Goal-Typen: weight, body_fat, lean_mass, vo2max, strength, flexibility, bp, rhr +- **UI:** + - Goal CRUD mit Fortschrittsbalken + - Mobile-friendly Design (full-width inputs, labels above fields) + - Inline editing vorbereitet + +### Training Phases Framework +- `training_phases` table (Auto-Detection vorbereitet für Phase 2) +- 5 Phase-Typen: calorie_deficit, calorie_surplus, deload, maintenance, periodization +- Status-Flow: suggested → accepted → active → completed → rejected +- Confidence scoring für KI-basierte Erkennung +- JSONB detection_params für Flexibilität + +### Fitness Tests +- `fitness_tests` table für standardisierte Tests +- 8 Test-Typen: cooper_12min, step_test, pushups_max, plank_max, flexibility_sit_reach, vo2max_est, strength_1rm_squat, strength_1rm_bench +- Norm-Kategorisierung vorbereitet (age/gender-spezifisch) +- Baseline-Tracking für Fortschrittsmessung + +--- + +## Technische Umsetzung + +### Backend + +**Migration 022:** `backend/migrations/022_goal_system.sql` +```sql +-- Strategic Layer +ALTER TABLE profiles ADD COLUMN goal_mode VARCHAR(50) DEFAULT 'health'; + +-- Tactical Layer +CREATE TABLE goals (...); +CREATE TABLE training_phases (...); +CREATE TABLE fitness_tests (...); +``` + +**Router:** `backend/routers/goals.py` (490 Zeilen) +- Vollständiges CRUD für alle 3 Ebenen +- Progress calculation (auto-update current values) +- Linear projection für target_date +- Helper functions für goal-type spezifische Current-Values + +**API Endpoints:** `/api/goals/*` +- `GET/PUT /mode` - Strategic goal mode +- `GET /list` - All goals with progress +- `POST /create` - Create goal +- `PUT /{id}` - Update goal +- `DELETE /{id}` - Delete goal +- `GET/POST /phases` - Training phases +- `PUT /phases/{id}/status` - Accept/reject auto-detected phases +- `GET/POST /tests` - Fitness tests + +### Frontend + +**GoalsPage:** `frontend/src/pages/GoalsPage.jsx` (570 Zeilen) +- **Goal Mode Selector:** 5 Karten mit Icons, Farben, Beschreibungen +- **Goal List:** Cards mit Progress-Balken, Projection-Display, Edit/Delete +- **Goal Form:** Mobile-optimiertes Modal + - Full-width inputs + - Labels above fields (not beside) + - Section headers with emoji (🎯 Zielwert) + - Unit display as styled badge + - Primary goal checkbox in highlighted section + - Text-align: left für Text-Felder, right für Zahlen +- **Empty State:** Placeholder mit CTA + +**Navigation Integration:** +- **Dashboard:** Goals Preview Card mit "Verwalten →" Link +- **Analysis Page:** 🎯 Ziele Button neben Titel (direkter Zugang) +- **Route:** `/goals` in App.jsx registriert + +**api.js:** 15+ neue API-Funktionen +```javascript +// Goal Modes +getGoalMode(), updateGoalMode(mode) + +// Goals CRUD +listGoals(), createGoal(data), updateGoal(id, data), deleteGoal(id) + +// Training Phases +listTrainingPhases(), createTrainingPhase(data), updatePhaseStatus(id, status) + +// Fitness Tests +listFitnessTests(), createFitnessTest(data) +``` + +--- + +## Commits + +| Commit | Beschreibung | +|--------|-------------| +| `337667f` | feat: Phase 0a - Minimal Goal System (Strategic + Tactical) | +| `906a3b7` | fix: Migration 022 - remove invalid schema_migrations tracking | +| `75f0a5d` | refactor: mobile-friendly goal form design | +| `5be52bc` | feat: goals navigation + UX improvements | + +**Branch:** `develop` +**Deployed to:** `dev.mitai.jinkendo.de` ✅ + +--- + +## Dokumentation + +- ✅ `docs/GOALS_SYSTEM_UNIFIED_ANALYSIS.md` (538 Zeilen) + - Analyse beider Fachkonzepte (Konzept v2 + GOALS_VITALS.md) + - Zwei-Ebenen-Architektur erklärt + - 120+ Placeholder-Kategorisierung für Phase 0b +- ✅ Migration 022 mit vollständigen COMMENT ON statements +- ✅ API-Dokumentation in Router-Docstrings +- ✅ Dieses Issue-Dokument + +--- + +## Basis für Phase 0b + +Phase 0a bietet die Foundation für: + +### Phase 0b: Goal-Aware Placeholders (16-20h) +- ✅ 120+ neue Platzhalter die `goal_mode` berücksichtigen +- ✅ Score-Berechnungen abhängig von Strategic Layer +- ✅ Baseline-Berechnungen (7d/28d/90d Trends) +- ✅ Lag-basierte Korrelationen +- ✅ Confidence Scoring + +**Beispiel Goal-Mode Impact:** +```python +# Gleiche Daten, unterschiedliche Interpretation: +Δ: -5kg FM, -2kg LBM + +goal_mode = "weight_loss" + → body_progress_score = 78/100 (FM↓ gut, LBM↓ tolerierbar) + +goal_mode = "strength" + → body_progress_score = 32/100 (LBM↓ ist KATASTROPHE!) + +goal_mode = "health" + → body_progress_score = 50/100 (neutral, ohne Bias) +``` + +--- + +## Testing + +✅ Migration erfolgreich auf dev.mitai.jinkendo.de +✅ Goal Mode wechselbar +✅ Goal CRUD funktioniert +✅ Progress calculation korrekt +✅ Mobile UI responsive +✅ Navigation von Dashboard + Analysis + +**Manuelle Tests durchgeführt:** +- [x] Goal Mode ändern +- [x] Ziel erstellen (alle 8 Typen) +- [x] Ziel bearbeiten +- [x] Ziel löschen +- [x] Primary Goal setzen +- [x] Progress-Balken korrekt +- [x] Mobile UI full-width +- [x] Text-Align korrekt + +--- + +## Akzeptanzkriterien + +- [x] Migration 022 erfolgreich +- [x] Goal Mode in profiles funktioniert +- [x] Goals CRUD vollständig +- [x] Progress-Tracking funktioniert +- [x] Primary Goal Konzept implementiert +- [x] Mobile-friendly UI +- [x] Navigation von 2+ Stellen +- [x] API-Dokumentation vollständig +- [x] Frontend form validation +- [x] Error handling korrekt + +--- + +## Nächste Schritte + +**Empfohlen:** + +1. **Option A: Issue #49 - Prompt Page Assignment (6-8h)** + - Prompts auf Verlaufsseiten zuordnen + - Quick Win für bessere UX + - Nutzt bestehendes Unified Prompt System + +2. **Option B: Phase 0b - Goal-Aware Placeholders (16-20h)** + - 120+ neue Platzhalter + - Score-Berechnungen mit goal_mode + - Größter strategischer Impact + +**Siehe:** `docs/NEXT_STEPS_2026-03-26.md` für detaillierte Planung + +--- + +## Lessons Learned + +### Was gut lief: +- ✅ Zwei-Ebenen-Architektur (Strategic + Tactical) macht Sinn +- ✅ Mobile-first Design von Anfang an +- ✅ Unified Analysis vor Implementierung (beide Fachkonzepte) +- ✅ Migration-System funktioniert einwandfrei + +### Was zu beachten ist: +- ⚠️ Schema_migrations verwendet `filename`, nicht `version` +- ⚠️ Unnötige DO-Blocks in Migrationen vermeiden +- ⚠️ Text-align: right als Default in form-input (für Textfelder überschreiben) + +--- + +**Erstellt:** 26. März 2026 +**Status:** ✅ COMPLETE - Ready for Phase 0b +**Related Issues:** #49 (Prompt Assignment), #47 (Value Table Refinement)