FluxyChat

Features

FluxyStream — Live Streaming & Broadcast

> ROADMAP 3.3 — Interactive streaming $42.36B (2025) → $147.11B (2030), CAGR 28.2%

Panoramica

FluxyStream è il modulo di live broadcasting integrato in FluxyChat. Combina video streaming WebRTC/RTMP → Cloudflare Stream → HLS, chat in tempo reale, moderazione AI, e feature interattive per il pubblico.

Architettura

OBS / WebRTC camera → Cloudflare Stream (RTMP/WHIP ingest) → HLS adaptive bitrate

                    Cloudflare D1 (metadata, chat, viewers)

                    Next.js Dashboard (viewer + broadcaster UI)

                    FluxyChat SDK (interactive features)

File principali

FileDescrizione
apps/dashboard/app/stream/page.tsxLista eventi live (live now + all streams)
apps/dashboard/app/stream/[eventId]/page.tsxViewer: video player + chat + raise hand
apps/dashboard/app/stream/[eventId]/broadcast/page.tsxBroadcaster: camera preview, RTMP ingest, go live/end
apps/dashboard/app/stream/demo/page.tsxDemo interattiva con tutte le feature SDK
apps/dashboard/components/stream/create-stream-dialog.tsxModal creazione evento
apps/dashboard/components/stream/stream-player.tsxPlayer HLS con controlli (mute, fullscreen)
apps/worker/src/routes/live-streaming-http.jsRoute API: CRUD eventi, provision, join/leave, chat, analytics, angles, highlights, products, gifts, sentiment, TURN
apps/worker/src/lib/live-streaming.jsLogica DB: eventi, chat rules, viewers, messaggi, analytics
apps/worker/src/lib/cloudflare-stream.jsIntegrazione Cloudflare Stream API (live inputs)
apps/worker/db/0089_live_events.sqlSchema originale tabella live_events
apps/worker/db/0134_live_streaming_chat.sqlSchema chat rules, viewers, messages, analytics
apps/worker/db/0154_fluxy_stream.sqlALTER TABLE: colonne Cloudflare Stream + tabelle angles/highlights/products/gifts/sentiment
apps/worker/db/0155_fluxy_stream_reconcile.sqlMigrazione riconciliazione idempotente
packages/sdk/src/fluxy-stream.tsSDK module: tutte le feature interattive in-memory

Feature implementate

Feature base (ROADMAP)

FeatureStatoNote
Live video broadcastWebRTC → Cloudflare Stream → HLS
Chat overlayFluxyChat room integrata nel player
Viewer countD1 counter + polling API
AI moderationcreateModerationEngine con DLP patterns
Polls/quizzescreatePoll() / votePoll() SDK + API
Tipping/donationsVirtual gifts + Stripe integration (esistente)
Recording + VODCloudflare Stream recording mode
Multi-camera switchingaddAngle() / setActiveAngle() SDK + API
RTMP ingestOBS → RTMP → Cloudflare Stream
Adaptive bitrateHLS multi-resolution (Cloudflare Stream)
DVR/rewind liveHLS DVR (Cloudflare Stream)
Analytics (viewership)D1 + recordAnalyticsBucket() / getEventAnalytics()
TURN server/api/live/turn-credentials — Coturn REST + Metered.ca

Feature innovative (ROADMAP)

FeatureStatoDemo
Stream as a RoomViewer = partecipante con avatar, raise hand, promozioni ruolo
AI-generated highlightsAuto-detection da sentiment spike + gift burst
Real-time sentiment dashboardGrafico sentiment in tempo reale con barre positive/negative
Interactive storytellingVoting branching narrative con barre progresso
Virtual gifts with physics5 gift types con animazioni (fall, burst, float, rain)
Multi-angle viewer choiceSwitch camera angles in real time
AI co-hostAgent risponde a domande, modera chat, genera highlights
Live commerce integrationProduct catalog + "Buy Now" overlay sincronizzato
GamificationXP, badges, leaderboard per viewer attivi

API endpoints

Eventi

  • POST /api/live/events — Crea evento
  • GET /api/live/events — Lista eventi
  • GET /api/live/events/:id — Dettaglio evento
  • PATCH /api/live/events/:id — Aggiorna evento (status, title, etc.)
  • GET /api/live/stats — Stats globali

Cloudflare Stream

  • POST /api/live/events/:id/provision — Crea live input (RTMP/WHIP)
  • DELETE /api/live/events/:id/input — Elimina live input

Viewer

  • POST /api/live/events/:id/join — Join (propaga auth.userId)
  • POST /api/live/events/:id/leave — Leave
  • GET /api/live/events/:id/viewers — Lista viewer attivi
  • GET /api/live/events/:id/viewer-count — Count viewer attivi
  • GET /api/live/events/:id/peak — Peak viewers
  • POST /api/live/events/:id/peak — Aggiorna peak
  • POST /api/live/events/:id/ban — Banna viewer
  • POST /api/live/events/:id/mute — Mute/unmute viewer

Chat

  • POST /api/live/events/:id/messages — Invia messaggio
  • GET /api/live/events/:id/messages — Lista messaggi
  • POST /api/live/events/:id/rules — Upsert chat rules
  • GET /api/live/events/:id/rules — Get chat rules

Pinning

  • POST /api/live/events/:id/pin — Pin messaggio
  • POST /api/live/events/:id/unpin — Unpin
  • GET /api/live/events/:id/pinned — Lista pinned

Analytics

  • POST /api/live/events/:id/analytics — Registra bucket
  • GET /api/live/events/:id/analytics — Query analytics

Multi-angle

  • GET /api/live/events/:id/angles — Lista camera angles
  • POST /api/live/events/:id/angles — Aggiungi angle

Highlights

  • GET /api/live/events/:id/highlights — Lista highlights
  • POST /api/live/events/:id/highlights — Crea highlight

Live Commerce

  • GET /api/live/events/:id/products — Lista prodotti
  • POST /api/live/events/:id/products — Aggiungi prodotto

Gifts

  • GET /api/live/events/:id/gifts — Lista gifts inviati
  • POST /api/live/events/:id/gifts — Invia gift

Sentiment

  • GET /api/live/events/:id/sentiment — Query sentiment data

WebRTC

  • GET /api/live/turn-credentials — Credenziali TURN ephemeral (TTL 1h)

Configurazione

Variabili ambiente Worker

# Cloudflare Stream
CLOUDFLARE_ACCOUNT_ID=your_account_id
CLOUDFLARE_STREAM_API_TOKEN=your_api_token
CLOUDFLARE_STREAM_CUSTOMER_CODE=your_customer_code

# TURN relay (opzionale per dev, obbligatorio per produzione WebRTC)
TURN_SECRET=your_hmac_secret          # Coturn REST API pattern
TURN_SERVERS=turn:turn.example.com:3478,turns:turn.example.com:5349
# OR
TURN_API_URL=https://api.metered.live/api/turn  # Metered.ca
TURN_API_KEY=your_metered_api_key

Come modificare

Aggiungere un nuovo gift type

Modifica l'array giftsCatalog in packages/sdk/src/fluxy-stream.ts:

{ id: "g_new", type: "new", label: "New Gift", iconEmoji: "🎁", price: 1000, currency: "usd", animation: "burst", color: "#ff00ff" }

Cambiare colori degli status

Modifica statusColor() in apps/dashboard/app/stream/page.tsx.

Aggiungere una camera angle predefinita

Chiama stream.addAngle(label, streamUrl, isDefault) nel seed di stream/demo/page.tsx.

Cambiare il TURN provider

Imposta TURN_SECRET + TURN_SERVERS per Coturn, oppure TURN_API_URL + TURN_API_KEY per Metered.ca.

On this page