# Deploying AdForia for your team

Three ways to get your team working in the same studio — each seat signs in at `/signin`
with their own PIN (Settings → Team seats). Pick by effort:

---

## Option A — Tailscale (5 minutes, free, zero server)

Run AdForia on any always-on machine (a Mac mini, your office desktop) and let teammates
reach it over a private mesh VPN. Nothing is exposed to the public internet.

1. Install [Tailscale](https://tailscale.com/download) on the host machine and each teammate's laptop (free plan covers 3 users / 100 devices).
2. On the host: `npm run dev` (or `npm run build && npm start` for production mode).
3. Teammates open `http://<host-tailnet-name>:4040`, activate once with the license key, then sign in with their seat PIN.
4. Done. The daily auto-backup keeps `data/assets/adforia-backup-*.zip` — copy it to Drive/S3 on whatever schedule you like.

**Best for:** brands/agencies with 2-3 people who want team access TODAY without touching a server.

---

## Option B — $6 VPS (30 minutes, always on, work from anywhere)

Any Ubuntu box (Hetzner/DigitalOcean/Lightsail, 2GB RAM is plenty):

```bash
# 1. deps
sudo apt update && sudo apt install -y nodejs npm ffmpeg zip caddy
sudo npm i -g pm2

# 2. app
git clone <your-repo> adforia && cd adforia/videoediting
npm install
cp .env.local.example .env.local   # add your API keys, or set them later in Settings
npm run build

# 3. run forever
pm2 start "npm start" --name adforia
pm2 save && pm2 startup

# 4. HTTPS (Caddy auto-provisions TLS)
echo 'studio.yourdomain.com {
  reverse_proxy localhost:4040
}' | sudo tee /etc/caddy/Caddyfile && sudo systemctl reload caddy
```

Then: open `https://studio.yourdomain.com` → activate the license → Settings → Team seats →
add your 3 members. Every teammate works from their own laptop, own session, anywhere.

**Backups:** `crontab -e` → `0 6 * * * cp /path/to/adforia/videoediting/data/assets/adforia-backup-*.zip /backup/` (the app already produces the daily zip; this ships it off-box). Or sync `data/` to S3 with `rclone`.

**Best for:** the Studio tier as intended — 3 concurrent seats, shared brand kits, swipe library and queue.

---

## Option C — Docker

```dockerfile
# Dockerfile (place in videoediting/)
FROM node:20-slim
RUN apt-get update && apt-get install -y ffmpeg zip && rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
EXPOSE 4040
CMD ["npm", "start"]
```

```bash
docker build -t adforia .
docker run -d --name adforia -p 4040:4040 \
  -v adforia-data:/app/data \
  --restart unless-stopped adforia
```

The `adforia-data` volume holds the database and every generated asset — snapshot it and
you've backed up the whole studio.

---

## Notes

- **Concurrency:** SQLite in WAL mode comfortably handles a 3-seat team on one server. The batch queue runs 2 parallel lanes; generation providers (Kie/ElevenLabs) are the real rate limit, not the app.
- **Security:** the license gate + per-member PIN sessions are designed for a private team deployment (VPN or your own domain). If you expose it publicly, put it behind Caddy basic-auth or Cloudflare Access as an extra layer.
- **Restore:** unzip a backup over `data/` and start the app — that's the whole disaster-recovery story.
