ZenLive

Production-ready WebRTC SFU server for live streaming and video conferencing. Built with Go, similar to LiveKit architecture.
Features
- WebRTC SFU - Selective Forwarding Unit for efficient media streaming
- API Key Authentication - Secure token-based room access like LiveKit
- Multi-Protocol - RTMP, HLS, WebRTC support
- Real-time Communication - Video calls, live streaming, screen sharing
- Redis Integration - Horizontal scaling with distributed session management
- Docker Ready - Deploy with Docker or Docker Compose
- Go SDK - Build custom streaming applications
Quick Start
1. Run with Docker
# Pull image
docker pull aminofox/zenlive:latest
# Run server
docker run -d --name zenlive -p 7880:7880 -p 7881:7881 aminofox/zenlive:latest
# Health check
curl http://localhost:7880/api/health
2. Use Docker Compose
git clone https://github.com/aminofox/zenlive.git
cd zenlive
docker-compose up -d
3. Build from Source
# Clone and build
git clone https://github.com/aminofox/zenlive.git
cd zenlive
make server
# Run
./bin/zenlive-server --config config.yaml --dev
SDK Usage
Generate API Keys
package main
import (
"context"
"time"
"github.com/aminofox/zenlive/pkg/auth"
)
func main() {
ctx := context.Background()
store := auth.NewMemoryAPIKeyStore()
manager := auth.NewAPIKeyManager(store)
expiresIn := 365 * 24 * time.Hour
key, _ := manager.GenerateAPIKey(ctx, "My App", &expiresIn, nil)
println("API Key:", key.AccessKey)
println("Secret:", key.SecretKey)
}
Create Room Token
package main
import (
"time"
"github.com/aminofox/zenlive/pkg/auth"
)
func main() {
apiKey := "your-api-key"
secretKey := "your-secret-key"
token, _ := auth.NewAccessTokenBuilder(apiKey, secretKey).
SetIdentity("user123").
SetName("John Doe").
SetRoomJoin("my-room").
SetCanPublish(true).
SetCanSubscribe(true).
SetValidFor(24 * time.Hour).
Build()
println("Room Token:", token)
}
Join Room
package main
import (
"context"
"github.com/aminofox/zenlive/pkg/logger"
"github.com/aminofox/zenlive/pkg/room"
)
func main() {
ctx := context.Background()
log := logger.NewDefaultLogger(logger.InfoLevel, "text")
roomMgr := room.NewRoomManager(log)
token := "your-room-token"
participant, _ := room.JoinRoomWithToken(ctx, "my-room", token, roomMgr, log)
println("Joined room as:", participant.ID)
}
Configuration
Create config.yaml:
server:
host: 0.0.0.0
port: 7880
signaling_port: 7881
dev_mode: false
auth:
jwt_secret: "your-secret-key"
default_api_key: ""
default_secret_key: ""
redis:
enabled: false
address: "localhost:6379"
password: ""
db: 0
webrtc:
stun_servers:
- "stun:stun.l.google.com:19302"
Environment variables:
ZENLIVE_HOST=0.0.0.0
ZENLIVE_PORT=7880
JWT_SECRET=your-secret
REDIS_URL=redis:6379
REDIS_PASSWORD=
Docker Deployment
Standalone
docker run -d \
--name zenlive \
-p 7880:7880 \
-p 7881:7881 \
-e JWT_SECRET=my-secret \
aminofox/zenlive:latest
With Redis
version: '3.8'
services:
zenlive:
image: aminofox/zenlive:latest
ports:
- "7880:7880"
- "7881:7881"
environment:
- JWT_SECRET=${JWT_SECRET}
- REDIS_URL=redis:6379
depends_on:
- redis
redis:
image: redis:7-alpine
ports:
- "6379:6379"
Custom Config
docker run -d \
-v $(pwd)/config.yaml:/app/config.yaml \
-p 7880:7880 \
aminofox/zenlive:latest \
--config /app/config.yaml
Development
Build
# Build SDK packages
make build
# Build server binary
make server
# Build Docker image
make docker
# Run tests
make test
Examples
# API key generation
go run examples/apikey/main.go
# Room authentication
go run examples/room-auth/main.go
# Video call with media
go run examples/video-call-media/main.go
Project Structure
zenlive/
โโโ cmd/
โ โโโ zenlive-server/ # Server binary
โโโ pkg/
โ โโโ api/ # REST API server
โ โโโ auth/ # Authentication & tokens
โ โโโ room/ # Room management
โ โโโ streaming/ # WebRTC, HLS, RTMP
โ โโโ storage/ # Recording & storage
โ โโโ ...
โโโ examples/ # SDK examples
โโโ docs/ # Documentation
โโโ config.yaml # Configuration
Architecture
โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโ
โ Client App โ โ ZenLive Server โ โ Redis โ
โ (Go SDK) โโโโโโโโโโถโ (Docker) โโโโโโโโโโถโ (Cache) โ
โโโโโโโโโโโโโโโโ Token โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโ
โ WebRTC SFU โ
โ (Media Stream) โ
โโโโโโโโโโโโโโโโโโ
Components:
- API Server (port 7880) - HTTP REST API for room management
- WebRTC Signaling (port 7881) - WebSocket for WebRTC negotiation
- Room Manager - Handles video call rooms and participants
- API Key Manager - Authentication with API key/secret pairs
- Redis (optional) - Session management for horizontal scaling
API Endpoints
GET /api/health - Health check
POST /api/keys - Generate API key pair
GET /api/rooms - List rooms
POST /api/tokens - Generate room token (via SDK)
Comparison with LiveKit
| Feature |
ZenLive |
LiveKit |
| WebRTC SFU |
โ
|
โ
|
| API Key Auth |
โ
|
โ
|
| Token-based Access |
โ
|
โ
|
| Docker Deployment |
โ
|
โ
|
| Redis Scaling |
โ
|
โ
|
| Architecture |
Monorepo |
Separate repos |
| Go SDK |
Same repo |
livekit-go |
| JS/Mobile SDKs |
Planned |
โ
|
Note: ZenLive uses a monorepo approach (server + SDK together) for faster development. Can be split into separate repos like LiveKit in the future.
Production Deployment
Security Checklist
- Change
jwt_secret in production
- Generate unique API keys (don't use defaults)
- Enable HTTPS/TLS for API endpoint
- Enable WSS for WebSocket signaling
- Configure TURN servers for NAT traversal
- Set up firewall rules (ports 7880, 7881)
- Enable Redis authentication
- Use environment variables for secrets
Monitoring
Prometheus metrics at http://localhost:9090/metrics:
- Active rooms count
- Participant count
- WebRTC tracks
- API request rate
Publishing Docker Image
# Login
docker login
# Build and tag
make docker
# Push to Docker Hub
make docker-push
# Users can pull
docker pull aminofox/zenlive:latest
Contributing
See docs/CONTRIBUTING.md for development guidelines.
License
MIT License - see LICENSE
Support
โจ Features
Streaming Protocols
- RTMP - Ingest from OBS, FFmpeg, Streamlabs
- HLS - Deliver to web/mobile with adaptive bitrate
- WebRTC - Ultra-low latency (<1s) for video calls
Additional Features
- Real-time Chat - WebSocket chat with moderation
- Recording - Save to local storage or S3
- Analytics - Real-time metrics & Prometheus export
- Authentication - JWT & role-based access control
- Scalable - Horizontal scaling with Redis
๐ฆ Use Cases
| Use Case |
Protocols |
Config |
| Live Streaming Platform |
RTMP + HLS |
Example |
| Video Call (1-1) |
WebRTC |
Example |
| Video Conference |
WebRTC + Chat |
Example |
| Recording Server |
RTMP + HLS + Storage |
Example |
๐ฏ SDK Philosophy
ZenLive focuses on REAL-TIME DELIVERY - not data persistence.
โ
SDK Does:
- Real-time streaming (RTMP, HLS, WebRTC)
- Real-time chat delivery
- Session management
- Recording to local/S3
โ SDK Does NOT:
- Database persistence (you handle this)
- Chat history storage (you save to your DB)
- User account management (your responsibility)
๐ก Your Responsibility: The SDK delivers real-time. YOU decide what to save to YOUR database.
๐ Documentation
๐ป Examples
# Basic streaming server
cd examples/basic && go run main.go
# With authentication
cd examples/auth && go run main.go
# WebRTC video call
cd examples/webrtc && go run main.go
# With chat
cd examples/chat && go run main.go
# With recording
cd examples/storage && go run main.go
See examples/ for all 11+ examples.
๐ง Configuration
Simple (Development)
cfg := config.DefaultConfig()
cfg.Streaming.EnableRTMP = true
cfg.Streaming.EnableHLS = true
With Chat
cfg.Chat.Enabled = true
// Save chat to YOUR database
chatServer.OnMessage(func(msg *chat.Message) {
myDB.SaveMessage(msg) // Your code
})
Production
cfg := config.DefaultConfig()
cfg.Auth.JWTSecret = os.Getenv("JWT_SECRET")
cfg.Storage.Type = "s3"
cfg.Analytics.Enabled = true
Multi-Server (Cluster)
cfg.Cluster.Enabled = true
cfg.Redis.Enabled = true // Required for cluster
๐๏ธ Architecture
Publishers (OBS/FFmpeg)
โ RTMP
ZenLive SDK
โโโ RTMP Server
โโโ HLS Server
โโโ WebRTC Server
โโโ Chat Server
โโโ Storage
โ
Viewers (Web/Mobile)
See ARCHITECTURE.md for details.
| Metric |
Single Server |
Cluster (3 nodes) |
| Concurrent Streams |
~1,000 |
~10,000+ |
| Concurrent Viewers |
~10,000 |
~100,000+ |
| Latency (HLS) |
10-30s |
10-30s |
| Latency (WebRTC) |
<1s |
<1s |
๐ Security
- JWT authentication
- Role-based access control (RBAC)
- TLS/HTTPS encryption
- Rate limiting
- Stream key rotation
- Audit logging
๐ค Contributing
Contributions are welcome! Please read our Contributing Guide.
๐ License
MIT License - see LICENSE file.
๐ Support
๐ Star Us!
If you find ZenLive useful, please give us a star! โญ
Made with โค๏ธ by the ZenLive Team
- Viewer analytics and session tracking
- Prometheus metrics export
- Health check endpoints
- Performance monitoring
- Config: Set
Analytics.Enabled = false to disable
๐จ Interactive Features (Optional)
- Live polling (single/multiple choice)
- Virtual gifts and currency system
- Real-time reactions and emojis
- Co-streaming support
โก Scalability (Optional - for distributed deployments)
- Horizontal scaling with load balancing
- Distributed session management (requires Redis)
- Service discovery
- CDN integration
- Config: Set
Cluster.Enabled = true and Redis.Enabled = true to enable
๐ฏ Use Cases
โ
Perfect For
-
Livestreaming Platforms (Twitch-like, YouTube Live)
- RTMP ingestion from OBS/StreamLabs
- HLS playback for viewers
- Real-time chat and interactions
-
Video Conferencing (Zoom-like, Google Meet)
- WebRTC peer-to-peer connections
- Low latency (<500ms)
- Optional recording
-
Audio Calling (Discord-like voice channels)
- WebRTC audio-only streams
- Group voice channels
-
Hybrid Platforms
- Combine streaming + video calls
- Switch between protocols dynamically
โ๏ธ Flexible Configuration
Simple Single-Server Livestream:
cfg := config.DefaultConfig()
cfg.Streaming.EnableRTMP = true
cfg.Streaming.EnableHLS = true
cfg.Chat.Enabled = true
cfg.Analytics.Enabled = false // Disable analytics
cfg.Cluster.Enabled = false // Single server
Video Call Only:
cfg := config.DefaultConfig()
cfg.Streaming.EnableRTMP = false
cfg.Streaming.EnableHLS = false
cfg.Streaming.EnableWebRTC = true
cfg.Chat.Enabled = false // Not needed for 1-1 calls
Production Multi-Server:
cfg := config.DefaultConfig()
cfg.Cluster.Enabled = true
cfg.Redis.Enabled = true // For distributed sessions
cfg.Analytics.Enabled = true
cfg.Storage.Type = "s3"
๐ See examples/config/ for complete configuration examples.
๐ Documentation
๐ก Usage Examples
RTMP Streaming Server
package main
import (
"github.com/aminofox/zenlive/pkg/logger"
"github.com/aminofox/zenlive/pkg/streaming/rtmp"
)
func main() {
log := logger.NewDefaultLogger(logger.InfoLevel, "text")
server := rtmp.NewServer(":1935", log)
server.SetOnPublish(func(streamKey string, metadata map[string]interface{}) error {
log.Info("Stream started", logger.String("key", streamKey))
return nil
})
server.Start()
}
Publish with OBS: rtmp://localhost:1935/live/your-stream-key
WebRTC Low-Latency Streaming
package main
import (
"github.com/aminofox/zenlive/pkg/logger"
"github.com/aminofox/zenlive/pkg/streaming/webrtc"
)
func main() {
log := logger.NewDefaultLogger(logger.InfoLevel, "json")
sfuConfig := webrtc.DefaultSFUConfig()
sfu, _ := webrtc.NewSFU(sfuConfig, log)
signalingConfig := webrtc.DefaultSignalingServerConfig()
signalingConfig.Address = ":8081"
server, _ := webrtc.NewSignalingServer(signalingConfig, sfu, log)
server.Start()
}
Stream Management
package main
import (
"context"
"github.com/aminofox/zenlive/pkg/sdk"
"github.com/aminofox/zenlive/pkg/logger"
)
func main() {
log := logger.NewDefaultLogger(logger.InfoLevel, "text")
manager := sdk.NewStreamManager(log)
ctx := context.Background()
// Create a stream
stream, _ := manager.CreateStream(ctx, &sdk.CreateStreamRequest{
UserID: "user-123",
Title: "My Gaming Stream",
Description: "Playing Minecraft",
Protocol: sdk.ProtocolRTMP,
})
// Start stream
controller := sdk.NewStreamController(manager, nil, log)
controller.StartStream(ctx, stream.ID)
// Get popular streams
popular, _ := manager.GetPopularStreams(ctx, 10)
}
Real-time Chat
package main
import (
"github.com/aminofox/zenlive/pkg/chat"
"github.com/aminofox/zenlive/pkg/logger"
)
func main() {
log := logger.NewDefaultLogger(logger.InfoLevel, "text")
// SDK only handles real-time delivery
// Users handle their own message persistence
server := chat.NewServer(chat.DefaultServerConfig(), log)
// Create chat room for stream
room, _ := server.CreateRoom(ctx, "stream-123", "My Stream Chat")
// Setup WebSocket endpoint
http.HandleFunc("/ws", server.HandleWebSocket)
http.ListenAndServe(":8080", nil)
}
More examples in examples/ directory (11 complete examples)
๐๏ธ Architecture
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Your Application โ
โ (import github.com/aminofox/zenlive) โ
โโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโผโโโโโโโโโ
โ ZenLive SDK โ
โโโโโโโโโโฌโโโโโโโโโ
โ
โโโโโโโโโโโโโดโโโโโโโโโโโโ
โ โ
โโโโโผโโโโโ โโโโโโโโผโโโโโโโ
โStreamingโ โ Features โ
โProtocolsโ โ โ
โโโโโโโโโโค โโโโโโโโโโโโโโโค
โ RTMP โ โ Chat โ
โ HLS โ โ Recording โ
โ WebRTC โ โ Analytics โ
โโโโโโโโโโ โ Auth โ
โ Security โ
โโโโโโโโโโโโโโโ
ZenLive is a library/SDK - you import it into your Go application. It's not a standalone service.
๐งช Testing
# Run all tests
go test ./...
# Run with coverage
go test -cover ./...
# Run specific package tests
go test ./pkg/streaming/rtmp/...
# Run benchmarks
go test -bench=. ./tests/performance/...
Test Coverage: 85%+ across all packages
- RTMP: 1000+ concurrent publishers
- HLS: 10,000+ concurrent viewers per node
- WebRTC: Sub-second latency (200-500ms)
- Chat: 10,000+ messages/second per room
- Horizontal Scaling: Tested up to 10 nodes
๐ ๏ธ Development
# Clone repository
git clone https://github.com/aminofox/zenlive.git
cd zenlive
# Install dependencies
go mod download
# Run tests
go test ./...
# Build examples
go build -o bin/basic ./examples/basic
๐ Requirements
- Go: 1.24.0 or later
- Optional: Redis (for distributed sessions), S3-compatible storage (for cloud recording)
๐บ๏ธ Roadmap
โ
v1.0.0 (Current - January 2026)
- Multi-protocol streaming (RTMP, HLS, WebRTC)
- Real-time chat
- Recording & storage
- Authentication & security
- Analytics & monitoring
- Interactive features
๐ฎ Future Versions
- v1.1.0: Enhanced WebRTC (simulcast, SVC)
- v1.2.0: AI-powered analytics and insights
- v1.3.0: Multi-region deployment
- v2.0.0: GraphQL API, gRPC support
๐ค Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature)
- Commit your changes (
git commit -m 'Add amazing feature')
- Push to the branch (
git push origin feature/amazing-feature)
- Open a Pull Request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
Built with โค๏ธ for the livestreaming community.
Special thanks to:
Current Version: v1.0.0
Release Date: January 11, 2026
Status: โ
Production Ready
Get Started: go get github.com/aminofox/[email protected]