How miroslavpejic85/mirotalksfu works
Project Type and Purpose
• MiroTalk SFU is a full-stack, self-hosted, real-time video conferencing system built on Node.js and Mediasoup (Selective Forwarding Unit).
• It provides a PWA frontend, REST/Swagger API layer, WebSocket/WebRTC media routing, RTMP streaming support, and integrations (Slack, Discord, Mattermost, Sentry, Recall.ai, OpenAI).
File Structure Highlights
• app/ – Core Node.js monolith:
• app/src/ – SFU logic (Server.js, Peer, Room, RtmpStreamer, etc.), middleware, config.
• app/api/ – REST endpoints (join, meeting, stats, token) implemented in JS/PHP/Python/Sh.
• app/ssl/ – SSL certs for HTTPS.
• public/ – Static assets: HTML views, JS client code, CSS, images, sounds, SFU client libs (Mediasoup).
• cloud/ – Supplemental Node.js server for “cloud” assets or functions.
• rtmpServers/ – Standalone RTMP server demos & Docker recipes (nginx-rtmp, node-media-server).
• webhook/ – Microservice to emit meeting events to external webhooks.
• widgets/ – Embeddable support widgets for third-party sites.
• docker-compose.template.yml, Dockerfile, webpack.config.js – Containerization & build.
• tests/ – Unit tests for core modules (Validator, XSS, ServerAPI).
1. Clients (Browser/Mobile PWA)
• Components: UI (public/views + public/js/C \
• Protocols: HTTPS for UI & REST, WebSocket for signaling, WebRTC for media
2. Load Balancer / SSL Terminator
• Optional: Nginx, HAProxy, or cloud LB
3. Node.js Application Server
• HTTP REST API (app/api)
• Static file server (public/)
• WebSocket signaling + Mediasoup worker management (app/src/Server.js)
• Business logic: Room, Peer, JWT Auth, Host Protection
4. Mediasoup SFU Worker Processes
• Media routing: publishes/subscribes video/audio between peers
5. RTMP Streaming Subsystem
• In-process: RtmpStreamer, RtmpFile (app/src)
• Optional external containers: nginx-rtmp, node-media-server (rtmpServers/)
6. Webhook Service
• Emits meeting events (join/leave/record) to external URLs (webhook/server.js)
7. Cloud Functions / Asset Server
• Optional: cloud/server.js for telco-level scaling or CDN integration
8. External Services
• Recall.ai (recording API)
• OpenAI / ChatGPT
• Slack / Discord / Mattermost integrations
• Sentry (error tracking)
• S3 (optional recording storage)
• Client → LB → Node.js: HTTPS GET/POST for UI & REST
• Client ↔ Node.js: WebSocket for signaling (SDP/ICE)
• Node.js ↔ Mediasoup Worker: media negotiation and pipe lines
• Node.js → RTMP Engines: push RTMP streams (OBS compatibility)
• Node.js → Webhook Service: HTTP callbacks on events
• Node.js → External Integrations: REST calls to Recall.ai, Slack, Discord, Sentry
• Node.js ↔ Optional Cloud Asset Server: asset upload/download and SSR endpoints
c. Architectural Patterns & Principles
• Modular Monolith: single codebase split into transport (app/src), API (app/api), UI (public)
• Event-Driven: signaling events trigger media routing & webhooks
• Separation of Concerns: static hosting vs. dynamic API vs. media routing
• Containerization: Docker + docker-compose for reproducible deployments
d. Key Technologies & Libraries
• Node.js v22+, Express (HTTP + WebSocket), Mediasoup SFU, FFmpeg (recording), nginx-rtmp/node-media-server, PWA client, JWT, OpenID Connect.
Detail Level
• Cross-cutting concerns: SSL termination, config (.env), Docker orchestration.