From 173cfcd9ab76604539e158caed48f131b67a19e2 Mon Sep 17 00:00:00 2001 From: dahoud Date: Sat, 10 Jan 2026 11:09:22 +0000 Subject: [PATCH] =?UTF-8?q?docs:=20Ajout=20guide=20de=20d=C3=A9ploiement?= =?UTF-8?q?=20frontend?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DEPLOYMENT_FRONTEND.md | 330 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 330 insertions(+) create mode 100644 DEPLOYMENT_FRONTEND.md diff --git a/DEPLOYMENT_FRONTEND.md b/DEPLOYMENT_FRONTEND.md new file mode 100644 index 0000000..9e33fef --- /dev/null +++ b/DEPLOYMENT_FRONTEND.md @@ -0,0 +1,330 @@ +# 🚀 DĂ©ploiement Frontend AfterWork + +**Date** : 2026-01-10 +**Statut** : ✅ PrĂȘt pour le build production + +--- + +## 📋 Configuration de Production + +### URL de l'API Backend +``` +https://api.lions.dev/afterwork +``` + +### WebSocket +``` +wss://api.lions.dev/afterwork/ws/notifications/{userId} +wss://api.lions.dev/afterwork/ws/chat/{userId} +``` + +--- + +## 🔧 Build de l'Application + +### Build APK (Android) + +```powershell +cd C:\Users\dadyo\PersonalProjects\lions-workspace\afterwork + +# Build APK production +.\build-prod.ps1 -Target apk + +# Ou directement avec Flutter +flutter build apk --release \ + --dart-define=API_BASE_URL=https://api.lions.dev/afterwork \ + --dart-define=ENVIRONMENT=production \ + --dart-define=DEBUG_MODE=false \ + --split-per-abi +``` + +**Artefacts gĂ©nĂ©rĂ©s:** +``` +build/app/outputs/flutter-apk/ +├── app-armeabi-v7a-release.apk +├── app-arm64-v8a-release.apk (RecommandĂ© pour la plupart des appareils) +└── app-x86_64-release.apk +``` + +### Build AAB (Google Play Store) + +```powershell +# Build AAB pour Play Store +.\build-prod.ps1 -Target appbundle + +# Ou directement +flutter build appbundle --release \ + --dart-define=API_BASE_URL=https://api.lions.dev/afterwork \ + --dart-define=ENVIRONMENT=production \ + --dart-define=DEBUG_MODE=false +``` + +**Artefact gĂ©nĂ©rĂ©:** +``` +build/app/outputs/bundle/release/app-release.aab +``` + +--- + +## đŸ“± Installation et Test + +### Installer l'APK sur un Appareil + +```bash +# Via ADB +adb install build/app/outputs/flutter-apk/app-arm64-v8a-release.apk + +# Ou copier l'APK sur l'appareil et l'installer manuellement +``` + +### Tester l'Application + +1. **Connexion au Backend** + - L'app doit pointer vers `https://api.lions.dev/afterwork` + - VĂ©rifier que le login fonctionne + +2. **WebSocket (Temps RĂ©el)** + - Tester les notifications en temps rĂ©el + - Tester le chat instantanĂ© + - VĂ©rifier les typing indicators + +3. **FonctionnalitĂ©s Principales** + - ✅ Login/Signup + - ✅ Gestion de profil + - ✅ ÉvĂ©nements + - ✅ Amis (ajout, suggestions, demandes) + - ✅ Chat (messages, statuts ✓✓✓) + - ✅ Social (posts, likes, commentaires) + - ✅ Stories + - ✅ Notifications + +--- + +## 🔄 Changements pour Production + +### Configuration API + +Le fichier `lib/core/constants/env_config.dart` est configurĂ© pour supporter les variables d'environnement: + +```dart +static const String apiBaseUrl = String.fromEnvironment( + 'API_BASE_URL', + defaultValue: 'http://192.168.1.145:8080', // DĂ©veloppement +); +``` + +**En production:** +- Via `--dart-define=API_BASE_URL=https://api.lions.dev/afterwork` +- Le script `build-prod.ps1` configure automatiquement cette variable + +### Validation + +Au dĂ©marrage, l'app valide la configuration: +- En production, HTTPS est obligatoire +- Les URLs malformĂ©es sont rejetĂ©es +- Les clĂ©s API manquantes gĂ©nĂšrent des warnings + +--- + +## 🐛 Corrections AppliquĂ©es + +### Race Condition Chat (CRITIQUE) +**ProblĂšme:** Les icĂŽnes de statut (✓, ✓✓, ✓✓ bleu) ne s'affichaient pas + +**Solution:** Pattern Optimistic UI +- Message créé localement immĂ©diatement +- AjoutĂ© Ă  la liste AVANT la requĂȘte HTTP +- RemplacĂ© par le message serveur Ă  la rĂ©ponse + +**Fichier:** `lib/presentation/state_management/chat_bloc.dart` + +### TODOs ImplĂ©mentĂ©s (13) +- Partage de posts (copier lien, partage natif) +- Signalement de posts +- Recherche de conversations +- Gestion de mĂ©dias (upload, suppression, miniatures) +- SĂ©lection d'amis pour partage + +--- + +## 📩 Fichiers Importants + +### Configuration +``` +lib/core/constants/ +├── env_config.dart # Configuration environnements +├── colors.dart # ThĂšme de couleurs +└── urls.dart # URLs et endpoints + +lib/config/ +├── injection/injection.dart # Injection de dĂ©pendances +└── router.dart # Navigation +``` + +### Services +``` +lib/data/services/ +├── chat_websocket_service.dart # WebSocket chat +├── realtime_notification_service.dart # WebSocket notifications +├── media_upload_service.dart # Upload mĂ©dias +└── image_compression_service.dart # Compression images +``` + +### État Management +``` +lib/presentation/state_management/ +├── chat_bloc.dart # Gestion chat +├── event_bloc.dart # Gestion Ă©vĂ©nements +└── user_bloc.dart # Gestion utilisateurs +``` + +--- + +## 🎯 URLs et Endpoints + +### Authentification +- **POST** `/api/users/login` +- **POST** `/api/users/register` + +### Utilisateurs +- **GET** `/api/users/{id}` +- **PUT** `/api/users/{id}` +- **GET** `/api/users/friends` + +### Chat +- **GET** `/api/messages/conversations` +- **GET** `/api/messages/conversation/{id}` +- **POST** `/api/messages/send` +- **WebSocket** `/ws/chat/{userId}` + +### Social +- **GET** `/api/social/posts` +- **POST** `/api/social/posts` +- **POST** `/api/social/posts/{id}/like` +- **POST** `/api/social/posts/{id}/comment` + +### Notifications +- **GET** `/api/notifications` +- **PUT** `/api/notifications/{id}/read` +- **WebSocket** `/ws/notifications/{userId}` + +--- + +## 📊 Statistiques du Projet + +| MĂ©trique | Valeur | +|----------|--------| +| **Fichiers Dart** | ~200+ | +| **Lignes de code** | ~40,000+ | +| **Widgets custom** | 80+ | +| **Blocs/Providers** | 15+ | +| **Services** | 20+ | +| **Entities** | 15+ | +| **Tests** | 25+ | + +--- + +## ✅ Checklist de DĂ©ploiement + +### Avant le Build +- [x] Backend dĂ©ployĂ© et accessible sur `https://api.lions.dev/afterwork` +- [x] Configuration `env_config.dart` prĂȘte +- [x] Script `build-prod.ps1` configurĂ© +- [x] Tests manuels effectuĂ©s en local +- [x] Race condition chat corrigĂ©e + +### Build +- [ ] ExĂ©cuter `.\build-prod.ps1 -Target apk` +- [ ] VĂ©rifier la taille des APKs gĂ©nĂ©rĂ©s +- [ ] Tester l'installation sur un appareil rĂ©el + +### Tests Post-Build +- [ ] Login fonctionne avec l'API production +- [ ] WebSocket se connecte correctement +- [ ] Chat temps rĂ©el fonctionne +- [ ] Notifications temps rĂ©el fonctionnent +- [ ] Upload de mĂ©dias fonctionne +- [ ] Pas d'erreurs dans les logs + +### Distribution +- [ ] Signer l'APK/AAB si nĂ©cessaire +- [ ] Upload sur Play Store (ou distribution interne) +- [ ] Documentation utilisateur mise Ă  jour + +--- + +## 🔐 SĂ©curitĂ© + +### HTTPS Obligatoire en Production +L'application force HTTPS en production via `env_config.dart`: + +```dart +if (isProduction && !apiBaseUrl.startsWith('https://')) { + errors.add('API_BASE_URL doit utiliser HTTPS en production'); +} +``` + +### Tokens et Authentification +- Les tokens JWT sont stockĂ©s de maniĂšre sĂ©curisĂ©e +- Refresh automatique des tokens expirĂ©s +- DĂ©connexion automatique si le token est invalide + +--- + +## 📞 Support + +En cas de problĂšme: + +1. **VĂ©rifier les logs de l'app:** + ```bash + flutter logs + # ou + adb logcat | grep flutter + ``` + +2. **VĂ©rifier la connexion API:** + ```bash + curl https://api.lions.dev/afterwork/q/health/ready + ``` + +3. **VĂ©rifier les WebSockets:** + - Ouvrir l'app + - VĂ©rifier les logs pour "WebSocket connected" + +--- + +## 🎉 RĂ©sumĂ© + +### ✅ Application ComplĂšte et Fonctionnelle + +- **Frontend**: Flutter avec architecture Clean + BLoC +- **Backend**: Quarkus avec WebSocket temps rĂ©el +- **Infrastructure**: Kubernetes sur VPS +- **URL Production**: https://api.lions.dev/afterwork + +### ✅ PrĂȘt pour Production + +Toutes les fonctionnalitĂ©s sont implĂ©mentĂ©es et testĂ©es: +- Authentification sĂ©curisĂ©e +- Chat temps rĂ©el avec statuts de messages +- Publications sociales avec mĂ©dias +- Stories temporaires +- Notifications push temps rĂ©el +- Gestion d'Ă©vĂ©nements +- SystĂšme d'amitiĂ© complet + +--- + +**Pour builder l'application:** +```powershell +.\build-prod.ps1 -Target apk +``` + +**Artefacts:** +``` +build/app/outputs/flutter-apk/app-arm64-v8a-release.apk +``` + +--- + +**DerniĂšre mise Ă  jour:** 2026-01-10