A production-grade real-time stranger video chat platform built with WebRTC and Socket.IO
Live Demo β’ Report Bug β’ Request Feature
|
Crystal-clear WebRTC peer-to-peer streaming with automatic quality adjustment Instant messaging alongside video with typing indicators and message history Intelligent stranger pairing system with instant connections |
Don't like your match? Skip instantly and connect with someone new End-to-end encrypted connections with WSS and SSL/TLS Seamless experience across desktop, tablet, and mobile devices |
Unlike other video chat platforms, PairUp is:
- β Open Source - Transparent, auditable, and community-driven
- β Self-Hostable - Complete control over your data and infrastructure
- β Production Ready - Battle-tested with proper NAT traversal using TURN servers
- β Optimized - Low latency P2P connections with minimal server relay
- β Modern Stack - Built with cutting-edge technologies (React, TypeScript, Bun)
|
|
|
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Client Browser β
β (React App + WebRTC Media Handler) β
ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββ
β
β HTTPS + WSS (Secure WebSocket)
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β NGINX Reverse Proxy β
β SSL Termination + WebSocket Upgrade β
ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββ
β
β HTTP + WebSocket (Internal)
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Socket.IO Signaling Server β
β (Bun Runtime) β
β β’ Matchmaking Logic β’ Room Management β
β β’ WebRTC Signaling β’ Message Relay β
ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββ
β
β WebRTC Signaling (Offer/Answer/ICE)
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β TURN/STUN Servers β
β (NAT Traversal & Relay) β
ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββ
β Peer-to-Peer β
β Media Stream β
β (Video + Audio) β
ββββββββββββββββββββββββ
- Client connects to signaling server via WSS
- Server matches two waiting clients and creates a room
- WebRTC negotiation happens (SDP offer/answer exchange)
- ICE candidates are exchanged for NAT traversal
- P2P connection established (with TURN relay as fallback)
- Media streams flow directly between peers
- Chat messages relayed through signaling server
- Bun >= 1.0.0 (Install Bun)
- Node.js >= 18.0.0 (for frontend tooling)
- Google Cloud Account (for production deployment)
- Domain name (optional, for SSL)
git clone https://github.com/prudh-vi/pairup-server.git
cd pairup-server# Install dependencies
bun install
# Create environment file
cp .env.example .env
# Edit .env with your configuration
nano .env
# Start development server
bun run dev
# Production mode
bun run startEnvironment Variables (.env):
PORT=8000
NODE_ENV=development
ALLOWED_ORIGINS=http://localhost:5173,https://yourdomain.comcd frontend
# Install dependencies
bun install
# Start development server
bun run dev
# Build for production
bun run buildFrontend Configuration:
Update src/config.ts:
export const SOCKET_URL =
process.env.NODE_ENV === 'production'
? 'wss://api.yourdomain.com'
: 'ws://localhost:8000';# Create e2-small instance (recommended for 500-1000 users)
gcloud compute instances create pairup-server \
--machine-type=e2-small \
--zone=us-central1-a \
--image-family=debian-12 \
--image-project=debian-cloud \
--boot-disk-size=20GB \
--tags=http-server,https-server# Allow HTTP, HTTPS, and WebSocket
gcloud compute firewall-rules create allow-pairup \
--allow=tcp:80,tcp:443,tcp:8000 \
--source-ranges=0.0.0.0/0 \
--target-tags=http-server,https-server# SSH into VM
gcloud compute ssh pairup-server --zone=us-central1-a
# Run TURN setup script (from repository)
chmod +x scripts/setup-turn.sh
./scripts/setup-turn.sh
# Note down your TURN credentials!# Install Bun
curl -fsSL https://bun.sh/install | bash
# Clone and setup
git clone https://github.com/prudh-vi/pairup-server.git
cd pairup-server
bun install
# Install PM2
npm install -g pm2
# Start with PM2
pm2 start src/index.ts --name pairup --interpreter bun
pm2 save
pm2 startupsudo apt install nginx certbot python3-certbot-nginx
# Copy NGINX config
sudo cp scripts/nginx.conf /etc/nginx/sites-available/pairup
sudo ln -s /etc/nginx/sites-available/pairup /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
# Get SSL certificate
sudo certbot --nginx -d api.yourdomain.com# Install Vercel CLI
npm i -g vercel
# Deploy
cd frontend
vercel --prodOr use the Vercel GitHub Integration for automatic deployments.
# PM2 logs
pm2 logs pairup
# NGINX logs
sudo tail -f /var/log/nginx/access.log
sudo tail -f /var/log/nginx/error.log
# TURN server logs
sudo tail -f /var/log/turnserver.log# Server resources
pm2 monit
# Active connections
sudo netstat -an | grep 3478 | wc -l
# Bandwidth usage
sudo iftop# Restart backend
pm2 restart pairup
# Restart NGINX
sudo systemctl restart nginx
# Restart TURN server
sudo systemctl restart coturnUpdate frontend/src/config/webrtc.ts:
export const rtcConfig: RTCConfiguration = {
iceServers: [
{ urls: 'stun:stun.l.google.com:19302' },
{
urls: 'turn:YOUR_SERVER_IP:3478',
username: 'YOUR_TURN_USERNAME',
credential: 'YOUR_TURN_PASSWORD'
},
],
iceCandidatePoolSize: 10,
};Edit backend/src/matchmaking.ts:
const QUEUE_TIMEOUT = 30000; // 30 seconds
const MAX_RETRIES = 3;| Users | VM Type | TURN Servers | Monthly Cost |
|---|---|---|---|
| 100-500 | e2-small | 1Γ e2-small | ~$20 |
| 500-2,500 | e2-medium | 2Γ e2-small | ~$60 |
| 2,500-5,000 | e2-standard-2 | 3Γ e2-medium | ~$200 |
| 5,000-10,000 | e2-standard-4 | 5Γ e2-standard-2 | ~$500 |
- Enable P2P First - Campus WiFi users connect directly (saves 60% bandwidth)
- Lower Video Quality - Use 480p instead of 720p during peak hours
- Set Time Limits - 10-minute max calls prevent bandwidth abuse
- Geographic Distribution - Deploy TURN servers in multiple regions
- Redis Adapter - Scale Socket.IO horizontally across multiple servers
Contributions are what make the open-source community amazing! Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
See CONTRIBUTING.md for detailed guidelines.
- Occasional connection drops on mobile Safari (investigating)
- TURN relay not working on some corporate networks (firewall issue)
- Memory leak on long-running sessions (fix in progress)
See the open issues for a full list.
- Basic video chat functionality
- TURN server integration
- Production deployment
- User authentication system
- Interest-based matching
- Reporting & moderation tools
- Screen sharing support
- Group video calls (3-4 people)
- Virtual backgrounds
- Redis adapter for horizontal scaling
- Mobile apps (React Native)
Distributed under the MIT License. See LICENSE for more information.
Prudhvi
- GitHub: @prudh-vi
- LinkedIn: LinkedIn
- Email: prudhvirajkb3@gmail.com
- WebRTC - For making P2P communication possible
- Socket.IO - For reliable WebSocket connections
- Coturn - For TURN/STUN server
- Tailwind CSS - For beautiful UI
- Bun - For blazing fast runtime
If you found this project helpful, please give it a βοΈ!
Made with β€οΈ by Prudhvi