A real-time web chat application with WebRTC-powered audio and video calling. Users join rooms with a username and room ID to chat and call — no accounts, no setup.
- Real-time messaging via Socket.IO
- Room-based chat with unique username validation per room
- WebRTC audio and video calling with multi-participant support
- Mute, video toggle, and call duration controls
- Incoming call notifications with accept / decline
- Emoji picker for messages
- Live user count and typing indicators
- Auto-cleanup of stale connections
| Layer | Technology |
|---|---|
| Frontend | React 18, Socket.IO Client, WebRTC API |
| Backend | Node.js, Express, Socket.IO Server |
| Calling | WebRTC Peer-to-Peer + Google STUN/TURN |
| Deployment | Vercel (frontend) · Fly.io (backend) |
React (Vercel)
↓ Socket.IO
Node.js + Socket.IO (Fly.io)
↓ WebRTC Signaling
Peer-to-Peer Connection
- Node.js v14+
- A modern browser with WebRTC support (Chrome, Firefox, Edge, Safari 11+)
git clone https://github.com/GowsiSM/REAL-TIME-CHAT-APPLICATION.git
cd REAL-TIME-CHAT-APPLICATIONcd server
npm install
node index.jsRuns on http://localhost:3001
cd frontend
npm install
npm startRuns on http://localhost:3000
- Open the app and enter a username and room ID
- Share the same room ID with anyone you want to chat with
- Type messages and press Enter or Send
- Click Audio or Video to start a call when others are in the room
- Use call controls to mute, toggle video, or end the call
- Click Logout to leave the room
| Endpoint | Description |
|---|---|
GET /health |
Server status and active room info |
GET /rooms/stats |
Room statistics and user counts |
GET /webrtc/turn-credentials |
Short-lived TURN credentials for WebRTC |
Uses Google STUN servers plus short-lived credentials for a configured TURN server:
const rtcConfig = {
iceServers: [
{ urls: "stun:stun.l.google.com:19302" },
{ urls: "stun:stun1.l.google.com:19302" },
{
urls: "turn:turn.example.com:3478",
username: "<short-lived username>",
credential: "<short-lived credential>"
}
]
};The signaling server generates coturn-compatible, time-limited credentials using
TURN_SERVER_URL and TURN_SERVER_SECRET. Set
TURN_CREDENTIAL_TTL_SECONDS optionally (default: 3600, maximum: 86400).
The TURN secret is never sent to the frontend.
The live version runs on:
- Frontend → Vercel — deploy the
/frontendfolder - Backend → Fly.io — deploy the
/serverfolder (WebSocket-friendly, stays online)
After deploying the backend, update the socket URL in frontend/src/App.js:
socketRef.current = io("https://your-backend.fly.dev");Configure these backend environment variables in the deployment environment:
TURN_SERVER_URL=turn:your-turn-host.example.com:3478
TURN_SERVER_SECRET=your-coturn-static-auth-secret
TURN_CREDENTIAL_TTL_SECONDS=3600For coturn, enable the shared-secret mechanism with the same secret (for example,
use-auth-secret and static-auth-secret).
Chrome 60+ · Firefox 55+ · Safari 11+ · Edge 79+
HTTPS is required for camera and microphone access in production.