Skip to content
nicx17Public

About

High-performance, real-time video synchronization application that prioritizes Local-First Privacy.

Topics

Resources

Security policy

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

Lets Watch

Lets Watch is a local-first watch-party app for self-hosted environments. Each viewer opens the video file from their own machine, while the server only coordinates playback state over Socket.IO.

Features

  • Syncs play, pause, and seek events across a room with shared participant control.
  • Lets viewers create rooms with their own room code and 6-digit join PIN.
  • Offers room chat with viewer-selected names, quick emoji reactions, color emoji from the bundled Noto Color Emoji font, and lightweight image sharing.
  • Serves the React frontend and the Socket.IO backend from one Node process in production.
  • Keeps media local to each participant instead of uploading it to the server.
  • Broadcasts chat messages live without storing chat history on the server.
  • Includes basic hardening such as Helmet, payload validation with Zod, and lightweight rate limiting.
  • Obfuscates sensitive identifiers in backend logs so room and participant metadata are not written in plain text.
  • Applies dedicated authentication throttling to room create/join flows to reduce brute-force attempts, including reconnect-based retries from the same client identity, and locks a room's PIN entry after repeated failures from any mix of clients.

Repository Layout

  • client/: React 19 + Vite frontend.
  • server/: Express + Socket.IO backend.
  • README.md: project overview and development guide.
  • SECURITY.md: current controls, limitations, and security workflow.
  • DEPLOYMENT.md: production setup and hosting notes.

Prerequisites

  • Node.js 22.18 or newer, which can run TypeScript natively. CI runs on Node 22 and 24, and .nvmrc pins Node 26 for local development.
  • npm 10 or newer.

Local Development

Install dependencies in both packages:

npm run install:all

Start the backend:

cd server
npm run dev

Start the frontend in a second terminal:

cd client
npm run dev

The default local URLs are:

  • Frontend: http://localhost:5173
  • Backend: http://localhost:4000

Environment Variables

Server

Copy server/.env.example to server/.env:

PORT=4000
NODE_ENV=production
APP_URL=https://www.example.com
Variable Required Purpose
PORT No (default 4000) Port the HTTP and Socket.IO server listens on.
HOST No (default 0.0.0.0) Address to bind. Use 127.0.0.1 when a reverse proxy runs on the same machine.
NODE_ENV Yes in production production enables static frontend serving, HSTS, and strict origin checks.
APP_URL Yes when NODE_ENV=production Public origin. Used for CORS, Socket.IO admission, and CSP connect-src. The server refuses to start without it in production.
TRUST_PROXY No (default off) Number of reverse proxies in front of the server (true means 1). The client address used for rate limiting is read that many entries from the right of X-Forwarded-For. See DEPLOYMENT.md.

Client

Copy client/.env.example to client/.env if the frontend needs to talk to a separately hosted backend:

VITE_SOCKET_URL=http://localhost:4000

In production, the client falls back to window.location.origin when VITE_SOCKET_URL is not set.

Validation

Run from the repo root after both packages are installed:

npm run lint
npm run test
npm run build

What these commands do:

  • npm run lint: runs frontend ESLint and backend TypeScript checks.
  • npm run test: runs client and server Vitest suites.
  • npm run build: builds the frontend and type-checks the backend.

Production Notes

  • The frontend must be built before starting the server in production.
  • The backend serves client/dist when NODE_ENV=production.
  • Static assets under /assets are cached aggressively because Vite fingerprints them.
  • index.html is served with no-store caching so browsers always pick up the latest asset references.
  • In production, index.html is served through a nonce-injecting response path.
  • Open the app at / in production. Direct /index.html requests are redirected to / so CSP nonce injection is consistently applied.
  • Chat images are resized in the browser before they are sent over Socket.IO.
  • Joining an existing room requires both the chosen room code and its 6-digit PIN.
  • Room codes are normalized to uppercase and PIN inputs are reduced to six digits during create and join.
  • Rooms also expose a copyable share link with a room-specific token so invite links can join directly without re-entering the PIN. The token is in the URL fragment (#token=...), so it is never sent to the server or written to proxy logs.
  • PIN-based joins rotate the current share token, so older copied links stop working after a fresh PIN join.
  • Room state is in-memory only. When the last participant disconnects, room membership and playback state are dropped. Run exactly one server process.
  • GET /healthz returns {"status":"ok"} for load balancers and uptime checks.
  • The server runs TypeScript directly on Node (type stripping), so there is no server build step or runtime transpiler.
  • Production Socket.IO admission checks Origin first and only falls back to the effective Host header when Origin is absent. It does not trust X-Forwarded-Host as an auth signal.

Security Headers

  • CSP is emitted as an HTTP response header and uses nonce-augmented script-src with strict-dynamic support (without unsafe-inline for scripts).
  • HSTS is enabled in production with long max-age, subdomain coverage, and preload.

See DEPLOYMENT.md for a full deployment walkthrough.

License

This project is licensed under GPL-3.0-or-later. See LICENSE for details.

About

High-performance, real-time video synchronization application that prioritizes Local-First Privacy.

Topics

Resources

Security policy

Stars

0 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages