# 4NK IA Backend API d'ingestion et d'orchestration pour le pipeline notarial avec IA intégrée. ## 🚀 Démarrage rapide ### Installation automatique ```bash # Installation complète ./install.sh # Ou démarrage rapide des services essentiels ./quick-start.sh ``` ### Installation manuelle ```bash # 1. Cloner le repository git clone cd 4NK_IA_back # 2. Créer le fichier .env cp .env.example .env # Éditer .env avec vos configurations # 3. Démarrer les services make up ``` ## 📋 Prérequis - Docker et Docker Compose - Python 3.11+ (pour le développement local) - 8GB RAM minimum - 20GB d'espace disque ## 🛠️ Commandes disponibles ### Installation et démarrage ```bash # Installation complète make install # Démarrage rapide make quick-start # Démarrage normal make up # Arrêt make down # Redémarrage make restart ``` ### Maintenance ```bash # Statut des services make status # Vérification de santé make health-check # Logs make logs # Logs spécifiques make logs-api make logs-db make logs-redis make logs-minio # Sauvegarde make backup # Restauration make restore # Nettoyage make clean-all # Mise à jour make update-images ``` ### Développement ```bash # Mode développement make dev # Tests make test # Shell dans l'API make shell-api # Construction des images make build ``` ## 🌐 Services disponibles | Service | URL | Description | |---------|-----|-------------| | API Backend | http://localhost:8000 | API principale | | API Documentation | http://localhost:8000/api-docs | Documentation Swagger | | MinIO Console | http://localhost:9001 | Interface de stockage | | AnythingLLM | http://localhost:3001 | Interface LLM | | Grafana | http://localhost:3000 | Monitoring | | Neo4j Browser | http://localhost:7474 | Base de données graphique | ## 🔧 Configuration ### Variables d'environnement Le fichier `.env` contient toutes les configurations : ```bash # Base de données POSTGRES_USER=notariat POSTGRES_PASSWORD=notariat_pwd POSTGRES_DB=notariat # MinIO MINIO_ROOT_USER=minioadmin MINIO_ROOT_PASSWORD=minioadmin123 # Neo4j NEO4J_AUTH=neo4j/neo4j123 # Services externes ANYLLM_BASE_URL=http://anythingsqlite:3001 OLLAMA_BASE_URL=http://ollama:11434 ``` ### Configuration de l'API L'API backend est configurée via les variables d'environnement : - `API_HOST`: Adresse d'écoute (défaut: 0.0.0.0) - `API_PORT`: Port d'écoute (défaut: 8000) - `API_WORKERS`: Nombre de workers (défaut: 4) - `LOG_LEVEL`: Niveau de log (défaut: INFO) - `SECRET_KEY`: Clé secrète pour JWT ## 📊 Monitoring ### Healthchecks Tous les services incluent des healthchecks : ```bash # Vérification manuelle curl http://localhost:8000/api/health # Via le script de maintenance ./maintenance.sh health ``` ### Logs ```bash # Tous les logs make logs # Logs spécifiques make logs-api make logs-db # Logs en temps réel docker-compose -f infra/docker-compose.yml logs -f ``` ### Métriques - **Grafana**: http://localhost:3000 - **Prometheus**: Métriques disponibles sur le port 9090 ## 🔒 Sécurité ### Authentification L'API utilise JWT pour l'authentification : ```bash # Génération d'un token curl -X POST http://localhost:8000/api/auth/login \ -H "Content-Type: application/json" \ -d '{"username": "admin", "password": "password"}' ``` ### HTTPS Pour la production, configurez un reverse proxy (nginx/traefik) avec SSL. ## 🧪 Tests ```bash # Tests unitaires make test # Tests d'intégration make test-api # Tests avec coverage python -m pytest tests/ --cov=services/host_api ``` ## 📦 Déploiement ### Production ```bash # Installation en mode production ./install.sh prod # Ou via Makefile make prod ``` ### Docker ```bash # Construction des images make build # Construction sans cache make build-no-cache ``` ## 🐛 Dépannage ### Problèmes courants 1. **Port déjà utilisé** ```bash # Vérifier les ports utilisés netstat -tlnp | grep :8000 # Arrêter les services make down ``` 2. **Problème de permissions** ```bash # Vérifier les permissions ls -la # Corriger les permissions chmod +x *.sh ``` 3. **Services non accessibles** ```bash # Vérifier le statut make status # Vérifier les logs make logs ``` ### Logs de débogage ```bash # Logs détaillés docker-compose -f infra/docker-compose.yml logs -f --tail=100 # Logs d'un service spécifique docker-compose -f infra/docker-compose.yml logs -f host-api ``` ## 📚 Documentation - [API Documentation](http://localhost:8000/api-docs) - [Changelog](CHANGELOG.md) - [Contributing](CONTRIBUTING.md) - [Code of Conduct](CODE_OF_CONDUCT.md) ## 🤝 Contribution 1. Fork le projet 2. Créer une branche feature (`git checkout -b feature/AmazingFeature`) 3. Commit les changements (`git commit -m 'Add some AmazingFeature'`) 4. Push vers la branche (`git push origin feature/AmazingFeature`) 5. Ouvrir une Pull Request ## 📄 Licence Ce projet est sous licence MIT. Voir le fichier [LICENSE](LICENSE) pour plus de détails. ## 🆘 Support Pour obtenir de l'aide : 1. Consultez la [documentation](http://localhost:8000/api-docs) 2. Vérifiez les [issues existantes](https://github.com/your-repo/issues) 3. Créez une nouvelle issue si nécessaire ## 🔄 Mise à jour ```bash # Mise à jour des images Docker make update-images # Mise à jour du code git pull origin main make build make restart ```