New archi: domain driven development
Working but need to check out code
This commit is contained in:
@@ -0,0 +1,308 @@
|
||||
# 🎯 Architecture Finale - 100% DDD
|
||||
|
||||
## ✅ Migration Complète Terminée
|
||||
|
||||
Toute la couche de compatibilité a été supprimée. L'architecture est maintenant **100% Domain-Driven Development**.
|
||||
|
||||
---
|
||||
|
||||
## 📁 Structure Finale
|
||||
|
||||
```
|
||||
agent_media/
|
||||
│
|
||||
├── domain/ # 🎯 LOGIQUE MÉTIER PURE
|
||||
│ ├── shared/
|
||||
│ │ ├── exceptions.py
|
||||
│ │ └── value_objects.py
|
||||
│ ├── movies/
|
||||
│ │ ├── entities.py
|
||||
│ │ ├── value_objects.py
|
||||
│ │ ├── repositories.py
|
||||
│ │ ├── services.py
|
||||
│ │ └── exceptions.py
|
||||
│ ├── tv_shows/
|
||||
│ │ ├── entities.py
|
||||
│ │ ├── value_objects.py
|
||||
│ │ ├── repositories.py
|
||||
│ │ ├── services.py
|
||||
│ │ └── exceptions.py
|
||||
│ └── subtitles/
|
||||
│ ├── entities.py
|
||||
│ ├── value_objects.py
|
||||
│ ├── repositories.py
|
||||
│ ├── services.py
|
||||
│ └── exceptions.py
|
||||
│
|
||||
├── infrastructure/ # 🔧 DÉTAILS TECHNIQUES
|
||||
│ ├── api/
|
||||
│ │ ├── tmdb/
|
||||
│ │ ├── knaben/
|
||||
│ │ └── qbittorrent/
|
||||
│ ├── persistence/
|
||||
│ │ ├── memory.py
|
||||
│ │ └── json/
|
||||
│ └── filesystem/
|
||||
│ ├── file_manager.py
|
||||
│ ├── organizer.py
|
||||
│ └── exceptions.py
|
||||
│
|
||||
├── application/ # 🎬 USE CASES
|
||||
│ ├── movies/
|
||||
│ │ ├── search_movie.py
|
||||
│ │ └── dto.py
|
||||
│ ├── torrents/
|
||||
│ │ ├── search_torrents.py
|
||||
│ │ ├── add_torrent.py
|
||||
│ │ └── dto.py
|
||||
│ └── filesystem/
|
||||
│ ├── set_folder_path.py
|
||||
│ ├── list_folder.py
|
||||
│ └── dto.py
|
||||
│
|
||||
├── agent/ # 🤖 INTERFACE LLM
|
||||
│ ├── llm/
|
||||
│ │ ├── __init__.py
|
||||
│ │ └── deepseek.py
|
||||
│ ├── tools/
|
||||
│ │ ├── __init__.py
|
||||
│ │ ├── api.py
|
||||
│ │ └── filesystem.py
|
||||
│ ├── agent.py
|
||||
│ ├── registry.py
|
||||
│ ├── prompts.py
|
||||
│ ├── parameters.py
|
||||
│ └── config.py
|
||||
│
|
||||
└── app.py # 🚀 FASTAPI
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔄 Imports Mis à Jour
|
||||
|
||||
### **app.py**
|
||||
```python
|
||||
# AVANT
|
||||
from agent.memory import Memory
|
||||
|
||||
# APRÈS
|
||||
from infrastructure.persistence.memory import Memory
|
||||
```
|
||||
|
||||
### **agent/agent.py**
|
||||
```python
|
||||
# AVANT
|
||||
from .memory import Memory
|
||||
|
||||
# APRÈS
|
||||
from infrastructure.persistence.memory import Memory
|
||||
```
|
||||
|
||||
### **agent/tools/api.py**
|
||||
```python
|
||||
# Utilise directement les use cases
|
||||
from application.movies import SearchMovieUseCase
|
||||
from infrastructure.api.tmdb import tmdb_client
|
||||
```
|
||||
|
||||
### **agent/tools/filesystem.py**
|
||||
```python
|
||||
# Utilise directement les use cases
|
||||
from application.filesystem import SetFolderPathUseCase
|
||||
from infrastructure.filesystem import FileManager
|
||||
from infrastructure.persistence.memory import Memory
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🗑️ Fichiers Supprimés
|
||||
|
||||
### **Ancienne Architecture**
|
||||
```
|
||||
❌ agent/api/themoviedb.py
|
||||
❌ agent/api/knaben.py
|
||||
❌ agent/api/qbittorrent.py
|
||||
❌ agent/api/__init__.py
|
||||
❌ agent/models/tv_show.py
|
||||
❌ agent/models/__init__.py
|
||||
❌ agent/memory.py
|
||||
```
|
||||
|
||||
### **Dossiers Supprimés**
|
||||
```
|
||||
❌ agent/api/
|
||||
❌ agent/models/
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## ✅ Fichiers Conservés
|
||||
|
||||
### **Agent Core**
|
||||
```
|
||||
✅ agent/agent.py # Agent principal (imports mis à jour)
|
||||
✅ agent/registry.py # Registry des tools
|
||||
✅ agent/prompts.py # Construction des prompts
|
||||
✅ agent/parameters.py # Schéma des paramètres
|
||||
✅ agent/config.py # Configuration
|
||||
```
|
||||
|
||||
### **Agent LLM**
|
||||
```
|
||||
✅ agent/llm/__init__.py
|
||||
✅ agent/llm/deepseek.py # Client DeepSeek
|
||||
```
|
||||
|
||||
### **Agent Tools**
|
||||
```
|
||||
✅ agent/tools/__init__.py
|
||||
✅ agent/tools/api.py # Wrappers vers use cases
|
||||
✅ agent/tools/filesystem.py # Wrappers vers use cases
|
||||
```
|
||||
|
||||
### **Application**
|
||||
```
|
||||
✅ app.py # FastAPI (imports mis à jour)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🎯 Flux de Données
|
||||
|
||||
```
|
||||
USER
|
||||
↓
|
||||
LibreChat
|
||||
↓
|
||||
app.py (FastAPI)
|
||||
↓
|
||||
Agent (agent/agent.py)
|
||||
↓
|
||||
Tools (agent/tools/)
|
||||
↓
|
||||
Use Cases (application/)
|
||||
↓
|
||||
Domain Services (domain/)
|
||||
↓
|
||||
Infrastructure (infrastructure/)
|
||||
↓
|
||||
External APIs / Storage
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔑 Principes DDD Appliqués
|
||||
|
||||
### **1. Layered Architecture**
|
||||
✅ Séparation stricte : Domain → Application → Infrastructure → Interface
|
||||
|
||||
### **2. Dependency Inversion**
|
||||
✅ Domain ne dépend de rien
|
||||
✅ Infrastructure dépend de Domain
|
||||
✅ Application orchestre Domain et Infrastructure
|
||||
|
||||
### **3. Bounded Contexts**
|
||||
✅ Movies, TV Shows, Subtitles sont des domaines séparés
|
||||
|
||||
### **4. Ubiquitous Language**
|
||||
✅ Vocabulaire métier partagé (Movie, TVShow, Episode, etc.)
|
||||
|
||||
### **5. Entities & Value Objects**
|
||||
✅ Entities : Movie, TVShow, Episode, Subtitle
|
||||
✅ Value Objects : ImdbId, MovieTitle, SeasonNumber, etc.
|
||||
|
||||
### **6. Repositories**
|
||||
✅ Interfaces abstraites dans domain/
|
||||
✅ Implémentations concrètes dans infrastructure/
|
||||
|
||||
### **7. Domain Services**
|
||||
✅ MovieService, TVShowService, SubtitleService
|
||||
|
||||
### **8. Application Services (Use Cases)**
|
||||
✅ SearchMovieUseCase, SearchTorrentsUseCase, etc.
|
||||
|
||||
---
|
||||
|
||||
## 🚀 Commandes de Nettoyage
|
||||
|
||||
### **Script Automatique**
|
||||
```bash
|
||||
chmod +x FINAL_CLEANUP.sh
|
||||
./FINAL_CLEANUP.sh
|
||||
```
|
||||
|
||||
### **Manuel**
|
||||
```bash
|
||||
# Supprimer les dossiers
|
||||
rm -rf agent/api/
|
||||
rm -rf agent/models/
|
||||
|
||||
# Supprimer le fichier
|
||||
rm -f agent/memory.py
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📊 Statistiques
|
||||
|
||||
### **Avant le Nettoyage**
|
||||
- Fichiers dans agent/ : ~15
|
||||
- Couches de compatibilité : 3 (api, models, memory)
|
||||
- Architecture : Hybride
|
||||
|
||||
### **Après le Nettoyage**
|
||||
- Fichiers dans agent/ : ~8
|
||||
- Couches de compatibilité : 0
|
||||
- Architecture : 100% DDD
|
||||
|
||||
---
|
||||
|
||||
## 🎉 Résultat
|
||||
|
||||
### **Architecture Propre** ✅
|
||||
Plus aucune couche de compatibilité
|
||||
|
||||
### **Imports Directs** ✅
|
||||
Tous les imports pointent vers la nouvelle architecture
|
||||
|
||||
### **DDD Pur** ✅
|
||||
Respect strict des principes Domain-Driven Development
|
||||
|
||||
### **Maintenable** ✅
|
||||
Code clair, organisé, facile à comprendre
|
||||
|
||||
### **Évolutif** ✅
|
||||
Facile d'ajouter de nouvelles fonctionnalités
|
||||
|
||||
---
|
||||
|
||||
## 📚 Documentation
|
||||
|
||||
- `DDD_PHASE1_COMPLETE.md` - Phase 1 (Domain + Infrastructure)
|
||||
- `DDD_PHASE2_COMPLETE.md` - Phase 2 (Application + Agent)
|
||||
- `DDD_MIGRATION_COMPLETE.md` - Récapitulatif complet
|
||||
- `ARCHITECTURE_FINALE.md` - Ce fichier (architecture finale)
|
||||
- `DELETED_FILES.md` - Liste des fichiers supprimés
|
||||
|
||||
---
|
||||
|
||||
## 🎯 Prochaines Étapes
|
||||
|
||||
1. **Tester l'application** : `uvicorn app:app --reload`
|
||||
2. **Vérifier que tout fonctionne**
|
||||
3. **Commencer à utiliser la nouvelle architecture**
|
||||
4. **Ajouter de nouveaux use cases si nécessaire**
|
||||
|
||||
---
|
||||
|
||||
## 🏆 Mission Accomplie
|
||||
|
||||
L'architecture est maintenant **100% Domain-Driven Development** !
|
||||
|
||||
✅ Aucune couche de compatibilité
|
||||
✅ Imports directs vers la nouvelle architecture
|
||||
✅ Code propre et maintenable
|
||||
✅ Prêt pour l'avenir
|
||||
|
||||
🎉 **Félicitations !** 🎉
|
||||
Reference in New Issue
Block a user