From cc9635c8b69ac7ebcfa9751a3da7a6e011aa64fb Mon Sep 17 00:00:00 2001 From: Pierre Date: Mon, 24 Aug 2026 08:53:44 +0000 Subject: [PATCH] Add detailed documentation --- docs/README.md | 235 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 235 insertions(+) create mode 100644 docs/README.md diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..551a072 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,235 @@ +# Gestion - Documentation détaillée + +## Architecture + +```mermaid +graph TD + subgraph "Frontend (Next.js 14)" + Pages[App Router Pages] + Components[Composants React] + Forms[react-hook-form + zod] + Charts[Recharts] + end + + subgraph "Backend (Next.js API Routes)" + API[API Routes] + Auth[Auth Middleware
jose JWT] + Mail[Nodemailer] + end + + subgraph "Base de données" + PG[(PostgreSQL 17
gestion_secourit)] + Prisma[Prisma Client 5] + end + + subgraph "Services externes" + SMTP[Infomaniak SMTP
smtp.infomaniak.ch:465] + end + + Pages --> Components + Components --> Forms + Components --> Charts + Components --> API + API --> Auth + API --> Prisma + API --> Mail + Prisma --> PG + Mail --> SMTP +``` + +## Modèle de données (Prisma) + +```mermaid +erDiagram + USER ||--o{ SESSION : "a" + USER ||--o{ CLIENT : "gère" + USER ||--o{ QUOTE : "crée" + USER ||--o{ SALE : "enregistre" + USER ||--o{ TODO : "a" + CLIENT ||--o{ QUOTE : "reçoit" + CLIENT ||--o{ CONTRACT : "a" + CLIENT ||--o{ SALE : "a" + QUOTE ||--o{ QUOTE_ITEM : "contient" + QUOTE ||--o| CONTRACT : "devient" + CONTRACT ||--o{ INVOICE : "génère" + SALE ||--o{ SALE_ITEM : "contient" + + USER { + string id PK + string email UK + string name + string passwordHash + string role + } + + CLIENT { + string id PK + string name + string email + string phone + string address + string siret + enum type PROSPECT|CLIENT + boolean isProfessional + string userId FK + } + + QUOTE { + string id PK + string clientId FK + string userId FK + string name + string quoteNumber + enum status DRAFT|PROPOSAL|SENT|ACCEPTED|REJECTED|EXPIRED + float setupTotal + float monthlyTotal + float costTotal + float marginTotal + float discount + int travelKm + float travelCost + } + + QUOTE_ITEM { + string id PK + string quoteId FK + enum type PRODUCT|SERVICE + string label + float unitPrice + float costPrice + int quantity + boolean isRecurring + float setupPrice + float monthlyPrice + } + + CONTRACT { + string id PK + string clientId FK + string quoteId FK + string userId FK + string contractNumber + enum status ACTIVE|TERMINATED|CANCELLED + date startDate + date endDate + } + + INVOICE { + string id PK + string clientId FK + string contractId FK + string userId FK + string invoiceNumber + enum status DRAFT|SENT|PAID|OVERDUE + float total + date dueDate + } + + SALE { + string id PK + string clientId FK + string userId FK + float total + date saleDate + string proposal + } + + SALE_ITEM { + string id PK + string saleId FK + string productId + int quantity + float unitPrice + } + + TODO { + string id PK + string userId FK + string title + string description + enum priority LOW|MEDIUM|HIGH + boolean completed + } +``` + +## Pages et Routes + +### Pages (Frontend) +| Route | Description | +|-------|-------------| +| `/` | Dashboard principal | +| `/login` | Page de connexion | +| `/clients` | Liste des clients | +| `/quotes` | Liste des devis | +| `/contracts` | Liste des contrats | +| `/invoices` | Liste des factures | +| `/sales` | Liste des ventes | +| `/servers` | Gestion serveurs | +| `/todos` | To-do list | + +### API Routes +| Méthode | Route | Description | +|---------|-------|-------------| +| POST | `/api/auth/login` | Connexion | +| POST | `/api/auth/register` | Inscription | +| GET | `/api/auth/me` | Profil | +| GET | `/api/clients` | Liste clients | +| POST | `/api/clients` | Créer client | +| GET | `/api/quotes` | Liste devis | +| POST | `/api/quotes` | Créer devis | +| GET | `/api/contracts` | Liste contrats | +| GET | `/api/invoices` | Liste factures | +| GET | `/api/sales` | Liste ventes | +| GET | `/api/dashboard` | Données dashboard | +| GET | `/api/todos` | Liste to-dos | + +## Fonctionnalités + +### Clients +- Types : prospect, client +- Informations pro (SIRET) ou perso +- Historique devis/contrats/factures + +### Devis +- Lignes avec prix unitaire, coût, quantité +- Calcul automatique : setup total, mensuel, marge +- Frais de déplacement (km) +- Statuts : brouillon → proposition → envoyé → accepté/refusé/expiré +- Conversion en contrat + +### Contrats +- Liés à un devis accepté +- Suivi durée (début/fin) +- Génération de factures + +### Factures +- Numérotation auto +- Statuts : brouillon → envoyé → payé → en retard +- Notifications email + +### Ventes +- Enregistrement avec lignes +- Référencement produits + +### To-do list +- Priorités (low/medium/high) +- Suivi complétion + +## Développement + +```bash +cd /opt/gestion +npm install +npx prisma generate +npx prisma db push +npm run dev # Next.js dev sur :3005 +``` + +## Déploiement + +```bash +# Production (bare metal, pas Docker) +NODE_ENV=production nohup npx next start -p 3005 & +``` + +> **Note** : Pas de process manager. Envisager pm2 ou systemd.