91 lines
4.0 KiB
Markdown
91 lines
4.0 KiB
Markdown
# CLAUDE.md
|
||
|
||
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
||
|
||
## Verhaltensregeln
|
||
|
||
- Kein erklärender Text bei Routineaufgaben (Commits, Pushes, Branch-Wechsel)
|
||
- Bei Fehlern: erst 2x selbst versuchen, dann fragen
|
||
- Branches selbstständig wechseln wie benötigt
|
||
|
||
## Sprache & Konventionen
|
||
|
||
- **Code-Bezeichner, Commit-Messages:** Englisch, Imperativ (`Add`, `Fix`, `Refactor`)
|
||
- **Dokumentation & Kommentare:** Deutsch
|
||
- **Commit-Format:** `<type>: <short description>` (max. 72 Zeichen)
|
||
Types: `feat` | `fix` | `refactor` | `test` | `docs` | `chore`
|
||
- Nach jedem Commit sofort pushen
|
||
- Keine `console.log`/`print` in Produktionscode, keine auskommentierten Code-Blöcke
|
||
|
||
## Projektkontext (Schnelleinstieg)
|
||
|
||
**Gartenmanager** – Docker-basierte Gartenverwaltung. Multi-User, Multi-Tenant, Rollensystem.
|
||
**Stack:** Vue 3 + PrimeVue → FastAPI (Python 3.11) → PostgreSQL 15
|
||
**Phase:** 1 abgeschlossen (Auth, Beete, Pflanzen, Bepflanzung). Phase 2 = Testing & CI/CD.
|
||
**Version:** `cat VERSION` | **Branch:** `git branch --show-current`
|
||
**Sessionstart:** [.claude/session-context.md](.claude/session-context.md) lesen.
|
||
**Modulreferenz:** [docs/project-structure.md](docs/project-structure.md) – vor Quellcode-Reads.
|
||
|
||
## Scripts (immer diese verwenden)
|
||
|
||
```bash
|
||
bash .claude/scripts/git-commit.sh "message" # stage all + commit + push
|
||
bash .claude/scripts/git-switch.sh <branch> # branch wechseln
|
||
bash .claude/scripts/git-switch.sh <branch> from <base> # neuer branch aus base
|
||
bash .claude/scripts/git-pr.sh create <head> <base> "titel" # PR erstellen
|
||
bash .claude/scripts/git-pr.sh merge <nr> squash # PR mergen
|
||
bash .claude/scripts/git-pr.sh list # offene PRs
|
||
bash .claude/scripts/bump.sh [patch|minor] "beschreibung" # version + commit + push
|
||
bash .claude/scripts/new-feature.sh [feature|fix] <name> # branch aus develop
|
||
```
|
||
|
||
## Architektur
|
||
|
||
```
|
||
backend/app/
|
||
core/config.py – Settings (DATABASE_URL, SECRET_KEY, ...)
|
||
core/security.py – JWT (Access 30min / Refresh 7d), Passwort-Hashing
|
||
core/deps.py – get_current_user, get_tenant_context, require_min_role()
|
||
db/session.py – async Engine + get_session()
|
||
models/ – SQLAlchemy ORM (UUID-PKs): User, Tenant, Plant, Bed, BedPlanting
|
||
schemas/ – Pydantic v2 Create/Update/Read je Entität
|
||
crud/ – CRUDBase + spezialisierte Klassen, nur DB-Zugriff
|
||
api/v1/ – Router: auth, plants, beds, plantings
|
||
seeds/initial_data.py – 28 Pflanzen + 15 Kompatibilitäten (idempotent)
|
||
|
||
frontend/src/
|
||
api/client.js – Axios + JWT-Interceptor + Auto-Refresh bei 401
|
||
stores/ – Pinia: auth, beds, plants
|
||
router/index.js – Auth-Guard, /login /beete /beete/:id /pflanzen
|
||
views/ – LoginView, BedsView, BedDetailView, PlantsView
|
||
components/ – AppLayout, BedForm, PlantingForm, PlantForm
|
||
```
|
||
|
||
**Tenant-Kontext:** Header `X-Tenant-ID` bei allen Nicht-Auth-Requests.
|
||
**Rollen:** `READ_ONLY` < `READ_WRITE` < `TENANT_ADMIN` < `is_superadmin`
|
||
|
||
## Pflichtregeln
|
||
|
||
1. **Nie direkt nach `main`** – nur PR, nur auf Anweisung
|
||
2. **Arbeit in `feature/`, `fix/` oder `chore/`** unter `develop`
|
||
3. **Nach jeder Änderung:** `bump.sh` ausführen (MINOR bei Features, PATCH bei Fixes)
|
||
4. **MAJOR-Version** niemals selbstständig erhöhen
|
||
5. **Vor Merge/PR:** CHANGELOG, README, `docs/project-structure.md` prüfen
|
||
6. **In `develop` mergen erst** wenn alle Tests grün sind
|
||
|
||
## Testing
|
||
|
||
- Integrationstests testen gegen echte DB (keine DB-Mocks)
|
||
- Backend: pytest in `backend/tests/` | Frontend: Vitest neben Quelldateien oder `__tests__/`
|
||
- Run: `docker compose exec backend pytest` / `cd frontend && npm run test`
|
||
|
||
## Build
|
||
|
||
```bash
|
||
docker compose -f docker-compose.dev.yml up # Dev (hot-reload)
|
||
docker compose up -d # Prod
|
||
docker compose exec backend alembic upgrade head
|
||
docker compose exec backend python -m app.seeds.initial_data
|
||
cd frontend && npm run dev
|
||
```
|