ihm_client/docs/INTEGRATION_4NK_NODE.md

306 lines
8.4 KiB
Markdown

# Intégration de l'Interface Utilisateur dans 4NK_node
Ce document décrit le processus d'intégration de l'interface utilisateur `ihm_client` dans l'infrastructure `4NK_node`.
## 🎯 Objectif
Intégrer l'interface utilisateur web dans le conteneur `4NK_node` pour fournir une interface graphique complète pour :
- Gestion des paiements silencieux
- Interaction avec les relais sdk_relay
- Monitoring de l'infrastructure Bitcoin
- Interface utilisateur pour les fonctionnalités 4NK
## 📁 Fichiers d'Intégration
### Nouveaux Fichiers Créés
- `Dockerfile.4nk-node` - Dockerfile optimisé pour l'intégration
- `nginx.4nk-node.conf` - Configuration nginx adaptée à 4NK_node
- `start-4nk-node.sh` - Script de démarrage avec vérification des services
- `docker-compose.4nk-node.yml` - Configuration Docker Compose
- `INTEGRATION_4NK_NODE.md` - Cette documentation
## 🏗️ Architecture d'Intégration
```
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ ihm_client │ │ sdk_relay_1 │ │ sdk_relay_2 │
│ (Port 8080) │◄──►│ (Port 8090) │◄──►│ (Port 8091) │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│ │ │
│ ▼ ▼
│ ┌─────────────────┐ ┌─────────────────┐
│ │ sdk_relay_3 │ │ Bitcoin │
│ │ (Port 8092) │ │ (Port 18443) │
│ └─────────────────┘ └─────────────────┘
│ │ │
│ ▼ ▼
│ ┌─────────────────┐ ┌─────────────────┐
└─────────────►│ Blindbit │ │ Tor │
│ (Port 8000) │ │ (Port 9050) │
└─────────────────┘ └─────────────────┘
```
## 🚀 Démarrage Rapide
### 1. Prérequis
- Docker et Docker Compose installés
- Réseau `btcnet` créé (via 4NK_node)
- Services 4NK_node en cours d'exécution
### 2. Intégration dans 4NK_node
```bash
# Depuis le répertoire 4NK_node
cd 4NK_node
# Ajouter le service ihm_client au docker-compose.yml
# Copier les fichiers d'intégration depuis ihm_client
cp ../ihm_client/Dockerfile.4nk-node ./ihm_client/
cp ../ihm_client/nginx.4nk-node.conf ./ihm_client/
cp ../ihm_client/start-4nk-node.sh ./ihm_client/
# Ajouter le service au docker-compose.yml principal
```
### 3. Configuration du docker-compose.yml principal
Ajouter le service suivant au `docker-compose.yml` de 4NK_node :
```yaml
ihm_client:
build:
context: ./ihm_client
dockerfile: Dockerfile.4nk-node
container_name: 4nk-ihm-client
ports:
- "8080:80"
environment:
- SDK_RELAY_WS_URL=ws://sdk_relay_1:8090
- SDK_RELAY_HTTP_URL=http://sdk_relay_1:8091
- BITCOIN_RPC_URL=http://bitcoin:18443
- BLINDBIT_URL=http://blindbit:8000
volumes:
- ihm_client_logs:/var/log/nginx
networks:
- btcnet
depends_on:
- sdk_relay_1
- sdk_relay_2
- sdk_relay_3
restart: unless-stopped
```
### 4. Démarrage
```bash
# Redémarrer l'infrastructure complète
./restart_4nk_node.sh
# Ou démarrer uniquement l'interface
docker-compose up -d ihm_client
```
## 🔧 Configuration
### Variables d'Environnement
| Variable | Défaut | Description |
|----------|--------|-------------|
| `SDK_RELAY_WS_URL` | `ws://sdk_relay_1:8090` | URL WebSocket du relais principal |
| `SDK_RELAY_HTTP_URL` | `http://sdk_relay_1:8091` | URL HTTP de l'API du relais |
| `BITCOIN_RPC_URL` | `http://bitcoin:18443` | URL RPC de Bitcoin Core |
| `BLINDBIT_URL` | `http://blindbit:8000` | URL du service Blindbit |
### Ports
| Port | Service | Description |
|------|---------|-------------|
| 8080 | HTTP | Interface utilisateur principale |
| 3003 | Dev | Serveur de développement (optionnel) |
### Volumes
| Volume | Description |
|--------|-------------|
| `ihm_client_logs` | Logs nginx |
| `ihm_client_data` | Données persistantes |
## 🔌 Connectivité
### Services Intégrés
1. **sdk_relay WebSocket** (`/ws/`)
- Communication temps réel
- Synchronisation des données
- Notifications
2. **sdk_relay HTTP API** (`/api/`)
- Endpoints REST
- Gestion des paiements
- Configuration
3. **Bitcoin Core RPC** (`/bitcoin/`)
- Accès aux données blockchain
- Gestion des transactions
- Monitoring
4. **Blindbit** (`/blindbit/`)
- Filtres de paiements silencieux
- Services de validation
## 🧪 Tests d'Intégration
### Test de Connectivité
```bash
# Test de l'interface principale
curl -f http://localhost:8080
# Test de l'API sdk_relay
curl -f http://localhost:8080/api/health
# Test WebSocket
wscat -c ws://localhost:8080/ws/
```
### Test de Fonctionnalités
```bash
# Vérifier les logs
docker logs 4nk-ihm-client
# Tester la santé du conteneur
docker exec 4nk-ihm-client wget -q -O- http://localhost
# Vérifier la configuration
docker exec 4nk-ihm-client cat /usr/share/nginx/html/config.js
```
## 🔍 Monitoring
### Logs
```bash
# Logs en temps réel
docker logs -f 4nk-ihm-client
# Logs nginx
docker exec 4nk-ihm-client tail -f /var/log/nginx/ihm_client_access.log
docker exec 4nk-ihm-client tail -f /var/log/nginx/ihm_client_error.log
```
### Métriques
- **Disponibilité** : Healthcheck automatique
- **Performance** : Logs nginx avec métriques
- **Erreurs** : Logs d'erreur centralisés
## 🛠️ Développement
### Mode Développement
```bash
# Démarrer en mode développement
docker-compose -f docker-compose.4nk-node.yml up -d
# Rebuild après modifications
docker-compose -f docker-compose.4nk-node.yml build --no-cache ihm_client
```
### Debugging
```bash
# Accès au conteneur
docker exec -it 4nk-ihm-client sh
# Vérifier la configuration nginx
docker exec 4nk-ihm-client nginx -t
# Tester les services
docker exec 4nk-ihm-client wget -q -O- http://sdk_relay_1:8091/health
```
## 🔒 Sécurité
### Headers de Sécurité
- `X-Frame-Options: SAMEORIGIN`
- `X-Content-Type-Options: nosniff`
- `X-XSS-Protection: 1; mode=block`
- `Referrer-Policy: strict-origin-when-cross-origin`
### Authentification
- Bitcoin RPC : Authentification basique
- API sdk_relay : CORS configuré
- WebSocket : Validation des connexions
## 📊 Performance
### Optimisations
- **Cache statique** : Assets avec expiration 1 an
- **Compression** : Nginx gzip activé
- **Proxy** : Connexions persistantes
- **Healthcheck** : Monitoring automatique
### Ressources
- **CPU** : 0.5-1 core
- **RAM** : 256-512 MB
- **Stockage** : 100-200 MB
## 🚨 Dépannage
### Problèmes Courants
1. **Service non accessible**
```bash
# Vérifier les logs de démarrage
docker logs 4nk-ihm-client
# Vérifier la connectivité réseau
docker exec 4nk-ihm-client ping sdk_relay_1
```
2. **Erreurs nginx**
```bash
# Vérifier la configuration
docker exec 4nk-ihm-client nginx -t
# Redémarrer nginx
docker exec 4nk-ihm-client nginx -s reload
```
3. **Problèmes de build**
```bash
# Nettoyer et rebuilder
docker-compose down
docker system prune -f
docker-compose build --no-cache ihm_client
```
## 📈 Évolution
### Prochaines Étapes
1. **Intégration complète** dans 4NK_node
2. **Tests automatisés** d'intégration
3. **Monitoring avancé** avec métriques
4. **Interface d'administration** pour 4NK_node
5. **Documentation utilisateur** complète
### Améliorations Futures
- **Interface d'administration** pour gérer l'infrastructure
- **Dashboard de monitoring** en temps réel
- **Gestion des utilisateurs** et permissions
- **API REST** pour l'automatisation
- **Interface mobile** responsive
---
**Note** : Cette intégration est conçue pour être transparente et non intrusive dans l'infrastructure 4NK_node existante.