Prerequisites

Requirement Version
Node.js 18 or later
npm 9 or later
MongoDB 6 or later (local or MongoDB Atlas)

Clone the repository

git clone https://github.com/ratava/PoolStat-Scoreboard-PWA.git
cd PoolStat-Scoreboard-PWA
npm install

Environment variables

Create a .env file in the project root (never commit this file):

# MongoDB connection string
MONGODB_URI=mongodb://localhost:27017/poolstat

# Session secret — use a long random string
SESSION_SECRET=change-me-to-a-long-random-string

# Admin password for /admin.html
ADMIN_PASSWORD=your-admin-password

# Competition login password for /competition.html
COMPETITION_PASSWORD=your-competition-password

# MQTT broker connection
MQTT_BROKER_URL=wss://your-broker-host:9001/
MQTT_USERNAME=your-mqtt-username
MQTT_PASSWORD=your-mqtt-password

# YouTube OAuth (optional — required only for YouTube integration)
YOUTUBE_CLIENT_ID=your-google-client-id
YOUTUBE_CLIENT_SECRET=your-google-client-secret
YOUTUBE_REDIRECT_URI=http://localhost:3000/auth/youtube/callback

# Facebook agent (optional)
FACEBOOK_GROUP_URL=

# Environment
NODE_ENV=development
PORT=3000

Start the server

npm start

Open http://localhost:3000 in your browser.

Deploying to Render

The PWA is designed for deployment on Render:

  1. Create a new Web Service on Render
  2. Connect to the GitHub repository
  3. Set Build Command: npm install
  4. Set Start Command: node server.js
  5. Add all environment variables from the list above under Environment
  6. Set NODE_ENV=production
  7. Deploy

For MongoDB, use MongoDB Atlas and set the MONGODB_URI to your Atlas connection string.

OBS browser source setup

On each OBS machine that will be a rig:

  1. In OBS, add a Browser Source to your scene
  2. Set the URL to:
    https://your-server-url/browser-source.html?rigId=your-rig-id
    

    Replace your-rig-id with the Rig ID you will configure in Admin.

  3. Set width to 1920 and height to 1080 (or your stream resolution)
  4. Enable Shutdown source when not visible — OFF
  5. Enable Refresh browser when scene becomes active — optional

The browser source must remain loaded (even if not visible) to receive MQTT commands. It does not need to be in the currently active scene.