SPARKY is an AI-powered intelligent document processing platform for the Tunisian photovoltaic sector that automatically scans, classifies, and extracts data from invoices, quotes, delivery notes, purchase orders, and credit notes using Mistral AI, with secure authentication, PostgreSQL storage, Google Sheets export, and automated email notifica
# SPARKY (v2 — Angular 20)
Plateforme web d'intelligence documentaire pour le secteur photovoltaïque tunisien. Scanne, classifie et extrait automatiquement les données de factures, devis, bons de livraison, bons de commande et avoirs grâce à Mistral AI, avec persistance PostgreSQL, authentification sécurisée, export Google Sheets et notifications email orchestrées via n8n.
> **Cette version est l'upgrade v2** depuis Angular 17 → **Angular 20.3** + Material 20 (Material 3 design tokens) + Node 24 LTS. La version originale en Angular 17 reste disponible dans `C:\Sparky`.
---
## 🚀 Fonctionnalités
- **Scan multi-format** : PDF, JPG, PNG, TIFF
- **Classification automatique IA** : facture / devis / bon de livraison / bon de commande / avoir
- **Extraction structurée** : fournisseur, n° document, dates, montants HT/TVA/TTC, lignes articles
- **Score de confiance IA** affiché sur chaque document
- **Comparaison de prix** entre fournisseurs avec mise en évidence du moins cher
- **Catalogue stock** : articles + mouvements (entrées / sorties / inventaires / retours)
- **Export Excel** mis en forme et **Google Sheets** automatique (1 ligne par article extrait)
- **Notification email HTML** détaillée à chaque scan via n8n (tableau articles, totaux, bouton sheet)
- **Authentification sécurisée** (bcrypt, PostgreSQL `users`)
- **Tableau de bord** avec totaux par type, score IA, fournisseur, montant TTC
- **Déploiement Docker** : Orchestration complète via `docker-compose.yml`
---
## 🛠️ Stack technique
| Couche | Technologie |
|--------|-------------|
| Frontend | **Angular 20.3** (Signals, Material 3, RxJS 7.8) |
| Backend | FastAPI + Python 3.12 |
| Base de données | PostgreSQL 16 |
| ORM | SQLAlchemy async + asyncpg |
| IA | Mistral AI (`mistral-small-latest` + `pixtral-12b-2409`) |
| Workflow | n8n (notifications email + export Google Sheets) |
| Containerisation | Docker + Docker Compose |
| Export | openpyxl (Excel) + Google Sheets API |
---
## ⚙️ Déploiement et In …