feat: auto create pairs via Claude Haiku AI

Adds " Auto Pairs erstellen" button to the PairsPanel. On click,
sends the image and all object coordinates to Claude Haiku, which
returns 30 structured pairs (10× text, 10× yes_no, 10× question,
each split easy/medium difficulty) as JSON. Pairs are then created
and linked via the API with a live progress indicator.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-28 17:57:54 +02:00
parent 51588f291c
commit 8d514170c7
2 changed files with 198 additions and 2 deletions

32
CLAUDE.md Normal file
View File

@@ -0,0 +1,32 @@
# snakkimo-CMT — Development Rules
## Stack
- React + Vite + Tailwind v4
- API: snakkimo-API (Express/Node.js, PostgreSQL) at the URL in `src/lib/api.js`
- Deployed at cmt.snakkimo.com via Coolify (UUID: `wa3esdrwh7ib5i7vfhwrknb4`)
## Key Rules
### Pairs müssen immer mit object_pairs verknüpft sein
Jedes neu erstellte Pair **muss** direkt nach dem `POST /pairs` auch in `object_pairs` eingetragen werden:
```js
const pair = await apiPost('/pairs', { ... });
await apiLink(`/objects/${objectId}/pairs/${pair.id}`);
```
`object_pairs` ist die definitive Verknüpfung zwischen einem Pair und dem Bild/Objekt das angezeigt werden soll. Ohne diesen Eintrag ist das Pair für die App unsichtbar.
### Placeholder-Format
Sätze in questions/statements speichern Wörter und Objekte als `{{uuid}}`:
- `{{wordId}}` — Verweis auf ein Wort aus der `words` Tabelle
- `{{objectId}}` — Verweis auf ein Objekt aus der `objects` Tabelle (wird mit `withPlaceholders()` gesetzt wenn der User ein Objekt zuweist)
### answer_type Werte
Pairs haben einen einzigen `answer_type` TEXT:
- `yes_no` — Frage + Ja/Nein Antwort
- `text` — nur positives Statement
- `question` — Frage + Positiv + Negativ
- `word` — Frage + positive/negative Wörter (über `statement_positive_words` / `statement_negative_words`)
## Deployment
Push auf `main` → Coolify baut automatisch.
Manueller Deploy via MCP: `mcp__coolify__deployments` mit `operation: deploy`, `query: {"uuid":"wa3esdrwh7ib5i7vfhwrknb4"}`.