# Tiny Paleo Field Station

An original, dependency-free Twitch overlay made for dinosaur games. It includes a landscape canvas, a dedicated portrait canvas for Twitch Dual Format, five scenes, animated alerts, and a browser-based control room.

## Start it

1. Install Node.js 18 or newer.
2. Open a terminal in this folder.
3. Run `npm start`.
4. Open <http://127.0.0.1:4173>.
5. Create a ranger account with a username and a password of at least 10 characters.

Keep the terminal open while streaming.

## Add it to OBS

Sign in to the control room and use its **Copy OBS URL** buttons. Each account receives unique, read-only landscape and portrait URLs. Add them as **Browser Sources** with these settings:

- Landscape size: `1920 × 1080`
- Portrait size: `1080 × 1920`
- FPS: `30`
- Shutdown source when not visible: off
- Refresh browser when scene becomes active: off

For the gameplay scene, place the overlay above the game and webcam sources. The outlined Ranger Cam area is transparent, so the webcam should sit underneath it.

For Starting, Just Chatting, BRB, and Ending, the overlay provides an opaque illustrated background. Use the control room to change scenes and trigger alerts in every open Browser Source.

## Customize

Accounts and settings persist in `.data/accounts.json`, which is excluded from Git. Passwords are stored as salted `scrypt` hashes, never as plaintext. Login uses an `HttpOnly`, `SameSite=Lax` session cookie. Sessions are intentionally kept in memory, so restarting the server signs everyone out without deleting accounts.

Each OBS source reads only the account associated with its random overlay key. Control and alert API routes require a signed-in session. If an OBS URL is exposed, use **Rotate OBS Key** in the control room and replace the URL in OBS.

This first version uses simulated alert buttons. Twitch's native Alerts Browser Source can be placed above this overlay, or `overlay.js` can later be connected to an EventSub backend for completely custom live alerts.

## Public hosting

This is a single-server MVP. For public hosting:

- Run behind HTTPS; secure session cookies are enabled automatically when HTTPS is detected.
- Set `PALEO_HOST=0.0.0.0` when the hosting environment requires an external listener. `PORT` is supported.
- Persist the `.data` directory on a private server volume and back it up. `PALEO_DATA_PATH` can point to a mounted account file.
- Use one application instance. Move accounts, sessions, state, and rate limits to a real database/Redis before scaling to multiple instances.
- There is no email collection or password recovery yet. An operator must handle lost accounts manually.

## Deploy with Dokploy

The included `Dockerfile` is ready for Dokploy's **Application** service:

1. Create an Application and select this GitHub repository with branch `main`.
2. Choose **Dockerfile** as the build type.
3. Set Dockerfile Path to `Dockerfile` and Docker Context Path to `.`.
4. Under **Advanced → Mounts**, create a named **Volume Mount** at `/data`. This keeps accounts and settings across deployments and lets Dokploy back up the volume.
5. Keep one replica. Sessions and rate limits are currently stored in the running process.
6. Under **Domains**, create the domain at path `/`, set **Container Port** to `4173`, and enable HTTPS with Let's Encrypt.
7. Deploy. Do not add an Advanced host-port mapping unless you specifically need direct `server-ip:port` access.

The image already supplies these runtime defaults:

```text
PALEO_HOST=0.0.0.0
PORT=4173
PALEO_DATA_PATH=/data/accounts.json
```

The container runs as the non-root `node` user and exposes `/api/health` for its Docker health check.
