refactor(adr-023/024/025): retirer exemples de code et scripts
Suppression de tous les exemples de code pour garder uniquement les descriptions techniques : ADR-023 (Architecture Modération) : - Diagramme Mermaid → description flux textuelle - Exemples SQL/Redis → description workflow - Interface Go → description abstraction - Dépendances → liste concise ADR-024 (Monitoring et Observabilité) : - Diagramme Mermaid → architecture textuelle - Exemples PromQL → description métriques - Config YAML alertes → liste alertes avec seuils - Commandes bash WAL-E → description backup - Runbooks → étapes sans commandes ADR-025 (Sécurité et Secrets) : - Diagramme Mermaid → flux secrets textuel - Commandes bash Vault → description process - Code Go encryption → architecture encryption - Schéma SQL → contraintes textuelles - Config Nginx → configuration TLS - Code Go rate limiting → paramètres middleware ADR restent 100% techniques et complets sans code concret. Cohérence avec ADR-022 (même approche). Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -28,79 +28,35 @@ Architecture hybride **humain + IA** avec file d'attente intelligente.
|
||||
|
||||
### Architecture
|
||||
|
||||
```mermaid
|
||||
graph TB
|
||||
subgraph Client["App Mobile/Web"]
|
||||
Report["Signalement utilisateur"]
|
||||
end
|
||||
|
||||
subgraph Backend["Backend Go"]
|
||||
API["API Fiber<br/>/moderation/report"]
|
||||
Queue["PostgreSQL Queue<br/>LISTEN/NOTIFY"]
|
||||
Worker["Worker Go<br/>(transcription + NLP)"]
|
||||
end
|
||||
|
||||
subgraph AI["IA Self-hosted"]
|
||||
Whisper["Whisper large-v3<br/>(transcription)"]
|
||||
NLP["distilbert<br/>(sentiment + haine)"]
|
||||
end
|
||||
|
||||
subgraph Moderation["Modération Dashboard"]
|
||||
Dashboard["React Dashboard"]
|
||||
Player["Wavesurfer.js<br/>(lecture audio)"]
|
||||
end
|
||||
|
||||
subgraph Storage["Stockage"]
|
||||
DB["PostgreSQL<br/>(signalements + logs)"]
|
||||
Redis["Redis<br/>(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
|
||||
```
|
||||
**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)
|
||||
|
||||
### Workflow de Traitement
|
||||
|
||||
1. **Réception signalement** :
|
||||
```sql
|
||||
INSERT INTO moderation_reports (content_id, user_id, category, comment)
|
||||
VALUES ($1, $2, $3, $4)
|
||||
RETURNING id;
|
||||
|
||||
NOTIFY moderation_queue, 'report_id:{id}';
|
||||
```
|
||||
- Insertion en base PostgreSQL (table `moderation_reports`)
|
||||
- Notification asynchrone via PostgreSQL NOTIFY
|
||||
|
||||
2. **Worker asynchrone** (goroutine) :
|
||||
- Écoute `LISTEN moderation_queue`
|
||||
- Télécharge audio depuis stockage S3/local
|
||||
- Transcription Whisper (1-10 min selon durée)
|
||||
- Analyse NLP : score confiance 0-100%
|
||||
- Calcul priorité : `(score_IA × 0.7) + (nb_signalements × 0.2) + (fiabilité_signaleur × 0.1)`
|
||||
- Insertion Redis Sorted Set : `ZADD moderation:priority {priority} {report_id}`
|
||||
- Écoute queue PostgreSQL (LISTEN/NOTIFY)
|
||||
- Téléchargement audio depuis stockage S3/local
|
||||
- Transcription audio via Whisper large-v3 (1-10 min selon durée)
|
||||
- Analyse NLP : score confiance 0-100% (distilbert + roberta)
|
||||
- Calcul priorité selon formule : `(score_IA × 0.7) + (nb_signalements × 0.2) + (fiabilité_signaleur × 0.1)`
|
||||
- Insertion dans Redis Sorted Set pour priorisation
|
||||
|
||||
3. **Dashboard modérateurs** :
|
||||
- Poll Redis Sorted Set : `ZREVRANGE moderation:priority 0 19` (top 20)
|
||||
- Affichage liste priorisée avec transcription, waveform, historique créateur
|
||||
- Actions : Approuver, Rejeter, Escalade (shortcuts clavier A/R/E)
|
||||
- Logs audit PostgreSQL (conformité DSA)
|
||||
- Récupération signalements priorisés depuis Redis (top 20 par page)
|
||||
- Affichage : transcription, waveform audio, historique créateur
|
||||
- Actions disponibles : Approuver, Rejeter, Escalade (shortcuts clavier A/R/E)
|
||||
- Logs audit PostgreSQL pour traçabilité (conformité DSA)
|
||||
|
||||
## Alternatives considérées
|
||||
|
||||
@@ -136,14 +92,7 @@ graph TB
|
||||
|
||||
- **Performance MVP** : Suffisant jusqu'à 1000 signalements/jour (~0.7/min)
|
||||
- **Simplicité** : Pas de broker externe, transactions ACID
|
||||
- **Migration facile** : Abstraction interface `ModerationQueue` → swap vers Redis Streams si besoin
|
||||
|
||||
```go
|
||||
type ModerationQueue interface {
|
||||
Enqueue(ctx context.Context, reportID int64) error
|
||||
Listen(ctx context.Context) (<-chan int64, error)
|
||||
}
|
||||
```
|
||||
- **Migration facile** : Abstraction via interface `ModerationQueue` → swap vers Redis Streams si besoin (méthodes : Enqueue, Listen)
|
||||
|
||||
### Whisper large-v3 self-hosted
|
||||
|
||||
@@ -176,24 +125,16 @@ type ModerationQueue interface {
|
||||
|
||||
### Dépendances
|
||||
|
||||
```go
|
||||
// backend/go.mod
|
||||
require (
|
||||
github.com/gofiber/fiber/v3 latest // API Dashboard
|
||||
github.com/jackc/pgx/v5 latest // PostgreSQL + LISTEN/NOTIFY
|
||||
github.com/redis/rueidis latest // Cache priorisation
|
||||
// Whisper via Python subprocess ou go-whisper bindings
|
||||
)
|
||||
```
|
||||
**Backend Go** :
|
||||
- `gofiber/fiber/v3` : API Dashboard
|
||||
- `jackc/pgx/v5` : PostgreSQL + LISTEN/NOTIFY
|
||||
- `redis/rueidis` : Cache priorisation
|
||||
- Whisper : via Python subprocess ou go-whisper bindings
|
||||
|
||||
**Frontend Dashboard** :
|
||||
```json
|
||||
{
|
||||
"react": "^18.3.0",
|
||||
"@tanstack/react-table": "^8.10.0",
|
||||
"wavesurfer.js": "^7.0.0"
|
||||
}
|
||||
```
|
||||
- `react` : Framework UI
|
||||
- `@tanstack/react-table` : Tables performantes
|
||||
- `wavesurfer.js` : Player audio avec waveform
|
||||
|
||||
## Métriques de Succès
|
||||
|
||||
|
||||
Reference in New Issue
Block a user