# Haushalt

Basis-Software mit 3 geplanten Apps: Task Manager, Shopping List, Meal Planner.

Aktueller Stand: **TaskSchema module** implementiert (siehe `module.md`).

## Tech-Stack

| Schicht | Technologie |
|---------|------------|
| Backend | Symfony 7.4, PHP 8.3, Doctrine ORM, Symfony Messenger + Scheduler |
| Frontend Web | Vue 3 (Composition API), Vite, Pinia, Vue Router 4 |
| Frontend Mobile | Kotlin + Jetpack Compose (Material 3), Retrofit + kotlinx.serialization |
| Datenbank | MariaDB 10.11 (utf8mb4) |
| CORS | Nelmio CORS Bundle |
| Umgebung | DDEV |

## Struktur

```
backend/
  src/
    Collection/TaskCollection.php, TaskSchemaCollection.php
    Controller/Api/TaskController.php, TaskSchemaController.php
    DTO/TaskRequest.php, TaskSchemaRequest.php
    Entity/Task.php (+ schema FK), TaskSchema.php
    Enum/TaskStatus.php, TaskSchemaStatus.php
    Message/GenerateTasksMessage.php
    MessageHandler/GenerateTasksMessageHandler.php
    Repository/TaskRepository.php, TaskSchemaRepository.php
    Service/TaskManager.php (update/delete/toggle), TaskSchemaManager.php (create/update/delete), TaskGenerator.php (generateTasks/removeTasks/generateNewTasks)
    Schedule.php — Scheduler (cron 0 3 * * *)
  config/packages/messenger.yaml — scheduler_default transport
  migrations/
  public/app/version.json + haushalt.apk — App-Update
frontend/
  src/
    components/Icon.vue
    router/index.js — /, /tasks, /tasks/all, /tasks/:id, /schemas, /schemas/create, /schemas/:id
    services/api.js — taskApi + schemaApi
    stores/tasks.js, schemas.js
    views/ — Startpage, Task, TaskAll, TaskEdit, SchemaCreate, SchemaAll, SchemaEdit
app/app/src/main/java/de/haushalt/app/
  MainActivity.kt, MainScreen.kt, StartScreen.kt
  data/ — ApiClient, TaskApi, Task, TaskSchemaApi, TaskSchema, AppUpdateApi, AppUpdater
  ui/task/ — TaskScreen, TaskAllScreen, TaskEditScreen, ViewModels, DatePickerField, StatusDropdown, DateFormat
  ui/schema/ — SchemaCreateScreen, SchemaEditScreen, SchemaAllScreen, ViewModels, SchemaComponents
```

## Domänenmodell

**Task**: id, name, date?, status (active/done/inactive/past), schema?
- `past` ist derived (date < today), nicht user-selectable

**TaskSchema**: id, name, status (active/inactive), taskStatus, date?, repeat (json)?, start?, end?
- repeat=null → single (Task direkt, kein Schema persistiert)
- repeat={"daily":true} / {"weekly":[7 bools]} / {"monthly":[31 bools]}
- getRepeatType() → 'daily' | 'weekly' | 'monthly' | null

## REST-API

| Methode | Route | Zweck |
|---|---|---|
| GET | `/api/tasks?filter=current` | aktuelle Tasks |
| GET | `/api/tasks` | alle Tasks |
| GET | `/api/tasks/statuses` | selectable Statuswerte |
| GET | `/api/tasks/{id}` | einzelner Task |
| PUT | `/api/tasks/{id}` | Task aktualisieren |
| DELETE | `/api/tasks/{id}` | Task löschen |
| PATCH | `/api/tasks/{id}/toggle` | active↔done togglen |
| GET | `/api/task-schemas` | alle Schemas |
| GET | `/api/task-schemas/{id}` | einzelnes Schema |
| POST | `/api/task-schemas` | Schema erstellen (+ Tasks generieren) |
| PUT | `/api/task-schemas/{id}` | Schema aktualisieren (remove + regenerate Tasks) |
| DELETE | `/api/task-schemas/{id}` | Schema + nicht-past Tasks löschen |

## UI-Muster

- **`/tasks`**: Tasks nach Datum gruppiert in Cards (Legend-Titel). Icons: calendar, +, list, eye, refresh.
- **`/tasks/all`**: Flache Liste mit Edit/Delete. past=0.5 opacity, inactive=kursiv, done=durchgestrichen.
- **`/schemas`**: Schema-Liste mit Name + Repeat nebeneinander, Edit/Delete Icons.
- **Schema Create/Edit**: name, (status + taskStatus nebeneinander), repeat, weekday/monthday grid, (start + end nebeneinander).
- Kotlin: Lifecycle-Refresh via DisposableEffect ON_RESUME.
- App-Update: "Update prüfen" Button auf StartScreen, APK von Server laden.

## Dokumentation

- **`base.md`** — Vision: was gebaut wird
- **`module.md`** — Implementierungs-Schritte als Feature-Module
- **`CLAUDE.md`** (diese Datei) — Ist-Zustand des Codes

## Code-Konventionen

- **Sprache Code**: Englisch, **UI**: Deutsch, **Enum-Werte**: Englisch
- **Datum**: Backend ISO `Y-m-d`, UI `dd.MM.yyyy`
- **Frontend**: Vue 3 Composition API mit `<script setup>`

## Development

```bash
ddev start
ddev exec "cd backend && php bin/console cache:clear"
ddev exec "cd backend && php bin/console doctrine:migrations:migrate"
ddev exec "cd frontend && npm run dev -- --host 0.0.0.0"
ddev exec "cd frontend && npm run build"
cd app && JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64 ./gradlew :app:installDebug

# App-Update: APK nach backend/public/app/ kopieren, version.json versionCode hochzählen

# URLs
Frontend: https://haushalt.ddev.site:5173
API:      https://haushalt.ddev.site/api
```
