Files
site-nowyousea/content/ARCHITECTURE-SYSTEME.md

540 lines
33 KiB
Markdown
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# NowYouSea — Architecture Système Complète
*Du rocher au dashboard : description du réseau bout-en-bout*
---
## 1. Vue d'ensemble
```
┌─────────────────────────────────────────────────────────────────┐
│ TERRAIN (Rochers) │
│ │
│ 🪨 Rocher 1 🪨 Rocher 2 🪨 Rocher 3 🪨 Rocher N │
│ Port-Navalo Port Crouesty Île-aux-Moines ... │
│ [Capteurs] [Capteurs] [Capteurs] [Capteurs] │
│ [Edge compute] [Edge compute] [Edge compute] [Edge compute] │
│ [4G modem] [4G modem] [4G modem] [4G modem] │
│ │ │ │ │ │
└───────┼───────────────┼──────────────┼───────────────┼─────────┘
│ │ │ │
▼ ▼ ▼ ▼
┌─────────────────────────────────────────────────────────────────┐
│ RÉSEAU CELLULAIRE 4G/LTE │
│ (Orange, SFR, Bouygues, Free — SIM M2M) │
│ VPN chiffré (WireGuard) │
└───────────────────────────┬─────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────┐
│ INFRASTRUCTURE CLOUD │
│ │
│ ┌──────────────┐ ┌──────────────┐ ┌────────────────────┐ │
│ │ Broker MQTT │ │ Ingestion │ │ Base de données │ │
│ │ (messages) │→ │ Pipeline │→ │ TimescaleDB │ │
│ └──────────────┘ └──────────────┘ └────────────────────┘ │
│ │ │
│ ┌──────────────┐ ┌──────────────┐ │ │
│ │ Traitement │ │ Moteur │ │ │
│ │ acoustique │ │ d'alertes │←─────────┘ │
│ │ (FFT, SPL) │ │ (seuils) │ │
│ └──────────────┘ └──────┬───────┘ │
│ │ │
│ ┌──────────────┐ │ ┌────────────────────┐ │
│ │ API REST / │ │ │ Générateur │ │
│ │ WebSocket │ │ │ rapports DCSMM │ │
│ └──────┬───────┘ │ └────────────────────┘ │
│ │ │ │
└─────────┼─────────────────┼─────────────────────────────────────┘
│ │
▼ ▼
┌─────────────────────────────────────────────────────────────────┐
│ UTILISATEURS FINAUX │
│ │
│ 💻 Dashboard web 📱 App mobile 📧 Alertes SMS/email │
│ (capitainerie) (terrain) (gestionnaire) │
│ │
│ 📊 API publique 📄 Rapports PDF 🔗 Export Quadrige │
│ (chercheurs) (DCSMM) (Ifremer) │
└─────────────────────────────────────────────────────────────────┘
```
---
## 2. Couche 1 — Nœuds terrain (Rochers)
### 2.1 Architecture embarquée d'un rocher
```
┌─ ROCHER ──────────────────────────────────────────────┐
│ │
│ ☀️ Panneau solaire │
│ │ │
│ ▼ │
│ ┌─────────┐ ┌───────────────────────────────┐ │
│ │ MPPT │───→│ Batterie LiFePO4 │ │
│ │ Chargeur│ │ (12V, 20-100Ah selon config) │ │
│ └─────────┘ └───────────┬───────────────────┘ │
│ │ 12V │
│ ┌────────┴────────┐ │
│ ▼ ▼ │
│ ┌──────────┐ ┌──────────────┐ │
│ │ DC-DC 5V │ │ DC-DC 12V │ │
│ └────┬─────┘ └──────┬───────┘ │
│ │ │ │
│ ┌─────────┴───┐ ┌───────┴────────┐ │
│ ▼ ▼ ▼ ▼ │
│ ┌──────────┐ ┌────────┐ ┌─────────┐ ┌────────┐ │
│ │ SBC │ │ Modem │ │ Capteurs│ │ Capteurs│ │
│ │ (RPi/ESP)│ │ 4G │ │ analogiq│ │ numériq │ │
│ │ │ │ │ │ (hydro) │ │ (CTD,..)│ │
│ │ ┌──────┐│ │ ┌────┐ │ └────┬────┘ └───┬─────┘ │
│ │ │ADC ││ │ │SIM │ │ │ │ │
│ │ │24-bit││ │ │M2M │ │ │ RS485/SDI-12 │
│ │ └──┬───┘│ │ └────┘ │ │ │ │
│ │ │ │ └───┬────┘ │ │ │
│ │ │ │ │ │ │ │
│ │ │◄───┼──────┼───────────┘───────────┘ │
│ │ │ │ │ │
│ │ ┌──┴───┐│ │ MQTT/HTTPS │
│ │ │Local ││ │ ▲ │
│ │ │Store ││ │ │ │
│ │ │(SSD) ││ │ ┌─┴──────┐ │
│ │ └──────┘│ │ │Antenne │ 📡 │
│ └─────────┘ │ │4G+GPS │ │
│ │ └────────┘ │
│ │ │
└───────────────────┼────────────────────────────────────┘
▼ Internet 4G
```
### 2.2 Flux de données embarqué
```
Capteurs → Acquisition (ADC/bus) → Pré-traitement edge → Buffer local → Envoi MQTT
┌────┴─────┐
│ FFT temps │ (acoustique : spectre calculé sur le rocher)
│ réel │ → envoie SPL 63/125Hz, pas le WAV brut
└──────────┘
┌────┴─────┐
│ Moyennes │ (physico-chimie : moyenne glissante 1min/10min)
│ glissantes│ → réduit volume données ×100
└──────────┘
```
**Stratégie de bande passante :**
- Acoustique : FFT + SPL calculés sur le rocher → envoi de ~1 Ko/min au lieu de ~10 Mo/min de WAV brut
- Physico-chimie : moyennes 1min → envoi toutes les minutes
- Enregistrement WAV brut en local (SSD) pour récupération manuelle si besoin d'analyse fine
- Mode dégradé si perte réseau : tout est stocké localement, envoi en batch à la reconnexion
### 2.3 Protocoles de communication
| Couche | Protocole | Pourquoi |
|--------|-----------|----------|
| Transport données | **MQTT** (QoS 1) | Léger, bidirectionnel, fait pour IoT, reconnexion auto |
| Sécurité | **TLS 1.3** + certificats client | Chiffrement bout-en-bout |
| Tunnel réseau | **WireGuard VPN** | Léger, rapide, sécurise le canal 4G |
| Config à distance | **MQTT commandes** (topic dédié) | Reconfigurer capteurs, firmware OTA |
| Fallback | **HTTPS POST** | Si MQTT bloqué par opérateur |
| Inter-rochers | **LoRa** (optionnel) | Mesh local si un rocher perd la 4G, relais via un voisin |
---
## 3. Couche 2 — Réseau de transport
### 3.1 Connectivité cellulaire
```
Rocher → SIM M2M multi-opérateur → Internet → VPN → Serveur NowYouSea
```
| Élément | Phase initiale (1-10 rochers) | Scale-up (10-100) | Mass market (100+) |
|---------|-------------------------------|--------------------|--------------------|
| Type SIM | SIM M2M classique (1Nce, Hologram, ou opérateur national) | SIM M2M multi-opérateur avec roaming | eSIM + plateforme de gestion de flotte |
| Opérateur | Orange/SFR selon couverture site | Multi-opérateur avec failover | Contrat-cadre MVNO IoT |
| Data/mois | ~500 Mo/rocher (SPL + physico) | ~500 Mo/rocher | ~500 Mo/rocher |
| Coût SIM | ~3-5€/mois/rocher | ~2-4€/mois (volume) | ~1-2€/mois (volume) |
| Gestion | Manuelle (portail opérateur) | Plateforme IoT (1Nce, Pelion) | Plateforme IoT intégrée |
| Fallback | Aucun | LoRa mesh entre rochers proches | LoRa + satellite LEO (backup) |
### 3.2 Sécurité réseau
```
┌─────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐
│ Rocher │────→│ VPN │────→│ Firewall │────→│ Serveur │
│ (client │ │ WireGuard│ │ (UFW) │ │ MQTT │
│ VPN) │ │ tunnel │ │ │ │ Broker │
└─────────┘ └──────────┘ └──────────┘ └──────────┘
```
- Chaque rocher a une **clé VPN unique** (révocable en cas de vol/compromission)
- Certificats TLS client = authentification mutuelle
- Aucun port ouvert côté rocher (connexion sortante uniquement)
- Monitoring des connexions : alerte si un rocher ne communique plus depuis >1h
---
## 4. Couche 3 — Infrastructure serveur (Cloud/On-premise)
### 4.1 Phase initiale (1-10 rochers) — Serveur unique
```
┌─ SERVEUR UNIQUE (VPS ou bare metal) ────────────────────────┐
│ │
│ OS: Ubuntu Server 24.04 LTS │
│ RAM: 8 Go | CPU: 4 vCPU | SSD: 500 Go │
│ Coût: ~30-50€/mois (Hetzner, OVH, Scaleway) │
│ │
│ ┌────────────────┐ │
│ │ Mosquitto MQTT │ ← Réception données rochers │
│ │ Broker │ (port 8883 TLS) │
│ └───────┬────────┘ │
│ │ │
│ ▼ │
│ ┌────────────────┐ │
│ │ Service │ ← Parsing MQTT → insertion DB │
│ │ Ingestion │ Validation données │
│ │ (Python/Rust) │ Détection anomalies │
│ └───────┬────────┘ │
│ │ │
│ ▼ │
│ ┌────────────────┐ │
│ │ TimescaleDB │ ← Base time-series (extension PostgreSQL) │
│ │ (PostgreSQL) │ Compression auto, rétention configurable│
│ │ │ ~1 Go/rocher/an (données agrégées) │
│ └───────┬────────┘ │
│ │ │
│ ┌────┴────┬──────────┐ │
│ ▼ ▼ ▼ │
│ ┌───────┐ ┌────────┐ ┌──────────┐ │
│ │ API │ │ Moteur │ │ Rapport │ │
│ │ REST │ │ Alertes│ │ DCSMM │ │
│ │ + WS │ │ │ │ (cron) │ │
│ └───┬───┘ └───┬────┘ └──────────┘ │
│ │ │ │
│ │ SMS/email │
│ ▼ ▼ │
│ ┌───────┐ ┌────────┐ │
│ │ Nginx │ │ Twilio │ │
│ │ + │ │ / SMTP │ │
│ │ Front │ │ │ │
│ │ (Vue/ │ └────────┘ │
│ │ React)│ │
│ └───────┘ │
│ │
│ ┌────────────────┐ │
│ │ Grafana │ ← Monitoring interne (santé rochers, │
│ │ + Prometheus │ latence, uptime, batterie, signal 4G) │
│ └────────────────┘ │
│ │
│ Tout en Docker Compose sur 1 serveur │
└──────────────────────────────────────────────────────────────┘
```
**Coût infra Phase initiale : ~50€/mois tout compris**
### 4.2 Scale-up (10-100 rochers) — Architecture distribuée
```
┌─ LOAD BALANCER (Nginx/HAProxy) ─────────────────────────────┐
│ │
│ ┌──────────┬──────────┬──────────┐ │
│ ▼ ▼ ▼ ▼ │
│ ┌──────────┐┌──────────┐┌──────────┐┌──────────┐ │
│ │ MQTT ││ MQTT ││ API ││ API │ │
│ │ Broker 1 ││ Broker 2 ││ Server 1 ││ Server 2 │ │
│ │ (EMQX) ││ (EMQX) ││ ││ │ │
│ └────┬─────┘└────┬─────┘└────┬─────┘└────┬─────┘ │
│ │ │ │ │ │
│ └─────┬─────┘ └─────┬─────┘ │
│ ▼ ▼ │
│ ┌─────────────────┐ ┌─────────────────┐ │
│ │ Apache Kafka │ │ Redis Cache │ │
│ │ (streaming) │ │ (temps réel) │ │
│ └────────┬────────┘ └─────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────┐ │
│ │ TimescaleDB │ ← Cluster avec réplication │
│ │ (Primary + │ Partitionnement par rocher │
│ │ Read replica) │ ~100 Go total pour 100 rochers/an │
│ └─────────────────┘ │
│ │
│ + Kubernetes (K3s) pour orchestration │
│ + Backup automatisé (S3/Glacier) │
│ + CDN pour dashboard (CloudFlare) │
│ │
│ Coût: ~200-500€/mois (cloud managé ou 2-3 serveurs dédiés)│
└──────────────────────────────────────────────────────────────┘
```
### 4.3 Mass market (100+ rochers) — Full cloud
```
┌─ CLOUD MANAGÉ (AWS/GCP/Scaleway) ───────────────────────────┐
│ │
│ IoT Core (AWS IoT / GCP IoT) ← Gestion flotte rochers │
│ │ │
│ ▼ │
│ Streaming (Kinesis/Pub-Sub) → Lambda/Cloud Functions │
│ │ │
│ ▼ │
│ TimescaleDB Cloud / Amazon Timestream │
│ │ │
│ ├──→ API Gateway + serveurs auto-scalés │
│ ├──→ Moteur alertes (serverless) │
│ ├──→ ML Pipeline (détection espèces, anomalies) │
│ └──→ Data Lake (S3) pour WAV bruts et archives │
│ │
│ Coût: ~1 000-3 000€/mois selon usage │
│ Mais: scalable à l'infini, HA automatique, 0 maintenance │
└──────────────────────────────────────────────────────────────┘
```
---
## 5. Couche 4 — Traitement des données
### 5.1 Pipeline de traitement
```
Données brutes → Validation → Traitement → Stockage → Exploitation
(MQTT) (QA/QC) (calcul) (DB) (API/alertes)
Acoustique:
SPL 63Hz, 125Hz → Vérif plage → Lissage, → TimescaleDB → Dashboard SPL
(déjà FFT edge) valide moyenne horaire + archive Alerte seuil
Physico-chimie:
T°, pH, O2, sal → Vérif plage → Moyenne 10min → TimescaleDB → Dashboard
(moyennes 1min) détection interpolation + Quadrige Alerte anomalie
dérive capteur
Métadonnées:
Batterie, signal → — → — → Prometheus → Grafana
GPS, température + alertes monitoring
interne ops
```
### 5.2 Traitement acoustique détaillé
```
SUR LE ROCHER (edge): SUR LE SERVEUR (cloud):
Hydrophone Réception SPL
│ │
▼ ▼
ADC 24-bit Validation (plage, cohérence)
│ │
▼ ▼
Fenêtrage (Hanning) Agrégation temporelle
│ (horaire, journalier, mensuel)
▼ │
FFT 1024/4096 pts ▼
│ Calcul indicateurs DCSMM
▼ D11C2.1 (SPL médian 63Hz)
Extraction bandes: D11C2.2 (SPL médian 125Hz)
- 1/3 octave 63 Hz │
- 1/3 octave 125 Hz ▼
- Broadband SPL Comparaison seuils BEE
│ (Bon État Écologique)
▼ │
Envoi MQTT (~1Ko/min) ▼
│ Rapport annuel DCSMM D11
▼ (PDF auto-généré)
Stockage WAV local
(optionnel, SSD)
→ récupérable pour
analyse fine
(bioacoustique,
détection espèces)
```
### 5.3 Moteur d'alertes
```
┌─────────────────────────────────────────────────────┐
│ MOTEUR D'ALERTES │
│ │
│ Règles configurables par rocher / par client: │
│ │
│ SI SPL_125Hz > seuil_dcsmm PENDANT 30min │
│ → Alerte "Dépassement D11C2.2" → SMS + email │
│ │
│ SI O2_dissous < 4 mg/L │
│ → Alerte "Risque hypoxie" → SMS + email URGENT │
│ │
│ SI turbidité > 50 NTU ET hors marée │
│ → Alerte "Rejet suspect" → email + log │
│ │
│ SI batterie < 20% │
│ → Alerte OPS "Maintenance requise" → dashboard │
│ │
│ SI signal_4G = 0 PENDANT 2h │
│ → Alerte OPS "Rocher hors ligne" → SMS ops │
│ │
│ Canaux de notification: │
│ - SMS (Twilio) : alertes urgentes │
│ - Email (SMTP) : alertes standards + rapports │
│ - Webhook (API) : intégration systèmes tiers │
│ - Push mobile : app NowYouSea │
│ - Dashboard : toutes les alertes │
└─────────────────────────────────────────────────────┘
```
---
## 6. Couche 5 — Interfaces utilisateur
### 6.1 Dashboard web (prioritaire)
```
┌─ DASHBOARD NOWYOUSEA ──────────────────────────────────────┐
│ │
│ 🗺️ Carte interactive │
│ ├─ Position de chaque rocher (marqueurs) │
│ ├─ Code couleur état (vert/orange/rouge) │
│ ├─ Clic = détail du rocher │
│ └─ Zones DCSMM superposées │
│ │
│ 📊 Vue rocher individuel │
│ ├─ Graphiques temps réel (courbes SPL, T°, O2...) │
│ ├─ Historique (1j, 1sem, 1mois, 1an) │
│ ├─ Indicateurs DCSMM (jauge vert/rouge par descripteur) │
│ ├─ État système (batterie, signal, uptime) │
│ └─ Journal des alertes │
│ │
│ 📄 Rapports │
│ ├─ Export CSV/JSON (chercheurs) │
│ ├─ Rapport DCSMM PDF (auto-généré, annuel) │
│ ├─ Export format Quadrige (Ifremer) │
│ └─ Rapport personnalisé (période, paramètres) │
│ │
│ ⚙️ Administration │
│ ├─ Gestion rochers (ajout, config, maintenance) │
│ ├─ Gestion alertes (seuils, destinataires) │
│ ├─ Gestion utilisateurs (rôles : admin, viewer, ops) │
│ └─ Firmware OTA (mise à jour des rochers) │
│ │
│ Tech: Vue.js/React + Leaflet (carte) + Grafana embed │
└─────────────────────────────────────────────────────────────┘
```
### 6.2 API publique
```
GET /api/v1/rocks → Liste des rochers
GET /api/v1/rocks/{id}/data?param=spl_63hz&from=...&to=... → Données
GET /api/v1/rocks/{id}/status → État système
GET /api/v1/rocks/{id}/alerts → Alertes
GET /api/v1/rocks/{id}/report/dcsmm → Rapport DCSMM
POST /api/v1/rocks/{id}/config → Reconfiguration (admin)
WS /api/v1/rocks/{id}/stream → Flux temps réel (WebSocket)
```
---
## 7. Dimensionnement par phase
### Phase initiale : 1-10 rochers (2026)
| Composante | Choix | Coût mensuel |
|-----------|-------|-------------|
| Serveur | 1 VPS (Hetzner CX31 : 4 vCPU, 8 Go RAM, 160 Go SSD) | 15€ |
| Base de données | TimescaleDB sur même serveur | 0€ (inclus) |
| MQTT Broker | Mosquitto sur même serveur | 0€ (inclus) |
| Monitoring | Grafana + Prometheus sur même serveur | 0€ (inclus) |
| Domaine + SSL | nowyousea.fr + Let's Encrypt | 1€ |
| Backup | Stockage objet Scaleway (50 Go) | 2€ |
| SMS alertes | Twilio (~100 SMS/mois) | 5€ |
| SIM M2M (×10) | 10 × 5€ | 50€ |
| **Total infra mensuel** | | **~73€** |
| **Stockage données** | ~10 Go/an total | Confortable |
| **Bande passante** | ~5 Go/mois total | Confortable |
| **Administration** | 1 personne temps partiel | — |
### Scale-up : 10-100 rochers (2027-2028)
| Composante | Choix | Coût mensuel |
|-----------|-------|-------------|
| Serveurs | 2-3 serveurs dédiés (ou K3s cluster) | 100€ |
| Base de données | TimescaleDB dédié + réplica lecture | 50€ |
| MQTT Broker | EMQX cluster (2 nœuds) | Inclus (open-source) |
| Cache | Redis | 15€ |
| Streaming | Apache Kafka (si nécessaire) | Inclus (open-source) |
| CDN | CloudFlare (gratuit/pro) | 0-20€ |
| Backup | Stockage objet (500 Go) | 10€ |
| SMS alertes | ~1000 SMS/mois | 40€ |
| SIM M2M (×100) | 100 × 3€ (volume) | 300€ |
| Monitoring | Grafana Cloud (ou self-hosted) | 0-30€ |
| **Total infra mensuel** | | **~535-565€** |
| **Stockage données** | ~100 Go/an | Confortable |
| **Administration** | 1 personne temps plein (DevOps) | — |
### Mass market : 100+ rochers (2029+)
| Composante | Choix | Coût mensuel |
|-----------|-------|-------------|
| Cloud managé | AWS/GCP/Scaleway | 1 000-3 000€ |
| IoT Platform | AWS IoT Core ou équivalent | Inclus |
| Base de données | TimescaleDB Cloud | 200-500€ |
| Data Lake | S3 (archives WAV, données historiques) | 50-200€ |
| ML Pipeline | Détection espèces, anomalies | 100-300€ |
| SIM M2M (×300) | 300 × 2€ (gros volume) | 600€ |
| **Total infra mensuel** | | **~2 000-4 500€** |
| **Administration** | Équipe 2-3 personnes (DevOps, Data, Support) | — |
---
## 8. Sécurité
| Couche | Mesure |
|--------|--------|
| Rocher → Cloud | VPN WireGuard + TLS 1.3 + certificats client |
| Authentification rocher | Clé unique par appareil, révocable |
| Données stockées | Chiffrement at-rest (LUKS / cloud natif) |
| Dashboard | HTTPS + OAuth2 / OIDC + 2FA |
| API | Token JWT + rate limiting |
| Accès maintenance | SSH clé uniquement, pas de mot de passe |
| Firmware OTA | Signature cryptographique des mises à jour |
| RGPD | Pas de données personnelles collectées (données environnementales = pas RGPD) |
| Gestion incidents | Alertes auto si intrusion / comportement anormal |
---
## 9. Fiabilité & disponibilité
| Mécanisme | Description |
|-----------|-------------|
| Store & forward (rocher) | Si perte réseau, données stockées localement, envoyées à la reconnexion |
| Watchdog hardware | Redémarrage automatique si crash logiciel |
| Watchdog connectivité | Si perte MQTT > 5min, reboot modem 4G |
| Batterie tampon | 3-5 jours sans soleil |
| Mode basse conso | Nuit / hiver : réduction fréquence acquisition |
| Réplication DB | Read-replica (scale-up+) |
| Backup quotidien | Snapshot DB + export S3 |
| SLA cible | 99.5% uptime (données non-critique = quelques heures de gap tolérables) |
---
## 10. Évolutions futures
| Fonctionnalité | Phase | Description |
|----------------|-------|-------------|
| IA embarquée (edge) | 2027+ | Détection cétacés en temps réel sur le rocher (TinyML / Jetson Nano) |
| Réseau LoRa mesh | 2027+ | Rochers proches se relaient mutuellement (résilience) |
| Satellite LEO backup | 2028+ | Starlink IoT / Swarm pour rochers sans couverture 4G |
| Digital Twin | 2028+ | Modèle 3D de chaque site avec données temps réel superposées |
| Open Data | 2027+ | Publication données anonymisées pour la communauté scientifique |
| Intégration Copernicus | 2029+ | Corrélation données satellite (chlorophylle, SST) + données terrain |
| API Quadrige native | 2027 | Export automatique au format Ifremer pour intégration nationale |
---
*Document de travail — NowYouSea Team*
*Version 1 — 10 février 2026*