328 lines
11 KiB
Markdown
328 lines
11 KiB
Markdown
# Plan d'amélioration — Jardin App
|
||
|
||
> Généré le 2026-02-22 · Mis à jour le 2026-02-22
|
||
> Source : `amelioration.md` + analyse du code existant + brainstorming
|
||
> Statuts : `[ ]` à faire · `[→]` en cours · `[x]` terminé
|
||
|
||
---
|
||
|
||
## Brainstorming & Analyse
|
||
|
||
### Ce qui existe (MVP)
|
||
|
||
- Backend : CRUD jardins / variétés (plantes) / plantations / tâches / settings / upload basique
|
||
- Frontend : 9 vues (dashboard, jardins, grille, variétés, plantations, planning, tâches, lunaire, réglages)
|
||
- Infrastructure : Docker Compose, SQLite, Nginx, TZ=Europe/Paris
|
||
- Script `calendrier_lunaire/lunar_calendar.py` (skyfield + de421.bsp) prêt mais non intégré
|
||
|
||
### Décisions architecturales issues du brainstorming
|
||
|
||
| Sujet | Décision |
|
||
| --- | --- |
|
||
| Renommage variétés → plantes | Partout (modèle, routes, UI, seed, nav) |
|
||
| Photos | Upload → Pillow → WebP 1200px max, thumbnail 300px |
|
||
| Calendrier lunaire | Intégrer `lunar_calendar.py` dans l'API, cache JSON par année |
|
||
| Météo | Open-Meteo API (gratuit, sans clé, RGPD ok) |
|
||
| Outils | Nouvelle entité DB + seed 15 outils courants |
|
||
| Tâches récurrentes | Champ `frequence_jours` nullable + `date_prochaine` calculée |
|
||
| Capteurs MQTT | paho-mqtt, config par capteur (topic, type, unité) |
|
||
| Backup | Archive ZIP : jardin.db + uploads/ + export JSON |
|
||
| Détection plante | Pl@ntNet API (gratuit, open-source) ou mode offline désactivé |
|
||
| Migration BDD | Script Python `migrate.py` + versionnement `db_version` dans settings |
|
||
| Dictons | Table `dictons` seed avec ~60 dictons (Auvergne / Haute-Loire) |
|
||
| Astuces | Table `astuces` liée polymorphiquement (jardin / plante / tâche) |
|
||
| Récoltes | Table `recoltes` liée à une plantation (quantité, unité, date) |
|
||
| Ravageurs/maladies | Table `observations` (type: maladie/ravageur/traitement) |
|
||
|
||
---
|
||
|
||
## Phase 1 — Renommage & Enrichissement des modèles
|
||
|
||
> Priorité maximale : base de tout le reste
|
||
|
||
### 1.1 Renommage « Variétés » → « Plantes »
|
||
|
||
- [x] Backend : renommer `plant_varieties` → `plants`, router `/api/varieties` → `/api/plants`, modèles, seed
|
||
- [x] Frontend : renommer `VarietesView` → `PlantesView`, nav header, router, stores, api client
|
||
- [x] Tests : adapter tous les tests existants
|
||
|
||
**Impact** : ~12 fichiers
|
||
|
||
### 1.2 Enrichissement modèle Plante
|
||
|
||
Nouveaux champs :
|
||
|
||
- [x] `categorie` : enum (`potager`, `fleur`, `arbre`, `arbuste`)
|
||
- [x] `famille` : str (ex. Solanacées, Cucurbitacées...)
|
||
- [x] `resistance_froid` : int (°C minimum supporté)
|
||
- [x] `semis_debut` / `semis_fin` : int (mois 1-12)
|
||
- [x] `plantation_debut` / `plantation_fin` : int (mois 1-12)
|
||
- [x] `recolte_debut` / `recolte_fin` : int (mois 1-12)
|
||
- [x] `espacement_cm` : int nullable
|
||
- [x] `hauteur_cm` : int nullable
|
||
- [x] `maladies_courantes` : text (liste libre)
|
||
- [x] `astuces_culture` : text
|
||
- [x] `url_reference` : str nullable
|
||
|
||
### 1.3 Seed plantes courantes (~20 plantes)
|
||
|
||
- [x] Tomate, Courgette, Carotte, Salade, Ail, Oignon, Haricot, Pois, Poireau,
|
||
Pomme de terre, Fraise, Framboise, Persil, Échalote, Chou-fleur, Chou,
|
||
Betterave, Radis, Épinard, Basilic
|
||
|
||
### 1.4 Enrichissement modèle Jardin
|
||
|
||
Nouveaux champs :
|
||
|
||
- [x] `latitude` / `longitude` : float nullable (géolocalisation)
|
||
- [x] `type_terre` : enum (`argileux`, `sableux`, `limoneux`, `calcaire`, `humifère`)
|
||
- [x] `ph_sol` : float nullable (4.0 – 9.0)
|
||
- [x] `ensoleillement` : enum (`plein_soleil`, `mi_ombre`, `ombre`)
|
||
- [x] `surface_m2` : float nullable
|
||
- [x] `notes` : text nullable
|
||
|
||
### 1.5 Entité Outils (nouvelle)
|
||
|
||
Champs : `nom`, `description`, `categorie` (enum : bêche/fourche/griffe/arrosage/taille/autre), `photo_url`
|
||
|
||
- [x] Modèle SQLModel `Tool`
|
||
- [x] Router `/api/tools` (CRUD complet + tests)
|
||
- [x] Seed 15 outils : Bêche, Fourche-bêche, Grelinette, Pioche, Sarcloir, Râteau,
|
||
Binette, Transplantoir, Serfouette, Arrosoir, Tuyau, Sécateur, Cisaille, Brouette, Gants
|
||
- [x] Vue frontend `OutilsView.vue` + route `/outils`
|
||
- [x] Ajout dans la navigation (header + drawer)
|
||
|
||
### 1.6 Tâches enrichies
|
||
|
||
- [x] Champ `frequence_jours` : int nullable
|
||
- [x] Champ `date_prochaine` : date nullable
|
||
- [x] Champ `outil_id` : FK vers `tools` nullable
|
||
- [x] Seed tâches courantes : Arrosage, Binage, Désherbage, Taille, Traitement,
|
||
Semis, Plantation, Récolte, Compostage, Buttage, Paillage, Palissage, Fertilisation
|
||
|
||
### 1.7 Migration BDD automatique
|
||
|
||
- [x] Script `backend/app/migrate.py` : détecte colonnes manquantes via `PRAGMA table_info`
|
||
- [x] Applique `ALTER TABLE … ADD COLUMN` pour les nouveaux champs
|
||
- [x] Appelé dans le lifespan de `main.py` après `create_db_and_tables`
|
||
|
||
---
|
||
|
||
## Phase 2 — Médias enrichis
|
||
|
||
### 2.1 Upload photos avec optimisation
|
||
|
||
- [x] Ajouter `Pillow` aux dépendances backend
|
||
- [x] Endpoint `POST /api/upload` : détecter image → convertir WebP → resize 1200px max → thumbnail 300px
|
||
- [x] Nommage fichiers : `{uuid}.webp` + `{uuid}_thumb.webp`
|
||
- [x] Retourner `{ url, thumbnail_url }` dans la réponse
|
||
|
||
### 2.2 Photos liées aux entités (galerie)
|
||
|
||
- [x] Modèle `Media` : `entity_type` (jardin/plante/outil/plantation), `entity_id`, `url`, `thumbnail_url`, `titre`, `created_at`
|
||
- [x] Endpoint `GET /api/media?entity_type=jardin&entity_id=1`
|
||
- [x] Endpoint `DELETE /api/media/{id}`
|
||
- [ ] Composant Vue `MediaGallery.vue` réutilisable (lightbox simple)
|
||
|
||
### 2.3 Support PDF & URLs & annotations
|
||
|
||
- [x] Table `attachments` : `entity_type`, `entity_id`, `type` (pdf/url/note), `titre`, `contenu`
|
||
- [ ] Upload PDF stocké dans `/data/uploads/pdf/`
|
||
- [ ] Composant Vue `AttachmentList.vue`
|
||
|
||
### 2.4 Upload depuis mobile (appareil photo)
|
||
|
||
- [ ] `<input type="file" accept="image/*" capture="environment">` dans le composant upload
|
||
- [ ] Preview avant envoi (FileReader API)
|
||
|
||
---
|
||
|
||
## Phase 3 — Calendrier complet
|
||
|
||
### 3.1 Intégration lunar_calendar.py dans l'API
|
||
|
||
- [x] Service `backend/app/services/lunar.py` (skyfield + pytz + numpy)
|
||
- [x] Endpoint `GET /api/lunar?month=YYYY-MM` → retourne les jours du mois
|
||
- [x] Cache dict en mémoire par mois
|
||
|
||
### 3.2 Icônes calendrier lunaire
|
||
|
||
- [x] Phase interpolée sur illumination → icône emoji lune (🌑🌒🌓🌔🌕🌖🌗🌘)
|
||
- [x] Type jour → badge coloré : 🌱 Racine / 🌿 Feuille / 🌸 Fleur / 🍅 Fruit
|
||
- [x] Montante/Descendante : badges ↑↓
|
||
- [x] Périgée / Apogée / Nœud : badges spéciaux
|
||
|
||
### 3.3 Dictons régionaux
|
||
|
||
- [x] Table `dictons` : `mois` (1-12), `jour` nullable, `texte`, `region`
|
||
- [x] Seed ~15 dictons : Auvergne / Haute-Loire / National
|
||
- [x] Endpoint `GET /api/dictons?mois=3` → dictons du mois
|
||
|
||
### 3.4 Refonte vue Calendrier
|
||
|
||
- [x] Renommer `LunaireView.vue` → `CalendrierView.vue`, route `/calendrier`
|
||
- [x] Header navigation : "Lunaire" → "Calendrier"
|
||
- [x] Onglets internes : Lunaire / Météo / Tâches / Dictons
|
||
- [x] Vue mois : grille 7×5 avec résumé par jour (icône phase + type)
|
||
- [x] Vue jour (modal) : détail complet phase, signe zodiacal, type, dicton, météo
|
||
|
||
---
|
||
|
||
## Phase 4 — Météo
|
||
|
||
### 4.1 Intégration Open-Meteo
|
||
|
||
- [x] Service `backend/app/services/meteo.py` : httpx → Open-Meteo API
|
||
- [x] Cache fichier JSON 3h
|
||
- [x] Endpoint `GET /api/meteo?days=14`
|
||
|
||
### 4.2 Frontend météo
|
||
|
||
- [x] Onglet Météo dans CalendrierView avec codes WMO → icône + label + temp + pluie
|
||
- [x] Widget Dashboard : 3 prochains jours
|
||
|
||
---
|
||
|
||
## Phase 5 — Récoltes & Observations
|
||
|
||
### 5.1 Récoltes
|
||
|
||
- [x] Modèle `Recolte` : `plantation_id`, `quantite`, `unite`, `date_recolte`, `notes`
|
||
- [x] Router `/api/plantings/{id}/recoltes` (CRUD + tests)
|
||
- [x] API client frontend `recoltes.ts`
|
||
- [x] Section Récoltes dans PlantationsView (dépliable par plantation)
|
||
|
||
### 5.2 Observations (maladies, ravageurs, traitements)
|
||
|
||
- [x] Modèle `Observation` : `type` (maladie/ravageur/traitement/note), `titre`, `description`, `date`, `photo_url`
|
||
- [x] Router `/api/observations`
|
||
- [ ] Section Observations dans fiche plantation + jardin (frontend)
|
||
|
||
---
|
||
|
||
## Phase 6 — Capteurs IoT / MQTT
|
||
|
||
### 6.1-6.3 Capteurs
|
||
|
||
- [ ] Modèle `Sensor` + `SensorReading`
|
||
- [ ] Client MQTT (paho-mqtt)
|
||
- [ ] Frontend capteurs
|
||
|
||
> Phase optionnelle selon l'infrastructure disponible.
|
||
|
||
---
|
||
|
||
## Phase 7 — Astuces
|
||
|
||
### 7.1 Entité Astuces
|
||
|
||
- [x] Modèle `Astuce` : `entity_type`, `entity_id` nullable, `titre`, `contenu`, `source`
|
||
- [x] Router `/api/astuces`
|
||
- [x] Seed ~10 astuces
|
||
|
||
### 7.2 Frontend astuces
|
||
|
||
- [ ] Composant `AstuceCard.vue` (fond gruvbox-soft, icône 💡)
|
||
- [ ] "Astuce du jour" sur le Dashboard (rotation aléatoire par date)
|
||
|
||
---
|
||
|
||
## Phase 8 — UI/UX & Système de design
|
||
|
||
### 8.1 Palette sémantique (par-dessus Gruvbox)
|
||
|
||
- [x] Plante : `#b8bb26` (vert) · Jardin : orange · Arrosage : bleu · Outils : jaune
|
||
- [x] Récolte : `#8ec07c` (aqua) documenté dans tailwind.config.js
|
||
|
||
### 8.2 Responsive Desktop
|
||
|
||
- [x] Sidebar fixe 240px en desktop (≥1024px) avec icônes au lieu du drawer mobile
|
||
- [x] Drawer mobile maintenu pour petits écrans
|
||
|
||
### 8.3 Mode édition inline
|
||
|
||
- [ ] Bouton "Modifier" sur chaque fiche → bascule en mode formulaire in-place
|
||
- [ ] PUT sur l'API existante, sauvegarde optimiste
|
||
|
||
### 8.4 Icônes SVG dimensionnables
|
||
|
||
- [ ] Composant `AppIcon.vue` (name + size props)
|
||
|
||
---
|
||
|
||
## Phase 9 — Réglages avancés
|
||
|
||
### 9.1 Backup & Restore complet
|
||
|
||
- [ ] `GET /api/backup` → archive ZIP (jardin.db + uploads/) streamée
|
||
- [ ] `POST /api/restore` → upload ZIP, validation, décompression
|
||
|
||
### 9.2 Sections réglages organisées
|
||
|
||
- [ ] Onglets : Interface / Jardin / Plantes / Tâches / Calendrier / Météo / Capteurs / Sauvegarde
|
||
|
||
### 9.3 Détection de plante par photo (optionnel)
|
||
|
||
- [ ] Intégration Pl@ntNet API (désactivé si `PLANTNET_API_KEY` absent)
|
||
|
||
---
|
||
|
||
## Phase 10 — Backend : qualité & évolutivité
|
||
|
||
### 10.1 Tests de migration
|
||
|
||
- [ ] Tests de migration (créer DB v0, migrer vers v1, vérifier colonnes)
|
||
|
||
### 10.2 Export/Import JSON
|
||
|
||
- [ ] `GET /api/export` → JSON complet
|
||
- [ ] `POST /api/import` → validation + import
|
||
|
||
### 10.3 Tests élargis
|
||
|
||
- [ ] Tests pour chaque nouveau router (récoltes ✅, observations, capteurs, médias, dictons)
|
||
- [ ] Test service lunaire (mock skyfield ou dates connues)
|
||
- [ ] Test backup/restore
|
||
- [ ] Couverture cible : 80% des routers
|
||
|
||
---
|
||
|
||
## Ordre de développement recommandé
|
||
|
||
```text
|
||
Phase 1 (fondations) ✅
|
||
→ Phase 2 (médias) ✅ backend · frontend [ ]
|
||
→ Phase 3 (calendrier lunaire réel) ✅
|
||
→ Phase 4 (météo) ✅
|
||
Phase 5 (récoltes/observations) ✅ backend · frontend ✅ récoltes
|
||
Phase 7 (astuces) ✅ backend · frontend [ ]
|
||
Phase 8 (UI/UX) → sidebar responsive ✅ · mode édition [ ]
|
||
Phase 6 (MQTT) ← optionnel
|
||
Phase 9 (réglages avancés)
|
||
Phase 10 (qualité)
|
||
```
|
||
|
||
---
|
||
|
||
## Récapitulatif des nouvelles entités DB
|
||
|
||
| Table | Phase | Description | Statut |
|
||
| --- | --- | --- | --- |
|
||
| `plant` | 1.1 | Renommage de `plant_varieties` | ✅ |
|
||
| `tool` | 1.5 | Outils de jardinage | ✅ |
|
||
| `media` | 2.2 | Photos liées à toute entité | ✅ backend |
|
||
| `attachment` | 2.3 | PDF, URLs, notes | ✅ backend |
|
||
| `dicton` | 3.3 | Dictons saisonniers régionaux | ✅ |
|
||
| `recolte` | 5.1 | Quantités récoltées par plantation | ✅ |
|
||
| `observation` | 5.2 | Maladies, ravageurs, traitements | ✅ backend |
|
||
| `astuce` | 7.1 | Conseils de jardinage | ✅ backend |
|
||
|
||
---
|
||
|
||
## Changelog
|
||
|
||
| Date | Version | Description |
|
||
| --- | --- | --- |
|
||
| 2026-02-22 | v1.0 | Création initiale — 10 phases, ~90 tâches |
|
||
| 2026-02-22 | v1.1 | Phase 1-5 backend complètes · bug date Recolte corrigé · sidebar responsive desktop |
|