Skip to content

Repository files navigation

P2P Video Calling App

A simple, personal-use voice and video calling application built with WebRTC. Users can create a room and share a link for instant, browser-based communication without authentication.

🏗 Architecture

High-Level Architecture

The application follows a client-server model with a signaling mechanism to establish Peer-to-Peer (P2P) connections.

graph TD
    UserA[User A - Browser] <--> Server[Express Server + WebSocket Signaling]
    UserB[User B - Browser] <--> Server
    UserA -- WebRTC P2P (Audio/Video) --- UserB
    Server <--> DB[(PostgreSQL)]
Loading

Components

  1. Frontend (React + Vite): Handles the user interface, media device access (Camera/Mic), and WebRTC state management.
  2. Backend (Node.js + Express): Provides REST API for room management and hosts the WebSocket signaling server.
  3. Signaling Server (WebSocket): Facilitates the exchange of "handshake" information (SDP offers/answers and ICE candidates) between peers.
  4. Database (PostgreSQL): Stores room metadata for session persistence.
  5. WebRTC: Enables direct media streaming between browsers once the handshake is complete.

Sequence Diagram: Call Establishment

sequenceDiagram
    participant A as User A (Initiator)
    participant S as Signaling Server
    participant B as User B (Joiner)

    Note over A,B: Signaling via WebSocket
    A->>S: Create Room / Join Room
    B->>S: Join Room (via shared link)
    S->>A: peer-joined
    A->>A: Create WebRTC Offer
    A->>S: send offer (SDP)
    S->>B: forward offer
    B->>B: Create WebRTC Answer
    B->>S: send answer (SDP)
    S->>A: forward answer
    Note over A,B: ICE Candidate Exchange
    A->>S: send ice-candidate
    S->>B: forward candidate
    B->>S: send ice-candidate
    S->>A: forward candidate
    Note over A,B: P2P Connection Established
    A-->>B: Direct Video/Audio Stream
Loading

🚀 Local Deployment Guide

Prerequisites

  • Node.js: v18 or higher.
  • PostgreSQL: A running instance (or use a local SQLite/Mock if modified).
  • HTTPS: WebRTC requires a secure context. For local testing, localhost works, but for network access, you need SSL certificates.

1. Windows Setup

  1. Clone the repository:
    git clone <your-repo-url>
    cd <repo-name>
  2. Install Dependencies:
    npm install
  3. Environment Variables: Create a .env file in the root:
    DATABASE_URL=postgres://user:password@localhost:5432/dbname
  4. Database Push:
    npm run db:push
  5. Run Development:
    npm run dev
    Access at http://localhost:5000.

2. Raspberry Pi Setup (Linux)

  1. Install Node.js & Postgres:
    sudo apt update
    sudo apt install nodejs npm postgresql
  2. Setup Database:
    sudo -u postgres psql -c "CREATE DATABASE vido_call;"
  3. Deploy: Follow the same steps as Windows.
  4. Internet Access (Important):
    • To use this over the internet, you must use a tool like Cloudflare Tunnel or Nginx with Let's Encrypt to provide an https:// URL.
    • WebRTC will fail on mobile devices if served over plain http://.

🛠 Tech Stack

  • Frontend: React, Tailwind CSS, Framer Motion, Lucide Icons.
  • Backend: Node.js, Express, ws (WebSockets).
  • Database: Drizzle ORM + PostgreSQL.
  • Real-time: WebRTC (Native Browser API) + Google STUN servers.

About

Peer to Peer Video and Voice solution

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages