lecoffre_node/docs/ARCHITECTURE.md

108 lines
4.3 KiB
Markdown

# Architecture LeCoffre Node
> **📚 Documentation IA Recommandée** : Commencez par lire [`../IA_agents/context.md`](../IA_agents/context.md) et [`../IA_agents/flux.md`](../IA_agents/flux.md)
## Vue d'ensemble
LeCoffre Node orchestre les services nécessaires pour la plateforme de gestion de documents sécurisée LeCoffre, utilisant Bitcoin Signet et des technologies de cryptographie avancées.
## 🏗️ Architecture des Services
### Services Locaux (Docker Compose)
| Service | Port | Image | Statut | Description |
|---------|------|-------|--------|-------------|
| **tor-proxy** | 9050 | `btcpayserver/tor:0.4.8.10` | ✅ | Proxy anonyme pour Bitcoin |
| **bitcoin-signet** | - | `git.4nkweb.com/4nk/bitcoin:latest` | ✅ | Nœud Bitcoin Signet |
| **blindbit-oracle** | 8000 | `git.4nkweb.com/4nk/blindbit-oracle:dev` | ✅ | Oracle blockchain |
| **sdk_relay** | 8090-8091 | `git.4nkweb.com/4nk/sdk_relay:ext` | ✅ | Relay WebSocket |
| **sdk_signer** | 3001 | `git.4nkweb.com/4nk/sdk_signer:ext` | ✅ | Service de signature |
| **sdk_storage** | 8081 | `git.4nkweb.com/4nk/sdk_storage:ext` | ✅ | Stockage temporaire |
| **lecoffre-back** | 8080 | `git.4nkweb.com/4nk/lecoffre-back-mini:ext` | ✅ | API Backend |
| **lecoffre-front** | 3004 | `git.4nkweb.com/4nk/lecoffre-front:ext` | ✅ | Interface utilisateur |
| **ihm_client** | 3003 | `git.4nkweb.com/4nk/ihm_client:ext` | ✅ | Gestion des clés |
| **watchtower** | - | `containrrr/watchtower` | ✅ | Surveillance automatique |
### Services Externes
| Service | URL | Statut | Description |
|---------|-----|--------|-------------|
| **Bootstrap Relay** | `wss://dev3.4nkweb.com/ws/` | ✅ | Relay externe |
| **Signer Externe** | `ws://dev3.4nkweb.com:9090` | ✅ | Service de signature |
| **Mempool** | `https://mempool2.4nkweb.com` | ✅ | Explorateur Bitcoin Signet |
## 🔄 Flux d'Architecture
### Flux Principal
```
Internet → dev4.4nkweb.com (Nginx) → Services Locaux
├── Frontend: https://dev4.4nkweb.com/lecoffre → lecoffre-front:3004
├── IHM: https://dev4.4nkweb.com/ → ihm_client:3003
├── API: https://dev4.4nkweb.com/api/ → lecoffre-back:8080
└── WebSocket: https://dev4.4nkweb.com/ws/ → sdk_relay:8090
```
### Flux de Redirection
```
local.4nkdev.com → local.4nkweb.com → https://dev4.4nkweb.com/lecoffre
```
## ⚙️ Configuration des Services
### Variables d'Environnement Clés
```bash
# Services externes
VITE_BOOTSTRAPURL=wss://dev4.4nkweb.com/ws/
SIGNER_WS_URL=ws://dev3.4nkweb.com:9090
SIGNER_BASE_URL=https://dev3.4nkweb.com
RELAY_URLS=wss://dev4.4nkweb.com/ws/,wss://dev3.4nkweb.com/ws/
```
### Réseau Docker
- **Réseau** : `btcnet` (bridge) - subnet `172.20.0.0/16`
- **Volumes** : `4nk_node_bitcoin_data`, `blindbit_data`, `sdk_data`
## 🚀 Séquence de Démarrage
### Ordre Optimisé
1. **tor****bitcoin****blindbit****sdk_storage****sdk_relay****sdk_signer****ihm_client****lecoffre-back****lecoffre-front**
### Healthchecks
- **bitcoin** : `bitcoin-cli getblockchaininfo`
- **blindbit** : `curl http://localhost:8000/tweaks/1`
- **sdk_relay** : `curl http://localhost:8091/`
- **lecoffre-back** : `curl http://localhost:8080/api/v1/health`
## 🔧 Monitoring et Surveillance
### Watchtower
- **Mise à jour automatique** des images Docker toutes les 30 secondes
- **Surveillance** de tous les services avec le label `com.centurylinklabs.watchtower.enable=true`
### Commandes de Vérification
```bash
# Statut des services
docker compose ps
# Logs en temps réel
docker compose logs -f
# Vérifier Bitcoin
docker exec bitcoin-signet bitcoin-cli -signet -rpccookiefile=/home/bitcoin/.bitcoin/signet/.cookie getblockchaininfo
# Vérifier l'oracle
curl http://localhost:8000/tweaks/1
```
## 📚 Documentation Associée
- **[`../IA_agents/flux.md`](../IA_agents/flux.md)** - Flux détaillés et architecture
- **[`CONFIGURATION_SERVICES.md`](CONFIGURATION_SERVICES.md)** - Configuration détaillée
- **[`STARTUP_IMPROVEMENTS.md`](STARTUP_IMPROVEMENTS.md)** - Améliorations de démarrage
- **[`REX.md`](REX.md)** - Rapport d'expérience récent
## 🏷️ Historique des Versions
- **21/09/2025** : Déploiement réussi avec toutes les dépendances optimisées
- **21/09/2025** : Correction des imports WASM et compatibilité Alpine
- **21/09/2025** : Mise à jour de la documentation et nettoyage