Files
CRAPP/docs/DATABASE.md
T
davideandClaude Opus 5 e1e8dd5415 Reorganize documentation and unify the AI assistant rules
Documentation:
- Add docs/README.md, the documentation index that AGENTS.md pointed to as the
  first file to read but which did not exist.
- One home per piece of information: the feature list stays in ROADMAP.md,
  CHANGELOG.md records only when something shipped, TODO.md only ongoing work.
  Reconcile the entries that had drifted (CSI was both done and pending;
  pagelle, badge social and serie were missing from the roadmap).
- Rewrite DATABASE.md as tables: add giocatori_squadra (already created by a
  migration) and profili_giocatore (planned in DD-016), fix the wrong heading
  levels, drop the duplicated roadmap.
- DESIGN_DECISIONS.md: move the index to the top and sort it, extract the
  template into _template-dd.md.
- ARCHITECTURE.md becomes the technical reference; CLAUDE.md no longer
  duplicates it.
- Add docs/EFFICIENZA_CLOUD.md with the rules previously kept in mem/,
  separating what the code enforces from the goals not yet implemented.
- Fix statements the code contradicted: mutations use setQueryData rather than
  invalidateQueries, and scout_sessioni and giocatori_squadra are not read by
  the code yet.
- Track the v1.0 modules with no spec in docs/modules/ from TODO.md.

AI assistants:
- AGENTS.md is the single source of the rules, now including the technical
  constraints only Claude Code knew about (generated files, Vite plugins, data
  access) and an end-of-work checklist that applies to every assistant.
- CLAUDE.md and .cursor/rules/crapp.mdc point to AGENTS.md instead of
  restating it.
- Remove the five .cursor/*.md files, which Cursor never loaded.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-30 16:26:14 +02:00

3.1 KiB

Database CrAPP

Struttura del database Supabase (PostgreSQL) e ruolo di ogni tabella. Lo schema autoritativo sono le migration in supabase/migrations/: una tabella nuova va documentata qui nella stessa modifica che la crea. Le funzionalità future stanno in ROADMAP.md, non in questo file.

Anagrafica e utenti

Tabella Scopo Note
giocatori_squadra Anagrafica operativa della squadra, con ID testuali (g1gN), dati gestiti dagli admin (nome, cognome, numero, ruolo) e collegamento all'account (auth_user_id). Introdotta dalla migration m1_giocatori_squadra, già popolata (17 giocatori) ma non ancora letta dal codice: la rosa arriva tuttora da src/lib/crapp-data.ts, che resta il fallback anche dopo il passaggio. Destinata a diventare la source of truth. Vedi DD-015 e DD-016.
giocatori Anagrafica giocatori con UUID. Presente ma non usata dal codice attuale: la convergenza è rinviata (DD-012, DD-014).
profili_giocatore Dati personali, metadati del documento d'identità, certificato medico e path dei file, in relazione 1:1 con giocatori_squadra. Prevista per la v1.1 (DD-016), non ancora creata.
user_roles Ruoli applicativi (es. amministratore, giocatore).

giocatori_squadra / giocatori sono usate da: Squadra, Profili, Presenze, Scout, Badge, Pagelle.

Eventi e presenze

Tabella Scopo Note
eventi_app Eventi gestionali utilizzati dall'app. Modello in uso dal codice attuale.
risposte_presenze Risposte dei giocatori agli eventi. Modello in uso dal codice attuale.
eventi Calendario generale: allenamenti, partite, eventi della squadra. Modello "nuovo" con autenticazione e vincoli, non ancora adottato (DD-014).
presenze Presenze agli eventi. Come sopra (DD-014).

Scout

Tabella Scopo Note
scout_sessioni Sessioni di Scout Live: una sessione corrisponde a una partita. Non ancora usata dal codice: oggi lo stato della sessione vive in localStorage (src/lib/scout-live.ts, scout-store.ts) e sul database finiscono solo le azioni in scout_live.
scout_live Eventi registrati durante lo Scout Live. Serve esclusivamente per statistiche di squadra, mai per classifiche individuali (DD-008).

Votazioni

Tabella Scopo Note
mvp_voti Voti MVP assegnati a fine partita.
pagelle_voti Voti anonimi assegnati ai giocatori. Usati per il voto medio.
badge_social_voti Voti social per i badge.

Turni e notifiche

Tabella Scopo Note
turni_palloni Gestione dei turni palloni.
push_subscriptions Dispositivi registrati per le notifiche Push.
promemoria_push Storico dei promemoria inviati.

Funzioni speciali

Tabella Scopo Note
cacche_partita Sondaggio prepartita. Usato per statistiche e badge segreti.

Badge

Non esiste una tabella dedicata: i badge vengono calcolati a runtime dall'applicazione a partire dai dati esistenti (DD-007).