How jakekitchen/mumbai works
Project Type & Purpose
• Mumbai is a secure, open-source, one-to-one video conferencing application built to eliminate third-party logging or data capture.
• Its primary goal is to enable highly private, direct video calls using WebRTC. The README emphasizes that it is clientless, requiring no downloads or persistent logs.
Analyzing the File Structure
• Top-level:
– Files like .env, package.json, tsconfig.json, and LICENSE, which set up the environment, project configuration, and dependencies.
• Public Directory:
– Contains static assets such as CSS, JavaScript, EJS templates (home.ejs, call.ejs, header.ejs) used for the frontend.
– The JavaScript files (e.g., call.js, handle-ws.js, media.js, video-grid.js) manage client-side interactions – from handling media streams and WebRTC sessions to managing the video grid UI.
• src Directory:
– App.ts appears to be the entry point for the Node server.
– Routes directory (e.g., index.ts, room.router.ts) sets up express endpoints, including room management.
– Utils directory holds key modules for WebRTC signaling, room and user management, and websocket client handling.
– TLS key files in src (e.g., localhost+2-key.pem, localhost+2.pem) indicate secure communications.
• .github Directory:
– Provides CI/CD workflows which although peripheral to the system design, highlight automated testing and deployment practices.
Key Architectural Components
a. Frontend:
– Static pages served via EJS templates (e.g., home.ejs, call.ejs).
– CSS and JS assets that control UI and client-side logic.
– Browser API integration with WebRTC for peer-to-peer video functionality.
b. Backend:
– A Node/Express server (entry in src/app.ts) providing endpoints for room creation and routing (via room.router.ts and index.ts).
– Websocket handling (src/utils/handleWebsocket.ts, wsClients.ts, wsMessage.ts) that facilitates signaling between clients.
– Room and user management utilities (room.ts, rooms.ts, user.ts) to manage session states.
c. Signaling Layer:
– Uses websocket services to exchange session initiation messages, so clients can negotiate their WebRTC connection.
d. Security & Deployment:
– Integration of TLS certificates ensures secure client-server communication.
– The .env configuration files at both project root and within src suggest environment-specific settings.
Relationships & Interactions
• Clients (browsers) request the webpage HTML (EJS templates from the public folder) from the Express server.
• After rendering, the client-side JavaScript initiates WebRTC calls.
• A websocket connection (handled by modules in the src/utils directory) is established between the client and the server to exchange call setup signals.
• Once connected, direct peer-to-peer calls commence using the framework provided by WebRTC.
• The server also manages room creation, verification, and termination, ensuring that each room only hosts two participants.
Architectural Patterns & Design Principles
• Clear separation of concerns between frontend (presentation/UI, media handling) and backend (server routing, signaling, room management).
• Minimalist and secure design – intentionally limiting features for a privacy-first, two-participant system.
• Usage of common Node.js and Express patterns with a modular approach (distinct directories for routes and utilities).