How cleverprogrammers/nodejs-zoom-clone works
Project Type and Purpose
• This is a real-time, full-stack Zoom-style video conferencing clone built with Node.js.
• It uses Express.js to serve pages and static assets, EJS templates for HTML rendering, Socket.io for real-time signaling, and PeerJS (WebRTC) for peer-to-peer media streaming.
File Structure Analysis
• server.js: the single Node.js entry point. Sets up HTTP server, Express routes, Socket.io and PeerJS servers.
• public/: static assets (client-side JavaScript and CSS).
• views/: EJS templates (room.ejs) to render the video conferencing page.
• package.json, package-lock.json: Node.js dependencies (express, socket.io, peer, etc.).
Key README Insights
• Confirms Node.js, JavaScript, and MongoDB (though no DB code present).
• Focus is on building the UI, real-time signaling, and P2P media.
Main Components
a. Client (Browser)
• Loads HTML (EJS) + CSS + script.js from the server.
• Connects to:
• Socket.io server (for join/leave and user-connect/disconnect events).
• PeerJS server (WebRTC signaling → establishes P2P media connections).
b. Express Server (server.js)
• Serves static assets (public/) and renders views (views/room.ejs).
• Hosts:
• HTTP endpoint for “/:room” and “/” routes.
• Socket.io namespace for signaling.
c. (Optional) Database
d. External Services
• WebRTC NAT traversal (STUN/TURN servers) if configured.
• CDN for static assets (optional).
Component Relationships and Data Flows
• User navigates to “/roomID” → Express renders room.ejs → client JavaScript boots.
• Client opens Socket.io connection → “join-room” event → server tells existing clients to “user-connected”.
• Each client calls PeerJS.connect() → obtains peer ID → server broadcasts peer ID to room.
• Clients exchange WebRTC offer/answer via PeerJS server → establish direct P2P audio/video streams.
• Socket.io handles text chat or signaling fallbacks; PeerJS handles media channels.
Architectural Patterns and Principles
• Monolithic Node.js backend combining HTTP and real-time APIs.
• Separation of concerns:
• Presentation: EJS views + static assets.
• Signaling: Socket.io events.
• Media relay: PeerJS (WebRTC).
• Client-driven P2P mesh topology: each client links to every other client in a room.
Final Checklist
• Components clearly boxed and labeled.
• Callouts for key events or data formats (JSON, SDP).
• P2P mesh with multiple client instances and direct connections.