# Modèle de données - Premium 📖 Voir [Règles métier - Section 17 : Premium](../rules/premium.md) | [Entités globales](../../_shared/entities/modele-global.md) ## Diagramme ```mermaid erDiagram PREMIUM_SUBSCRIPTIONS }o--|| USERS : "abonnement" ACTIVE_STREAMS }o--|| USERS : "stream actif" ACTIVE_STREAMS }o--|| CONTENTS : "écoute" OFFLINE_DOWNLOADS }o--|| USERS : "téléchargé par" OFFLINE_DOWNLOADS }o--|| CONTENTS : "contenu" PREMIUM_SUBSCRIPTIONS { uuid id PK uuid user_id FK UK string provider string provider_subscription_id string provider_user_id string status string plan timestamp current_period_start timestamp current_period_end timestamp cancelled_at timestamp created_at } ACTIVE_STREAMS { uuid id PK uuid user_id FK UK uuid content_id FK string device_id string mode int last_position_seconds timestamp started_at timestamp last_heartbeat } OFFLINE_DOWNLOADS { uuid id PK uuid user_id FK uuid content_id FK string quality int file_size_bytes timestamp downloaded_at timestamp expires_at } ``` ## Légende **Entités Premium** : - **PREMIUM_SUBSCRIPTIONS** : Abonnements Premium - Provider : `mangopay` (web 4.99€), `apple` (IAP 5.99€), `google` (Play 5.99€) - Status : `active`, `cancelled`, `expired`, `past_due` - Plan : `monthly` (4.99€), `yearly` (49.99€ = 2 mois offerts) - Pas d'essai gratuit - Vérification temps réel via Redis cache (TTL 1h) + webhooks providers - **ACTIVE_STREAMS** : Streams actifs multi-devices - Limite 1 stream actif par compte (dernier device prioritaire KISS) - Mode : `online`, `offline` (si offline + WiFi/4G) - Heartbeat 30s, TTL Redis 5 min - Détection simultanée : WebSocket close device précédent - Exception : offline mode avion (pas de détection possible) - **OFFLINE_DOWNLOADS** : Téléchargements offline - Quality : `low` (24 kbps), `standard` (48 kbps), `high` (64 kbps Premium only) - Limite gratuit : 50 contenus max, Premium : illimité (espace disque) - Validité 30j, renouvellement auto si WiFi - Suppression auto après expiration