-- : -- : --

Paused

La La Land (Piano)

Justin Hurwitz

Home
Back to Projects
2026/ 12Live

Nearcast

Peer-to-Peer Video Chat Platform

Overview

A real-time peer-to-peer video and text chat application that connects strangers for live conversation using WebRTC, Socket.IO, React, and Express with hybrid architecture keeping signaling centralized while streaming media directly between browsers.

Nearcast is a peer-to-peer video chat platform that connects random strangers for live conversation. Built with WebRTC for direct browser-to-browser media streaming and Socket.IO for signaling, it demonstrates a hybrid architecture where the server only facilitates connection setup while media flows peer-to-peer.

Key Features

Peer-to-Peer Media

WebRTC direct browser-to-browser video and audio streaming with Google STUN server for NAT traversal

Real-Time Text Chat

Integrated instant messaging with timestamps, auto-scroll, and disconnect notifications

Preference Matching

Connect with strangers based on stated identity preferences (Male/Female/Any)

In-Call Controls

Mute/unmute, camera toggle, screen sharing, report user modal, and 'Next Stranger' skip

Privacy by Design

P2P streams never stored on server, no accounts required, end-to-end encrypted media

Modern Dark UI

Custom visual identity with dark theme (#07080a), green accents (#22c55e), translucent badges

Technology Stack

ReactTypeScriptExpressSocket.IOWebRTCViteNode.jsDocker

Challenges

  • Implementing reliable WebRTC peer-to-peer connections with NAT traversal

  • Building a matching queue system with preference-based pairing

  • Managing Socket.IO signaling for offers, answers, and ICE candidates

  • Handling graceful disconnects, reconnects, and 'Next Stranger' functionality

  • Ensuring privacy by keeping media streams peer-to-peer without server storage

Solutions

  • Built UserManager for queue management with preference-based matching (Male/Female/Any)

  • Designed RoomManager for 1-to-1 WebRTC signaling relay via Socket.IO events

  • Implemented Google STUN server for NAT traversal and ICE candidate exchange

  • Created React components with getUserMedia for camera/mic access and RTCPeerConnection management

  • Added in-call controls: mute, camera toggle, screen share, and skip to next stranger

  • Built integrated text chat with timestamps and auto-scroll alongside video streams

Project Architecture

// Project Structure

nearcast/
├── backend/
│   ├── src/
│   │   ├── index.ts         # Express + Socket.IO
│   │   └── managers/
│   │       ├── UserManager.ts # Queue & matching
│   │       └── RoomManager.ts # WebRTC signaling
│   ├── package.json
│   └── tsconfig.json
├── frontend/
│   ├── src/
│   │   ├── components/
│   │   │   ├── Landing.tsx  # Landing with preview
│   │   │   └── Room.tsx     # Video grid + chat
│   │   ├── App.tsx
│   │   └── index.css
│   ├── vite.config.ts
│   └── package.json
├── Dockerfile
└── vercel.json

Key Learnings

  • WebRTC architecture: RTCPeerConnection, SDP offers/answers, ICE candidate exchange

  • Socket.IO real-time bidirectional communication patterns for signaling

  • NAT traversal strategies with STUN servers and when TURN servers are needed

  • getUserMedia API for camera/microphone access with permission handling

  • Peer connection lifecycle management: setup, negotiation, connection states, cleanup

  • Building hybrid architectures: centralized signaling with peer-to-peer media

  • Privacy-first design: no server-side media storage, minimal metadata collection

Future Enhancements

TURN server integration for restrictive NAT, horizontal scaling with Redis for shared state, content moderation system, session timeouts, and CDN delivery for static assets.