generated from gilles/template-webapp
3.1 KiB
3.1 KiB
Modèle de données
Décrit les entités clés et leurs relations.
Légende des zones
<A COMPLETER PAR AGENT>: à compléter par un agent spécialisé backend.
Entités principales
Item (objet d'inventaire)
- Champs :
id(PK),name(string, requis),description(text, optionnel),quantity(int, défaut 1),price(decimal, optionnel),purchase_date(date, optionnel),status(enum: in_stock/in_use/broken/sold, défaut in_stock),location_id(FK Location),category_id(FK Category),created_at,updated_at - Contraintes :
nameunique par location,quantity>= 0,price>= 0, index surname+statuspour recherche
Location (emplacement physique hiérarchique)
- Champs :
id(PK),name(string, requis),type(enum: room/furniture/drawer/box),parent_id(FK Location, self-reference, optionnel),path(string, chemin complet calculé),created_at,updated_at - Contraintes :
nameunique parparent_id, pas de cycle dans hiérarchie (validation applicative), index surpathpour recherche hiérarchique
Category (domaine/catégorie)
- Champs :
id(PK),name(string, requis, unique),slug(string, requis, unique),description(text, optionnel),color(string hex, optionnel),icon(string, optionnel),created_at,updated_at - Contraintes :
nameetsluguniques, slug kebab-case, catégories prédéfinies (bricolage, informatique, électronique, cuisine) + possibilité ajout
Document (fichier attaché)
- Champs :
id(PK),item_id(FK Item, requis),type(enum: photo/notice/invoice/other),filename(string, requis),filepath(string, chemin relatif dans uploads/),mime_type(string),size_bytes(int),uploaded_at - Contraintes :
filepathunique, index suritem_id, taille max 50MB par fichier, types MIME autorisés (images, PDF)
Relations
- Item N..1 Location : Un item est dans une location, une location contient plusieurs items (CASCADE DELETE optionnel)
- Item N..1 Category : Un item appartient à une catégorie, une catégorie contient plusieurs items (RESTRICT DELETE)
- Item 1..N Document : Un item a plusieurs documents, un document appartient à un item (CASCADE DELETE)
- Location N..1 Location (self) : Hiérarchie parent/enfant (garage → étagère → boîte),
parent_idNULL pour racine (RESTRICT DELETE pour éviter orphelins)
Indexation recherche (SQLite FTS5)
- fts_items : Table virtuelle FTS5 sur
Item.name+Item.description+Category.name+Location.pathpour recherche full-text performante - Synchronisation : Triggers SQLite pour maintenir FTS5 à jour lors des INSERT/UPDATE/DELETE sur Item