diff --git a/docs/adr/023-architecture-moderation.md b/docs/adr/023-architecture-moderation.md index 055ed80..9cafc5f 100644 --- a/docs/adr/023-architecture-moderation.md +++ b/docs/adr/023-architecture-moderation.md @@ -28,15 +28,54 @@ Architecture hybride **humain + IA** avec file d'attente intelligente. ### Architecture -**Flux de traitement** : -1. **Client** (App Mobile/Web) → Signalement utilisateur -2. **API Backend** (Fiber) → Endpoint `/moderation/report` -3. **Queue PostgreSQL** → LISTEN/NOTIFY pour dispatch asynchrone -4. **Worker Go** → Goroutine de traitement (transcription + analyse) -5. **IA Self-hosted** → Whisper large-v3 (transcription) + distilbert/roberta (NLP) -6. **Cache Redis** → Sorted Sets pour priorisation temps réel -7. **Dashboard React** → Interface modérateurs avec Wavesurfer.js (player audio) -8. **Stockage** → PostgreSQL (signalements + logs audit) + Redis (cache priorisation) +```mermaid +graph TB + subgraph Client["App Mobile/Web"] + Report["Signalement utilisateur"] + end + + subgraph Backend["Backend Go"] + API["API Fiber
/moderation/report"] + Queue["PostgreSQL Queue
LISTEN/NOTIFY"] + Worker["Worker Go
(transcription + NLP)"] + end + + subgraph AI["IA Self-hosted"] + Whisper["Whisper large-v3
(transcription)"] + NLP["distilbert
(sentiment + haine)"] + end + + subgraph Moderation["Modération Dashboard"] + Dashboard["React Dashboard"] + Player["Wavesurfer.js
(lecture audio)"] + end + + subgraph Storage["Stockage"] + DB["PostgreSQL
(signalements + logs)"] + Redis["Redis
(priorisation + cache)"] + end + + Report --> API + API --> Queue + Queue --> Worker + Worker --> Whisper + Whisper --> NLP + NLP --> Redis + Worker --> DB + Dashboard --> Player + Dashboard --> Redis + Dashboard --> DB + + classDef clientStyle fill:#e3f2fd,stroke:#1565c0 + classDef backendStyle fill:#fff3e0,stroke:#e65100 + classDef aiStyle fill:#f3e5f5,stroke:#6a1b9a + classDef storageStyle fill:#e8f5e9,stroke:#2e7d32 + + class Client,Report clientStyle + class Backend,API,Queue,Worker backendStyle + class AI,Whisper,NLP aiStyle + class Storage,DB,Redis storageStyle +``` ### Workflow de Traitement diff --git a/docs/adr/024-monitoring-observabilite.md b/docs/adr/024-monitoring-observabilite.md index 530d5ac..85c2316 100644 --- a/docs/adr/024-monitoring-observabilite.md +++ b/docs/adr/024-monitoring-observabilite.md @@ -31,27 +31,64 @@ Stack **Prometheus + Grafana + Loki** self-hosted avec alerting multi-canal. ### Architecture -**Services surveillés** : -- Backend Go API (métriques Fiber) -- PostgreSQL (pg_exporter) -- Redis (redis_exporter) -- Zitadel (endpoint metrics) +```mermaid +graph TB + subgraph Services["Services RoadWave"] + API["Backend Go API
(Fiber metrics)"] + DB["PostgreSQL
(pg_exporter)"] + Redis["Redis
(redis_exporter)"] + Zitadel["Zitadel
(metrics endpoint)"] + end -**Stack Monitoring** : -- **Prometheus** : Collecte métriques (scrape), stockage TSDB 15j rétention -- **Grafana** : Visualisation dashboards -- **Loki** : Agrégation logs (chunks compressés, 7j rétention) -- **Alertmanager** : Routing alertes multi-canal -- **Uptime Kuma** : Checks HTTP externes, SSL monitoring + subgraph Monitoring["Stack Monitoring"] + Prom["Prometheus
(scrape + TSDB)"] + Grafana["Grafana
(dashboards)"] + Loki["Loki
(logs aggregation)"] + Alert["Alertmanager
(routing)"] + Uptime["Uptime Kuma
(external checks)"] + end -**Alerting** : -- Email (Brevo) : asynchrone, faible intrusivité -- Webhook (Slack/Discord) : temps réel, on-call + subgraph Notifications["Alerting"] + Email["Email (Brevo)"] + Slack["Webhook Slack/Discord"] + end -**Stockage** : -- Prometheus TSDB : métriques 15j -- Loki chunks : logs 7j -- Backups PostgreSQL : WAL-E continuous vers S3 OVH + subgraph Storage["Stockage"] + PromStorage["Prometheus TSDB
(15j retention)"] + LokiStorage["Loki Chunks
(7j retention)"] + Backups["Backups PostgreSQL
(S3 OVH)"] + end + + API --> Prom + DB --> Prom + Redis --> Prom + Zitadel --> Prom + + API -.->|logs stdout| Loki + Prom --> Grafana + Loki --> Grafana + Prom --> Alert + + Alert --> Email + Alert --> Slack + + Uptime -.->|external HTTP checks| API + Uptime --> Alert + + Prom --> PromStorage + Loki --> LokiStorage + DB -.->|WAL-E continuous| Backups + + classDef serviceStyle fill:#e3f2fd,stroke:#1565c0 + classDef monitoringStyle fill:#fff3e0,stroke:#e65100 + classDef notifStyle fill:#f3e5f5,stroke:#6a1b9a + classDef storageStyle fill:#e8f5e9,stroke:#2e7d32 + + class Services,API,DB,Redis,Zitadel serviceStyle + class Monitoring,Prom,Grafana,Loki,Alert,Uptime monitoringStyle + class Notifications,Email,Slack notifStyle + class Storage,PromStorage,LokiStorage,Backups storageStyle +``` ### Métriques Clés diff --git a/docs/adr/025-securite-secrets.md b/docs/adr/025-securite-secrets.md index d3360de..0bd995b 100644 --- a/docs/adr/025-securite-secrets.md +++ b/docs/adr/025-securite-secrets.md @@ -30,15 +30,55 @@ Stratégie **secrets management + encryption at rest + HTTPS** avec stack self-h ### Architecture Secrets -**Environnements** : -- **Développement** : Fichier .env local (non versionné) -- **Production** : HashiCorp Vault (self-hosted) +```mermaid +graph TB + subgraph Dev["Environnement Dev"] + EnvFile[".env file
(local uniquement)"] + end -**Flux** : -1. **Vault** stocke secrets sensibles (JWT signing key, DB credentials, Mangopay API key, encryption master key) -2. **Backend API** récupère secrets depuis Vault au démarrage -3. **Encryption layer** : AES-256-GCM pour PII, TLS 1.3 pour transport -4. **Stockage** : PostgreSQL (data encrypted at rest), Redis (TLS enabled) + subgraph Prod["Production"] + Vault["HashiCorp Vault
(secrets storage)"] + API["Backend Go API"] + DB["PostgreSQL
(encrypted at rest)"] + Redis["Redis
(TLS enabled)"] + end + + subgraph Encryption["Encryption Layer"] + AES["AES-256-GCM
(PII encryption)"] + TLS["TLS 1.3
(transport)"] + end + + subgraph Secrets["Secrets Stockés"] + JWT["JWT Signing Key
(RS256 private key)"] + DBCreds["DB Credentials
(user/pass)"] + Mangopay["Mangopay API Key
(sandbox + prod)"] + EncKey["Encryption Master Key
(AES-256)"] + end + + EnvFile -.->|dev only| API + Vault --> API + + Vault --- JWT + Vault --- DBCreds + Vault --- Mangopay + Vault --- EncKey + + API --> AES + API --> TLS + AES --> DB + TLS --> DB + TLS --> Redis + + classDef devStyle fill:#fff3e0,stroke:#e65100 + classDef prodStyle fill:#e3f2fd,stroke:#1565c0 + classDef encStyle fill:#f3e5f5,stroke:#6a1b9a + classDef secretStyle fill:#ffebee,stroke:#c62828 + + class Dev,EnvFile devStyle + class Prod,Vault,API,DB,Redis prodStyle + class Encryption,AES,TLS encStyle + class Secrets,JWT,DBCreds,Mangopay,EncKey secretStyle +``` ### Secrets Management avec Vault