fac9b96cca
CI / build (push) Has been cancelled
Folders were an implementation detail leaking into the event workflow: every upload needed a folder first and photos were split across pages. Uploads now land in a single implicit "Photos" folder and the event page renders one gallery with the uploader and an edited-only download. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
868 lines
44 KiB
Markdown
868 lines
44 KiB
Markdown
# Media Team Hub
|
||
|
||
Scheduling, availability, training, and media operations for a church media team.
|
||
|
||
The app runs the full weekly loop: recurring services are generated, seats are assigned (manually or by ranked auto-fill), conflicts and blackout dates are checked, the week is published, and volunteers receive email with one-click confirm/decline links. It also handles one-off event photography, a photo/video library, skill verification and mentoring, training material, announcements, coverage requests, calendar feeds, and backups.
|
||
|
||
Built with Next.js 15, React 19, TypeScript, PostgreSQL 16, and Drizzle ORM. It deploys as a portable Node container behind your own reverse proxy.
|
||
|
||
> **Notification scope:** email is the only delivery channel currently implemented. SMS was deliberately removed; queued SMS rows are suppressed by the dispatcher. See [Known gaps](#known-gaps).
|
||
|
||
## Contents
|
||
|
||
- [Features](#features)
|
||
- [Stack](#stack)
|
||
- [Quick start (Docker)](#quick-start-docker)
|
||
- [Deploying the combined stack on another system](#deploying-the-combined-stack-on-another-system)
|
||
- [Local development](#local-development)
|
||
- [Configuration](#configuration)
|
||
- [Email delivery](#email-delivery)
|
||
- [Scheduled jobs](#scheduled-jobs)
|
||
- [Backup and restore](#backup-and-restore)
|
||
- [Roles and permissions](#roles-and-permissions)
|
||
- [Testing](#testing)
|
||
- [Production deployment on Ubuntu](#production-deployment-on-ubuntu)
|
||
- [Project structure](#project-structure)
|
||
- [Documentation](#documentation)
|
||
- [Known gaps](#known-gaps)
|
||
|
||
## Features
|
||
|
||
### Scheduling
|
||
|
||
- Recurring service templates (RFC 5545 subset, local start time, duration, call-time offsets) materialized into dated instances and per-role seats.
|
||
- Week, month, and year calendar lenses, plus a printable run sheet/booth sheet.
|
||
- One active assignment per seat, enforced by the database; one assignment per person per service, enforced by the conflict engine.
|
||
- Manual assignments from a ranked candidate list (availability → roster → one-per-service → core competency → readiness).
|
||
- Hard-conflict blocking (blackout, double-booking, missing core skill, shadow pairing, etc.) with soft conflicts returned as warnings.
|
||
- Deterministic auto-fill under a monthly service cap, with preview and apply.
|
||
- Draft vs. published weeks: publishing validates coverage, writes an audit row, and queues notifications atomically. Unpublishing is refused while anyone is confirmed.
|
||
- Post-service completion job records `last_served_on` / `last_served_at`.
|
||
|
||
### Availability and coverage
|
||
|
||
- Volunteers publish one-off or recurring blackout ranges; coordinators see the whole team's availability.
|
||
- Warnings when a new blackout overlaps an existing assignment.
|
||
- Coverage board for swap/release requests, with ranked replacements.
|
||
- Public, no-account coverage request form at `/request-coverage`.
|
||
|
||
### Notifications
|
||
|
||
- Database outbox with atomic claiming, a `queued → sending → sent` state machine, retry backoff (5/30/120 minutes, three attempts), and stale-send recovery.
|
||
- Per-user email preference, lead time, digest flag, and quiet hours (quiet hours only gate SMS; there is no SMS transport).
|
||
- Admin-editable reminder rules: default 7 days out, Friday before at 18:00, and a day-of rule. Timing and channel set are runtime data, not code.
|
||
- Publish-time assignment email and reminders, with signed single-use confirm/decline links that work without signing in; every upcoming assignment can also be confirmed or released in-app from the home page.
|
||
- Declines cancel that assignment's queued mail; late assignments enqueue their own mail; unpublishing cancels the week's queued mail.
|
||
- Admin outbox log with retry and test-send.
|
||
|
||
### People, skills, and training
|
||
|
||
- Magic-link sign-in, optional account password, approval queue, deactivation, and admin account management.
|
||
- Skill taxonomy composed from category / technology / function, with per-position requirements (core flag, weight, required level).
|
||
- Volunteers record self-comfort; mentors/admins verify the real level. Every level change appends an assessment-history row.
|
||
- Per-skill mentor opt-in and persisted admin approval; trainee shadow seats require a paired, mentor-ready volunteer.
|
||
- Skills matrix, readiness scoring, and growth-goal domain rules.
|
||
- Rich-text training lessons with headings, lists, links, inline images (align, resize, caption, drag to reorder), and PDF/Word/text manuals up to 25 MB, plus draft/publish controls and separate admin/volunteer guides.
|
||
- Growth goals: volunteers ask to level up a skill, coordinators assign a mentor who is actually mentor-ready, and shadows are logged until the goal is achieved (verification itself stays in the matrix).
|
||
- Retention and storage report in the admin console: what the outbox, token tables and upload volume hold, and an explicit sweep for finished mail, used tokens and orphan files.
|
||
|
||
### Events and media
|
||
|
||
- One-off events with a shot brief, location, times, photographer/editor assignments, and a single shared photo gallery per event.
|
||
- RAW and JPEG uploads streamed to disk, SHA-256 dedupe per event, authenticated downloads, and manager-only event deletion with file cleanup.
|
||
- Photo gallery with cached grid thumbnails (RAW included), preview, non-destructive adjustments/presets, export, whole-event or edited-only ZIP download, and filing a finished event into a dated delivery folder with a manifest. Every photo and video byte lives on the configured media storage share — never in container-local storage.
|
||
- Video upload with FFmpeg probe/transcode to web H.264/AAC, generated poster, non-destructive trim re-render, and retry after a failed encode.
|
||
- Media visibility: team-only, unlisted link, or public. Ready public videos get `/watch/<id>`, a minimal `/embed/<id>` iframe, and an oEmbed endpoint.
|
||
- Announcements feed with draft/publish/delete for coordinators and admins.
|
||
|
||
### Calendars, exports, and admin
|
||
|
||
- Personal ICS calendar feed with a rotatable token.
|
||
- Schedule and service-history CSV exports; a server-rendered PDF booth sheet for any service; browser print-to-PDF for rosters.
|
||
- Admin console: people, skill matrix, positions and requirements, service templates, reminder rules, email delivery, notification log, media storage, and backup/restore.
|
||
- Runtime settings stored in Postgres, including encrypted Gmail credentials, so mail identity and storage paths change without a deploy.
|
||
|
||
## Stack
|
||
|
||
| Layer | Choice |
|
||
| --- | --- |
|
||
| Framework | Next.js 15 App Router, React 19, TypeScript (strict) |
|
||
| Styling | Tailwind CSS 4, local shadcn-style primitives, lucide-react |
|
||
| Database | PostgreSQL 16 via Drizzle ORM (`postgres` driver) |
|
||
| Auth | Auth.js / NextAuth v5, JWT sessions, magic links, optional passwords |
|
||
| Email | Nodemailer: Gmail SMTP (admin-configured) → Postmark → console/file transport |
|
||
| Media | FFmpeg, sharp, ImageMagick + LibRaw |
|
||
| Testing | Vitest (unit), Playwright (browser) |
|
||
| Runtime | Multi-stage Docker image, Node 22, non-root user |
|
||
|
||
Business rules live in pure modules under `src/domain/` with no database imports. `src/db/` resolves facts and applies those rules in transactions; route handlers and server components stay thin.
|
||
|
||
## Quick start (Docker)
|
||
|
||
Requirements: Docker with Compose, and a generated auth secret.
|
||
|
||
```bash
|
||
cp .env.example .env
|
||
# Set NEXTAUTH_SECRET in .env:
|
||
# openssl rand -base64 32
|
||
|
||
docker compose up -d db
|
||
docker compose --profile tools build migrate
|
||
docker compose --profile tools run --rm migrate # migrations + seed
|
||
docker compose up -d --build app lumenroom
|
||
```
|
||
|
||
Open <http://localhost:3000>. The advanced photo editor (Lumenroom) is the
|
||
vendored second container and publishes on <http://localhost:8787>; it is
|
||
optional, and the **Advanced** button stays disabled until `BRIDGE_SECRET` and
|
||
`LUMENROOM_URL` are set in `.env` (see [step 15](#15-advanced-photo-editor-bridge-optional)).
|
||
The app publishes on host port `3000`; Postgres is published on `5433` but bound to `127.0.0.1` by default (set `POSTGRES_BIND=0.0.0.0` only if another host must reach it).
|
||
|
||
```bash
|
||
curl -fsS http://localhost:3000/api/health # dashboard
|
||
curl -fsS http://localhost:8787/api/health # advanced editor
|
||
```
|
||
|
||
With the default local configuration (`MAGIC_LINK_DEV_TRANSPORT=true`), requesting a sign-in link shows it in the browser and prints it in the app log:
|
||
|
||
```bash
|
||
docker compose logs -f app
|
||
```
|
||
|
||
Sign in with the seeded admin, `admin@glenloch.local`. Other seeded accounts: `coordinator@glenloch.local`, volunteers `jordan@`, `avery@`, `sam@`, and a pending trainee `riley@` (all `@glenloch.local`). Seeded data includes two Sunday services, the next two weeks of seats, skills, assignments, reminder rules, and two training lessons.
|
||
|
||
Migrations are **not** run automatically by `docker compose up`. Re-run the `migrate` command after pulling schema changes. The seed is idempotent.
|
||
|
||
## Deploying the combined stack on another system
|
||
|
||
One clone deploys everything: the dashboard (`app`), the advanced photo editor
|
||
(`lumenroom`, vendored under `lumenroom/`) and PostgreSQL (`db`). The detailed
|
||
Ubuntu walkthrough below covers each step; this is the short version for moving
|
||
the stack to a new host.
|
||
|
||
**What the target host needs**
|
||
|
||
- Docker Engine 24+ with Compose v2, and sudo access.
|
||
- A DNS name per app (for example `media.example.org` and `edit.example.org`),
|
||
or the host's LAN IP if it is not exposed to the internet.
|
||
- Inbound TCP 80 and 443 only. Ports 3000, 5433 and 8787 stay on the private
|
||
interface (`APP_BIND`, `POSTGRES_BIND`, `LUMENROOM_BIND` = `127.0.0.1`).
|
||
- The media export mounted on the host for original photos and videos
|
||
([step 9](#9-media-storage-on-nfs-or-a-local-path-required-for-event-media)).
|
||
|
||
**Get the code and secrets**
|
||
|
||
```bash
|
||
git clone <repository-url> /opt/glenloch-media
|
||
cd /opt/glenloch-media
|
||
cp .env.example .env
|
||
chmod 600 .env
|
||
|
||
openssl rand -base64 32 # NEXTAUTH_SECRET
|
||
openssl rand -hex 32 # CRON_SECRET
|
||
openssl rand -hex 24 # POSTGRES_PASSWORD (hex avoids URL encoding)
|
||
openssl rand -hex 32 # BRIDGE_SECRET, shared by app and lumenroom
|
||
```
|
||
|
||
Minimum `.env` for both containers:
|
||
|
||
```dotenv
|
||
NEXTAUTH_URL=https://media.example.org
|
||
NEXTAUTH_SECRET=<base64 value>
|
||
PUBLIC_ORIGIN=https://media.example.org
|
||
APP_ORIGIN=https://media.example.org
|
||
APP_BIND=127.0.0.1
|
||
POSTGRES_BIND=127.0.0.1
|
||
POSTGRES_USER=media
|
||
POSTGRES_PASSWORD=<hex value>
|
||
POSTGRES_DB=media
|
||
DATABASE_URL=postgres://media:<hex value>@localhost:5433/media
|
||
CRON_SECRET=<hex value>
|
||
MEDIA_ARCHIVE_DIR=/mnt/glenloch-media
|
||
|
||
# Advanced editor bridge
|
||
LUMENROOM_URL=https://edit.example.org
|
||
LUMENROOM_BIND=127.0.0.1
|
||
BRIDGE_SECRET=<hex value>
|
||
```
|
||
|
||
`BRIDGE_SECRET` is passed to both services from this one value; they must match.
|
||
`LUMENROOM_URL` is the browser-facing editor address, while the app reaches
|
||
Lumenroom inside the Compose network by service name.
|
||
|
||
**Build, migrate, start**
|
||
|
||
```bash
|
||
docker compose config --quiet
|
||
docker compose up -d db
|
||
docker compose --profile tools build migrate
|
||
docker compose --profile tools run --rm migrate
|
||
docker compose up -d --build app lumenroom
|
||
docker compose ps
|
||
curl -fsS http://127.0.0.1:3000/api/health
|
||
curl -fsS http://127.0.0.1:8787/api/health
|
||
```
|
||
|
||
Both `app` and `lumenroom` must be `healthy`. `docker compose up -d --build`
|
||
without a service name also works and builds both images; naming them is just an
|
||
explicit version of the same command.
|
||
|
||
**Finish and verify**
|
||
|
||
1. Complete first sign-in and admin bootstrap ([step 5](#5-first-sign-in-and-admin-bootstrap)).
|
||
2. Save the media share in Settings → Media storage ([step 9](#9-media-storage-on-nfs-or-a-local-path-required-for-event-media)).
|
||
3. Put both hostnames in the reverse proxy ([step 6](#6-reverse-proxy-and-tls-with-caddy)) and reload Caddy.
|
||
4. Open an event photo and click **Advanced**: the editor should open in a new tab, already signed in, with a banner showing **Save to event**. If it reports the editor is not configured, `BRIDGE_SECRET` or `LUMENROOM_URL` is missing or the two secrets differ.
|
||
|
||
**Moving an existing installation.** Run Admin → Backup & restore on the old
|
||
host, copy the ZIP and `.env` (especially `NEXTAUTH_SECRET`) to the new host,
|
||
bring the stack up as above, then restore through the same admin panel. Original
|
||
media comes from the ZIP or the share itself. The `lumenroom-data` volume holds
|
||
only temporary bridge data and does not need to move.
|
||
|
||
## Local development
|
||
|
||
```bash
|
||
pnpm install
|
||
cp .env.example .env
|
||
docker compose up -d db
|
||
|
||
pnpm db:migrate
|
||
pnpm db:seed
|
||
pnpm dev
|
||
```
|
||
|
||
`pnpm dev` uses Turbopack. If a production `.next/` directory is present, remove it first (`rm -rf .next`); the two modes can conflict.
|
||
|
||
### Scripts
|
||
|
||
| Command | Purpose |
|
||
| --- | --- |
|
||
| `pnpm dev` | Development server (Turbopack) |
|
||
| `pnpm build` / `pnpm start` | Production build / start |
|
||
| `pnpm typecheck` | `tsc --noEmit` |
|
||
| `pnpm lint` | ESLint |
|
||
| `pnpm test` / `pnpm test:watch` | Vitest unit tests |
|
||
| `pnpm test:e2e` | Playwright (builds and starts its own server) |
|
||
| `pnpm db:generate` | Generate a Drizzle migration from schema changes |
|
||
| `pnpm db:migrate` | Apply migrations |
|
||
| `pnpm db:seed` | Idempotent seed |
|
||
| `pnpm db:prune` | Remove orphaned user-owned rows |
|
||
|
||
## Configuration
|
||
|
||
Copy `.env.example` to `.env`; never commit real secrets (`.env*` is ignored, `.env.example` is not).
|
||
|
||
| Variable | Purpose |
|
||
| --- | --- |
|
||
| `DATABASE_URL` | Postgres connection string for host-side CLI commands. Compose builds the app/migrate URL from `POSTGRES_*` and uses `db:5432`; local dev uses `localhost:5433`. |
|
||
| `POSTGRES_USER`, `POSTGRES_PASSWORD`, `POSTGRES_DB` | Compose database credentials. Applied only when the `pgdata` volume is first initialized; use a URL-safe password (hex is simplest). |
|
||
| `POSTGRES_PORT`, `POSTGRES_BIND` | Host publishing for Postgres. Defaults: `5433` on `127.0.0.1`. |
|
||
| `APP_PORT`, `APP_BIND` | Host publishing for the app. Default: `3000` on all interfaces; set `APP_BIND=127.0.0.1` behind a reverse proxy. |
|
||
| `NEXTAUTH_SECRET` | Auth.js signing secret **and** the at-rest encryption key for the stored Gmail app password. Rotating it invalidates sessions and makes the stored SMTP password undecryptable. |
|
||
| `NEXTAUTH_URL` | Base URL for Auth.js. Keep it HTTP locally; an HTTPS value marks the session cookie `Secure`, which breaks plain-HTTP LAN access. |
|
||
| `PUBLIC_ORIGIN` | Canonical origin used in emailed links. **Set this in any off-LAN deployment**; if empty, links use the request origin/Host header. |
|
||
| `APP_ORIGIN` | Fallback application origin. |
|
||
| `CHURCH_TIMEZONE` | Display timezone; scheduling itself stores UTC instants and local dates. Defaults to `America/New_York`. |
|
||
| `AUTO_ACTIVATE_NEW_USERS` | `false` (default) sends unknown emails to `pending_approval`; `true` is for dev/test only. |
|
||
| `MAGIC_LINK_DEV_TRANSPORT` | Shows/prints the sign-in link instead of emailing it. Defaults on outside production; compose sets `true` for first login. |
|
||
| `ALLOW_DEV_RESET` | Enables the destructive `POST /api/dev/reset` endpoint. Must stay `false` in real deployments. |
|
||
| `CRON_SECRET` | Bearer/query secret for the cron HTTP routes. Empty means session-only. |
|
||
| `POSTMARK_SERVER_TOKEN`, `POSTMARK_FROM` | Optional Postmark fallback and default sender. Admin email settings take precedence. |
|
||
| `OUTBOX_DIR` | Console email transport directory (`/tmp/outbox` in compose). |
|
||
| `UPLOAD_DIR` | Training attachments only (`/tmp/uploads` in compose). Event photos and videos never live here. |
|
||
| `ARCHIVE_DIR`, `NFS_SHARE`, `ARCHIVE_FOLDER` | Mount path inside the container, the reported share, and the default folder. This is the primary storage for original event photos and videos; a named share plus a writable path is required or uploads and photo editing stay disabled. |
|
||
| `MEDIA_ARCHIVE_DIR` | **Compose-only host path** mounted at `/archive` for the NFS export. |
|
||
| `LUMENROOM_URL`, `BRIDGE_SECRET` | Advanced editor bridge: the browser-facing address of the Lumenroom container and the shared token secret. Both are required for the **Advanced** button; leave empty to run without the editor. |
|
||
| `LUMENROOM_PORT`, `LUMENROOM_BIND` | **Compose-only** host publishing for Lumenroom. Default `8787` on all interfaces; set `127.0.0.1` behind a reverse proxy. |
|
||
| `SENTRY_DSN` | Declared but not wired to any integration. |
|
||
|
||
Volumes in Compose: `pgdata`, `outbox-data`, `uploads-data`, and either `archive-data` or the host `MEDIA_ARCHIVE_DIR` bind mount (the latter is what holds original photos and videos). Back these up together.
|
||
|
||
## Email delivery
|
||
|
||
Delivery is resolved at send time, in order:
|
||
|
||
1. **Gmail SMTP** configured in Admin → Email delivery (address + app password). The password is encrypted with AES-256-GCM using `NEXTAUTH_SECRET`.
|
||
2. **Postmark**, when `POSTMARK_SERVER_TOKEN` is set.
|
||
3. **Console transport**, which writes JSON messages under `OUTBOX_DIR` (development fallback).
|
||
|
||
The sender address and admin notification inbox are runtime settings. Admin → Notifications shows the outbox, allows retrying failed/suppressed rows, and sends a test message.
|
||
|
||
## Scheduled jobs
|
||
|
||
There is no in-app scheduler. Call these routes on a timer with `Authorization: Bearer $CRON_SECRET` (an authorized admin session also works):
|
||
|
||
| Route | Suggested cadence | Purpose |
|
||
| --- | --- | --- |
|
||
| `GET /api/dev/cron/instances` | Daily | Materialize upcoming service instances |
|
||
| `GET /api/dev/cron/slots` | Daily, after instances | Materialize seats (skips published weeks) |
|
||
| `GET /api/dev/cron/notifications` | Every 5 minutes | Claim and dispatch due outbox rows |
|
||
| `GET /api/dev/cron/complete` | Daily, after the last service | Complete past assignments and update serving history |
|
||
|
||
Set `CRON_SECRET` before enabling the timer; without it the routes only accept an authenticated session.
|
||
|
||
## Backup and restore
|
||
|
||
Admin → Backup & restore downloads one ZIP containing:
|
||
|
||
- `dump.sql` — schema, data, constraints, indexes, and the migration ledger;
|
||
- `uploads/` — training attachments;
|
||
- `archive/` — the media storage mount: original event photos, video originals/derivatives, and dated delivery folders;
|
||
- `manifest.json` — timestamp, app version, SHA-256 checksum, and included areas.
|
||
|
||
The manifest excludes `.env` and the console outbox. **Store `NEXTAUTH_SECRET` with the backup** — it decrypts the stored Gmail app password.
|
||
|
||
To restore: bring up a fresh stack, run migrations and seed, sign in as an admin, open Admin → Backup & restore, upload the ZIP, type `RESTORE`, and confirm. The database load is one transaction, so an incompatible dump rolls back. Restore replaces the current database and the file areas named in the manifest.
|
||
|
||
## Roles and permissions
|
||
|
||
| Permission | Admin | Coordinator | Volunteer | Trainee |
|
||
| --- | :---: | :---: | :---: | :---: |
|
||
| `admin.settings`, `users.manage`, `training.author`, `design.theme` | ✅ | — | — | — |
|
||
| `content.author`, `schedule.publish` | ✅ | ✅ | — | — |
|
||
| `schedule.view`, `volunteer.serve`, `volunteer.blackout`, `roster.view` | ✅ | ✅ | ✅ | partial (no roster) |
|
||
|
||
- **Admin** — everything, including system settings, people administration, and design/theme.
|
||
- **Coordinator** — scheduling, coverage, events, people operations, training, and announcements; no system/theme settings.
|
||
- **Volunteer** — set availability, view the schedule/roster, confirm or decline assignments, edit their profile.
|
||
- **Trainee** — shadow seat access without full roster visibility.
|
||
|
||
Route handlers enforce permissions server-side (`src/auth/api.ts`); the UI only hides controls. `/admin` redirects non-admins.
|
||
|
||
## Testing
|
||
|
||
```bash
|
||
pnpm typecheck
|
||
pnpm lint
|
||
pnpm test
|
||
pnpm test:e2e
|
||
pnpm build
|
||
```
|
||
|
||
Playwright builds and starts the app on port 3000 and resets the database between suites. **Never point it at a database you care about.** Use a disposable database:
|
||
|
||
```bash
|
||
TEST_DATABASE_URL=postgres://media:media@localhost:5433/media_e2e pnpm test:e2e
|
||
```
|
||
|
||
If a server is already listening on port 3000, Playwright reuses it; stop the dev server first so the test build and database are the ones under test.
|
||
|
||
The unit suite covers pure domain rules, auth/permissions/tokens, uploads, rate limiting, event access, photo/video helpers, and backup/export logic. `.github/workflows/ci.yml` defines the full check sequence: migration drift, typecheck, lint, unit tests, migrations, E2E, and build.
|
||
|
||
## Production deployment on Ubuntu
|
||
|
||
This is the full path for a fresh Ubuntu 22.04/24.04 host using Docker. The result is the app on `127.0.0.1:3000`, Postgres on `127.0.0.1:5433`, Caddy terminating TLS on ports 80/443, and cron driving the background jobs.
|
||
|
||
**Host requirements**
|
||
|
||
- Ubuntu 22.04 LTS or 24.04 LTS with sudo access.
|
||
- 2 vCPU and 2 GB RAM minimum (4 GB for heavy video processing), 20 GB free disk plus space for media.
|
||
- A DNS `A` record (and `AAAA` if using IPv6) for the hostname, pointing at the server.
|
||
- Inbound TCP 22, 80, and 443 allowed. Do **not** expose 3000 or 5433.
|
||
- An NFS export or host directory for original photo/video storage (required for event media).
|
||
|
||
### 1. Install Docker Engine and Compose
|
||
|
||
```bash
|
||
sudo apt-get update
|
||
sudo apt-get install -y ca-certificates curl gnupg
|
||
sudo install -m 0755 -d /etc/apt/keyrings
|
||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg \
|
||
| sudo gpg --dearmor --yes -o /etc/apt/keyrings/docker.gpg
|
||
sudo chmod a+r /etc/apt/keyrings/docker.gpg
|
||
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" \
|
||
| sudo tee /etc/apt/sources.list.d/docker.list >/dev/null
|
||
sudo apt-get update
|
||
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
|
||
sudo usermod -aG docker "$USER"
|
||
newgrp docker
|
||
docker compose version
|
||
```
|
||
|
||
### 2. Put the code on the server
|
||
|
||
```bash
|
||
sudo mkdir -p /opt/glenloch-media
|
||
sudo chown "$USER":"$USER" /opt/glenloch-media
|
||
git clone https://git.maple-street.net/bhursey/glenloch-media.git /opt/glenloch-media
|
||
cd /opt/glenloch-media
|
||
```
|
||
|
||
For a private repository, configure a read-only deploy key or access token in your Git host instead of embedding a password in the clone URL. Keep the checkout on `main`.
|
||
|
||
### 3. Create the environment file
|
||
|
||
```bash
|
||
cp .env.example .env
|
||
chmod 600 .env
|
||
openssl rand -base64 32 # NEXTAUTH_SECRET
|
||
openssl rand -hex 32 # CRON_SECRET
|
||
openssl rand -hex 24 # POSTGRES_PASSWORD (hex avoids URL encoding)
|
||
```
|
||
|
||
Edit `.env`. Minimum production values:
|
||
|
||
```dotenv
|
||
NEXTAUTH_URL=https://media.example.org
|
||
NEXTAUTH_SECRET=<base64 value>
|
||
PUBLIC_ORIGIN=https://media.example.org
|
||
APP_ORIGIN=https://media.example.org
|
||
|
||
APP_BIND=127.0.0.1
|
||
POSTGRES_BIND=127.0.0.1
|
||
POSTGRES_USER=media
|
||
POSTGRES_PASSWORD=<hex value>
|
||
POSTGRES_DB=media
|
||
DATABASE_URL=postgres://media:<hex value>@localhost:5433/media
|
||
|
||
CHURCH_TIMEZONE=America/New_York
|
||
AUTO_ACTIVATE_NEW_USERS=false
|
||
ALLOW_DEV_RESET=false
|
||
|
||
# Bootstrap only. Set to false before exposing the app (step 5).
|
||
MAGIC_LINK_DEV_TRANSPORT=true
|
||
|
||
CRON_SECRET=<hex value>
|
||
POSTMARK_FROM=media@example.org
|
||
# POSTMARK_SERVER_TOKEN=... # optional; Gmail can be configured in Admin instead
|
||
|
||
# Advanced photo editor (optional; omit to run without it)
|
||
LUMENROOM_URL=https://edit.example.org
|
||
LUMENROOM_BIND=127.0.0.1
|
||
BRIDGE_SECRET=<hex value>
|
||
```
|
||
|
||
Notes:
|
||
|
||
- `NEXTAUTH_URL` and `PUBLIC_ORIGIN` must be the public HTTPS origin. An HTTPS `NEXTAUTH_URL` makes the session cookie `Secure`, so do not sign in over plain HTTP once it is set.
|
||
- `POSTGRES_*` is applied when the `pgdata` volume is first initialized. Changing it later does **not** change the existing role; rotate with SQL (`ALTER ROLE`) or recreate the volume.
|
||
- `DATABASE_URL` is for host-side CLI commands. Compose builds the app's internal URL from `POSTGRES_*`.
|
||
- Back up `NEXTAUTH_SECRET` with the database: it encrypts the stored Gmail app password.
|
||
|
||
Validate the rendered Compose configuration before starting:
|
||
|
||
```bash
|
||
docker compose config --quiet
|
||
```
|
||
|
||
### 4. Build, migrate, and start
|
||
|
||
```bash
|
||
docker compose up -d db
|
||
docker compose --profile tools build migrate
|
||
docker compose --profile tools run --rm migrate
|
||
docker compose up -d --build app lumenroom
|
||
docker compose ps
|
||
curl -fsS http://127.0.0.1:3000/api/health
|
||
curl -fsS http://127.0.0.1:8787/api/health
|
||
```
|
||
|
||
Rebuild `migrate` as shown; `docker compose run` reuses the last built tools image, so without the build step an update can run stale seed code against a newer schema.
|
||
|
||
`migrate` runs migrations **and the demo seed** (seeded services, sample volunteers, and `admin@glenloch.local`). The seed is idempotent. For a clean production dataset, sign in with the seeded admin, then edit the services and people in Admin; do not re-run the seed after customizing.
|
||
|
||
### 5. First sign-in and admin bootstrap
|
||
|
||
Keep the app on loopback and use an SSH tunnel for this step:
|
||
|
||
```bash
|
||
ssh -L 3000:127.0.0.1:3000 you@media.example.org
|
||
```
|
||
|
||
Open `http://localhost:3000/login`, request a link for `admin@glenloch.local`, and read it from the page or from `docker compose logs app`. Then:
|
||
|
||
1. Admin → People: change the admin name and email to the real person, and create real accounts.
|
||
2. Admin → Services: set real service times, roles, and headcounts.
|
||
3. Remove or deactivate the seeded demo people.
|
||
4. Configure the real sender in Admin → Email delivery (Gmail app password) or set `POSTMARK_SERVER_TOKEN`.
|
||
|
||
Only after that, set `MAGIC_LINK_DEV_TRANSPORT=false` in `.env` and restart:
|
||
|
||
```bash
|
||
docker compose up -d app
|
||
```
|
||
|
||
**Do not expose the app publicly while the dev transport is on:** it displays sign-in links in the browser. Keep `APP_BIND=127.0.0.1` until bootstrap is finished.
|
||
|
||
### 6. Reverse proxy and TLS with Caddy
|
||
|
||
Install Caddy from its official repository:
|
||
|
||
```bash
|
||
sudo apt-get install -y debian-keyring debian-archive-keyring apt-transport-https curl
|
||
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' \
|
||
| sudo gpg --dearmor --yes -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
|
||
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' \
|
||
| sudo tee /etc/apt/sources.list.d/caddy-stable.list >/dev/null
|
||
sudo apt-get update
|
||
sudo apt-get install -y caddy
|
||
```
|
||
|
||
Write `/etc/caddy/Caddyfile` (replace the hostname):
|
||
|
||
```caddyfile
|
||
media.example.org {
|
||
encode zstd gzip
|
||
reverse_proxy 127.0.0.1:3000
|
||
}
|
||
|
||
edit.example.org {
|
||
reverse_proxy 127.0.0.1:8787
|
||
}
|
||
```
|
||
|
||
The second site is the advanced editor. Give it the same pattern as the app:
|
||
set `LUMENROOM_BIND=127.0.0.1` and `LUMENROOM_URL=https://edit.example.org`, and
|
||
point DNS for that hostname at the server too. If you leave the editor out,
|
||
remove its site block and set no `BRIDGE_SECRET`; the **Advanced** button then
|
||
reports that the editor is not configured.
|
||
|
||
```bash
|
||
sudo caddy validate --config /etc/caddy/Caddyfile
|
||
sudo systemctl reload caddy
|
||
sudo systemctl status caddy --no-pager
|
||
```
|
||
|
||
Caddy obtains and renews the certificate automatically once DNS and ports 80/443 are correct. Nginx also works: proxy to `http://127.0.0.1:3000` and set a body limit large enough for video uploads.
|
||
|
||
### 7. Firewall
|
||
|
||
```bash
|
||
sudo ufw allow OpenSSH
|
||
sudo ufw allow 80/tcp
|
||
sudo ufw allow 443/tcp
|
||
sudo ufw enable
|
||
sudo ufw status
|
||
```
|
||
|
||
`APP_BIND=127.0.0.1`, `LUMENROOM_BIND=127.0.0.1` and `POSTGRES_BIND=127.0.0.1` keep the app, the editor and the database off the public interface; only Caddy listens on 80/443.
|
||
|
||
### 8. Background jobs (cron)
|
||
|
||
Create `/usr/local/bin/media-hub-cron`:
|
||
|
||
```bash
|
||
sudo tee /usr/local/bin/media-hub-cron >/dev/null <<'EOF'
|
||
#!/usr/bin/env bash
|
||
set -euo pipefail
|
||
cd /opt/glenloch-media
|
||
secret="$(sed -n 's/^CRON_SECRET=//p' .env | head -1)"
|
||
base="http://127.0.0.1:3000"
|
||
case "${1:-}" in
|
||
notifications) endpoints=(notifications) ;;
|
||
daily) endpoints=(instances slots complete) ;;
|
||
*) echo "usage: $0 notifications|daily" >&2; exit 2 ;;
|
||
esac
|
||
for endpoint in "${endpoints[@]}"; do
|
||
curl -fsS -H "Authorization: Bearer $secret" "$base/api/dev/cron/$endpoint" >/dev/null
|
||
done
|
||
EOF
|
||
sudo chmod 700 /usr/local/bin/media-hub-cron
|
||
```
|
||
|
||
Schedule it in root's crontab (`sudo crontab -e`):
|
||
|
||
```cron
|
||
*/5 * * * * /usr/local/bin/media-hub-cron notifications
|
||
15 3 * * * /usr/local/bin/media-hub-cron daily
|
||
```
|
||
|
||
The daily job runs instances → slots → complete in that order. Run the script manually once and check its exit status after changing `.env`.
|
||
|
||
### 9. Media storage on NFS or a local path (required for event media)
|
||
|
||
Original event photos and videos are stored **only** on the configured media storage share — it is their primary home, not a backup. Without a named share and a writable mounted path, the uploader and the photo editor are disabled with a warning; the app never falls back to storing media inside the container or on the `archive-data` volume. Photos live in `<share>/<folder>/events/<eventId>/`, and each video keeps its original, renditions, poster and sidecar together in `<share>/<folder>/videos/<eventId>/<videoId>/`.
|
||
|
||
Mounting is the deployment's job; **the app never mounts anything** and never writes event media inside the container. The recommended setup is a normal OS-level mount of the export on the Docker host, bind-mounted into the container at `/archive`.
|
||
|
||
**Step 1 — mount the export on the host (as root):**
|
||
|
||
```bash
|
||
sudo apt-get install -y nfs-common # nfs client
|
||
sudo mkdir -p /mnt/glenloch-media
|
||
sudo mount -t nfs nas.example.org:/export /mnt/glenloch-media
|
||
```
|
||
|
||
Persist it across reboots in `/etc/fstab`:
|
||
|
||
```fstab
|
||
nas.example.org:/export /mnt/glenloch-media nfs defaults,_netdev,nofail 0 0
|
||
```
|
||
|
||
Running this stack inside a Proxmox LXC container (Docker in LXC) needs one extra step on the Proxmox host, because a plain container may not mount NFS itself:
|
||
|
||
```bash
|
||
# either allow NFS mounts inside the container, then mount there as above
|
||
pct set <ctid> -features mount=nfs,nesting=1
|
||
pct restart <ctid>
|
||
|
||
# or mount on the Proxmox host and pass the directory into the container
|
||
# (no extra capability needed; the mount must exist first)
|
||
pct set <ctid> -mp0 /mnt/glenloch-media,mp=/mnt/glenloch-media
|
||
```
|
||
|
||
**Step 2 — confirm the mount and write access:**
|
||
|
||
```bash
|
||
findmnt -T /mnt/glenloch-media -o TARGET,SOURCE,FSTYPE # SOURCE nas…:/export, FSTYPE nfs/nfs4
|
||
sudo chown 100:100 /mnt/glenloch-media # or fix the export's ID mapping
|
||
sudo -u '#100' test -w /mnt/glenloch-media && echo writable
|
||
```
|
||
|
||
**Step 3 — bind it into the app and restart.** In `.env`, point `MEDIA_ARCHIVE_DIR` at the host mount:
|
||
|
||
```dotenv
|
||
MEDIA_ARCHIVE_DIR=/mnt/glenloch-media
|
||
```
|
||
|
||
```bash
|
||
docker compose up -d app
|
||
docker compose exec app grep ' /archive ' /proc/self/mounts
|
||
# nfs4 nas.example.org:/export /archive nfs4 rw,... ← good
|
||
# zfs ssd-main/subvol-125-disk-0 /archive … ← still local disk
|
||
```
|
||
|
||
Order matters: bind mounts are resolved when the container starts, so mount the export **before** `docker compose up -d app`. A mount added afterwards is invisible inside the app until it is recreated, and a missing host path makes Docker create an empty local directory — which is why the app checks the filesystem rather than trusting the path.
|
||
|
||
**Step 4 — save it in Settings → Media storage:** enter the share name (for example `nas.example.org:/export`), keep the container path `/archive`, set the subfolder, and save. The panel shows the detected filesystem and free space. Uploads, photo editing and video processing stay blocked — with the exact reason — while the saved share reads like `host:/export` but `/archive` is on a local filesystem; the app never writes media to local disk under a NAS-style share name. A path-style share such as `/archive` is treated as local storage on purpose, for deployments without a NAS.
|
||
|
||
**Alternative — let Docker mount the export.** `docker-compose.nfs.yml` asks the Docker daemon to mount NFS as the volume behind `/archive`, with no host `/etc/fstab` entry:
|
||
|
||
```dotenv
|
||
NFS_ADDR=nas.example.org
|
||
NFS_EXPORT=/export # exported path only, without the server prefix
|
||
NFS_VERSION=4 # set 3 for older exports
|
||
```
|
||
|
||
```bash
|
||
docker compose -f docker-compose.yml -f docker-compose.nfs.yml up -d
|
||
```
|
||
|
||
This needs the daemon to be allowed to mount NFS (full root, or Docker in an LXC with `mount=nfs`). In an unprivileged container it fails with `operation not permitted`; use the host mount above instead.
|
||
|
||
### 10. Email delivery
|
||
|
||
Configure one transport in Admin → Email delivery:
|
||
|
||
- **Gmail SMTP** — the sending Gmail address plus a Google app password (requires 2FA on that account). The password is stored encrypted with `NEXTAUTH_SECRET`.
|
||
- **Postmark** — set `POSTMARK_SERVER_TOKEN` and `POSTMARK_FROM` in `.env`, then `docker compose up -d app`.
|
||
|
||
Without either, mail goes to the console transport under `OUTBOX_DIR` and is visible with `docker compose logs app`. Use Admin → Notifications → **Send test** to confirm delivery.
|
||
|
||
### 11. Backups
|
||
|
||
Use Admin → Backup & restore to download a ZIP of the database dump, uploads, archive, and manifest. Keep copies off the server, and store `.env` (especially `NEXTAUTH_SECRET`) separately with the backup. Restore on a fresh stack through the same admin panel; the database load is one transaction.
|
||
|
||
At minimum, back up after every schedule/training/media milestone and before every upgrade. The database, uploads, and archive volumes live under Docker's volume directory; the application-level ZIP is the supported portable backup.
|
||
|
||
The `lumenroom-data` volume is different: it holds only Lumenroom's temporary
|
||
bridge catalog, cached previews and thumbnails, so it can be left out of backups
|
||
and rebuilt by opening events again.
|
||
|
||
### 12. Updating the deployment
|
||
|
||
Take a backup, then:
|
||
|
||
```bash
|
||
cd /opt/glenloch-media
|
||
git pull --ff-only
|
||
docker compose --profile tools build migrate
|
||
docker compose --profile tools run --rm migrate
|
||
docker compose up -d --build app lumenroom
|
||
docker compose ps
|
||
curl -fsS http://127.0.0.1:3000/api/health
|
||
curl -fsS http://127.0.0.1:8787/api/health
|
||
```
|
||
|
||
`migrate` is idempotent and also runs the seed, which does not duplicate authored lessons or existing rows. If a release is bad, rebuild the previous commit:
|
||
|
||
```bash
|
||
git log --oneline -5
|
||
git checkout <previous-commit>
|
||
docker compose up -d --build app lumenroom
|
||
# after fixing:
|
||
git switch main
|
||
```
|
||
|
||
### 13. Health and troubleshooting
|
||
|
||
| Symptom | Check |
|
||
| --- | --- |
|
||
| 502 from Caddy | `docker compose ps` (app should be `healthy`), then `docker compose logs --tail=100 app`. |
|
||
| Login link not delivered | `MAGIC_LINK_DEV_TRANSPORT`, Gmail/Postmark configuration, `docker compose logs app`, and the console outbox. |
|
||
| `password authentication failed` | `POSTGRES_PASSWORD` changed after the volume was initialized. Use the original role password or rotate it with SQL. Changing the env alone does not update Postgres. |
|
||
| Secure-cookie/login loop | `NEXTAUTH_URL` and `PUBLIC_ORIGIN` must exactly match the HTTPS origin in the browser. |
|
||
| Wrong links in email | Set `PUBLIC_ORIGIN`; otherwise links derive from the request Host header. |
|
||
| Video upload/encode fails | Free disk space on the media storage share and `docker compose logs app` for FFmpeg errors. |
|
||
| Uploads/editing are disabled | Settings → Media storage needs a share name and a mounted path that UID 100 can write to; the banner states the exact failure. |
|
||
| Uploads are blocked with "not a network mount" | The export is not actually mounted: either add `docker-compose.nfs.yml` (`NFS_ADDR`/`NFS_EXPORT`) or mount it on the host and point `MEDIA_ARCHIVE_DIR` at that mount. `docker compose exec app grep ' /archive ' /proc/self/mounts` shows what the container really has. |
|
||
| Cron returns 401 | `CRON_SECRET` is set in `.env` and matches the value read by `/usr/local/bin/media-hub-cron`. |
|
||
| **Advanced** reports the editor is not configured | `LUMENROOM_URL` and `BRIDGE_SECRET` are set in the app's environment, and Lumenroom has the same `BRIDGE_SECRET`. Restart both: `docker compose up -d app lumenroom`. |
|
||
| Advanced opens but the editor fails to load or is blank | `docker compose ps` should show `lumenroom` as `healthy`; `curl -fsS http://127.0.0.1:8787/api/health`; check `LUMENROOM_URL` is reachable from users' browsers and the proxy forwards `edit.example.org` to `127.0.0.1:8787`. |
|
||
| Disk filling up | Docker log rotation is capped at 10 MB × 3 per service; remove old backups, exports, and unused media. |
|
||
|
||
### 14. Production checklist
|
||
|
||
- [ ] `NEXTAUTH_SECRET` generated, backed up, and not reused from development.
|
||
- [ ] `PUBLIC_ORIGIN` and `NEXTAUTH_URL` set to the public HTTPS URL.
|
||
- [ ] `APP_BIND=127.0.0.1`, `POSTGRES_BIND=127.0.0.1`, and Postgres is not reachable from the internet.
|
||
- [ ] `AUTO_ACTIVATE_NEW_USERS=false`, `ALLOW_DEV_RESET=false`, `MAGIC_LINK_DEV_TRANSPORT=false`.
|
||
- [ ] Strong, URL-safe `POSTGRES_PASSWORD`; `.env` is mode `600`.
|
||
- [ ] TLS certificate issued; HTTP redirects to HTTPS.
|
||
- [ ] Gmail/Postmark configured and a test email received.
|
||
- [ ] Cron jobs installed and returning success.
|
||
- [ ] Backup downloaded, stored off-host, and restore tested once.
|
||
- [ ] Media storage share configured in Settings → Media storage and writable (required for event photos and videos).
|
||
- [ ] `LUMENROOM_BIND=127.0.0.1`, `LUMENROOM_URL` set to the editor's HTTPS origin, and `BRIDGE_SECRET` identical in both containers.
|
||
- [ ] `edit.example.org` (or the chosen editor hostname) proxies to `127.0.0.1:8787`, and **Advanced** opens the editor signed in.
|
||
- [ ] The `/api/dev/*` prefix is historical: the guards, not the URL, are the security boundary.
|
||
|
||
### 15. Advanced photo editor bridge (optional)
|
||
|
||
Event photos can also be opened in a separate Lumenroom deployment for a much
|
||
deeper develop module (WebGL2 tone/colour pipeline, HSL mixer, split toning,
|
||
per-channel curves, texture/dehaze/grain, history and presets). The simple
|
||
editor stays the default; the advanced one is reached from the photo editor's
|
||
**Advanced** button.
|
||
|
||
The two apps never share a database. The dashboard opens a scoped bridge
|
||
session, sends the browser to Lumenroom with a short-lived signed token, and
|
||
Lumenroom mirrors the event's photo list. Photo bytes are proxied on demand, so
|
||
nothing is copied at login; the imported event is temporary and is deleted when
|
||
that bridge session expires (12 hours by default).
|
||
|
||
**One deployment.** Lumenroom is vendored under `lumenroom/`, and
|
||
`docker-compose.yml` builds it as a second service next to the app. One clone
|
||
and one command deploy both (add `--build` when the sources changed):
|
||
|
||
```bash
|
||
docker compose up -d --build app lumenroom
|
||
```
|
||
|
||
Deployment steps are in [Deploying the combined stack on another
|
||
system](#deploying-the-combined-stack-on-another-system); the editor only needs
|
||
the extra `LUMENROOM_*` and `BRIDGE_SECRET` values shown there.
|
||
|
||
Values in `.env` (all optional except the secret):
|
||
|
||
```dotenv
|
||
# Browser-facing URL of the editor. Users' devices must reach it.
|
||
LUMENROOM_URL=http://<lan-ip>:8787
|
||
# One long random string, shared by both services.
|
||
BRIDGE_SECRET=<64+ random characters>
|
||
# Optional tuning
|
||
# GLENLOCH_URL=http://app:3000 # internal; the service default
|
||
# LUMENROOM_PORT=8787
|
||
# LUMENROOM_BIND=0.0.0.0 # set 127.0.0.1 behind a proxy
|
||
# LUMENROOM_BRIDGE_TTL_HOURS=12
|
||
# LUMENROOM_INVITE=our-team
|
||
```
|
||
|
||
`BRIDGE_SECRET` only signs bridge tokens; it is never sent to the browser as a
|
||
credential. The token minted when you click **Advanced** expires in 10 minutes
|
||
and is scoped to one user and one event. With `BRIDGE_SECRET` empty the button
|
||
is visible but reports that the editor is not configured.
|
||
|
||
`GLENLOCH_URL` is server-to-server inside the Compose network (default
|
||
`http://app:3000`), so it needs no TLS. `LUMENROOM_URL` is different: the user's
|
||
browser is redirected there, so it must be a reachable address — the host's LAN
|
||
IP for a local stack, or an HTTPS hostname in production.
|
||
|
||
**Reverse proxy.** Lumenroom's UI fetches `/api/...` from the root of its own
|
||
origin, so give it a hostname, not a path prefix:
|
||
|
||
```caddy
|
||
edit.example.org {
|
||
reverse_proxy lumenroom:8787
|
||
}
|
||
```
|
||
|
||
Then set `LUMENROOM_URL=https://edit.example.org` and
|
||
`LUMENROOM_BIND=127.0.0.1`. Putting both apps on the same site
|
||
(`media.example.org`, `edit.example.org`) keeps the redirect and its cookie
|
||
first-party.
|
||
|
||
**Data.** `lumenroom` keeps only temporary bridge data in the `lumenroom-data`
|
||
volume (SQLite catalog, cached previews and thumbnails); originals stay on the
|
||
media share and the edited JPEGs are written back there. That volume can be
|
||
left out of backups. To run the editor on its own instead, its
|
||
`lumenroom/docker-compose.yml` still works standalone.
|
||
|
||
**How it behaves.** Clicking **Advanced** in the photo editor opens the same
|
||
event in Lumenroom already signed in — no second password. Lumenroom shows a
|
||
banner with **Save to event** (renders the open photo at full size and stores it
|
||
as the event photo's edited JPEG, so thumbnails, delivery exports and the
|
||
`variant=edited` viewer use it) and **Back to dashboard**. Photos remain on the
|
||
media share; only the temporary catalog rows, thumbnails and previews live in
|
||
Lumenroom's data volume. RAW files get a 4000 px JPEG proxy generated by the dashboard's
|
||
RAW decoder (cached in Lumenroom) instead of the simple editor's 1800 px
|
||
preview, so advanced RAW exports are larger than the simple editor's.
|
||
The advanced recipe is stored in `event_photos.advanced_edit_json`, separate from
|
||
the simple editor's recipe; saving in either editor replaces the generated JPEG
|
||
that the gallery shows.
|
||
|
||
## Project structure
|
||
|
||
```text
|
||
.
|
||
├── .github/workflows/ci.yml Typecheck, lint, tests, migrations, E2E, build
|
||
├── docs/ Product spec, architecture, build plan, current state
|
||
├── drizzle/ Migrations, snapshots, journal
|
||
├── e2e/ Playwright specs and shared helpers
|
||
├── lumenroom/ Advanced photo editor (Vite + Node), built by compose
|
||
├── public/ Static assets
|
||
├── src/
|
||
│ ├── app/ Pages, layouts, API route handlers
|
||
│ ├── auth/ Auth.js config, magic links, permissions, gates
|
||
│ ├── components/ App UI and local UI primitives
|
||
│ ├── db/ Schema, queries, transactions, seed/prune/complete jobs
|
||
│ ├── domain/ Pure, unit-tested business rules
|
||
│ └── lib/ Timezone, tokens, email, storage, media, backup helpers
|
||
├── Dockerfile Multi-stage build; tools stage for migrations
|
||
├── docker-compose.yml App + Lumenroom + Postgres + one-shot migrate/seed
|
||
├── drizzle.config.ts
|
||
├── next.config.ts
|
||
├── playwright.config.ts
|
||
└── package.json
|
||
```
|
||
|
||
### Main routes
|
||
|
||
| Route | Purpose |
|
||
| --- | --- |
|
||
| `/home` | Personal next-serve, upcoming assignments, coverage status |
|
||
| `/dashboard` | Coordinator coverage snapshot and queues |
|
||
| `/schedule` | Week/month/year schedule; inline editing for coordinators |
|
||
| `/schedule/print`, `/run-sheet/[instanceId]` | Printable roster and editable run sheet |
|
||
| `/availability` | Personal and team blackout management |
|
||
| `/coverage` | Swap/release requests and public intake |
|
||
| `/events`, `/events/[id]` | One-off events, briefs, photographers, photo gallery |
|
||
| `/media`, `/media/[id]` | Photo/video library and public video page |
|
||
| `/training`, `/training/guides/*` | Lessons, attachments, role guides |
|
||
| `/announcements` | Team feed |
|
||
| `/roster` | Active team directory |
|
||
| `/profile`, `/settings` | Personal details, skills, calendar feed, account security |
|
||
| `/admin` | Admin console |
|
||
| `/login`, `/respond`, `/request-coverage`, `/watch/[id]`, `/embed/[id]` | Public or token-based entry points |
|
||
|
||
## Documentation
|
||
|
||
- [docs/PROJECT-STATE.md](docs/PROJECT-STATE.md) — detailed code map, data model, route inventory, risks.
|
||
- [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) — architecture and design rationale.
|
||
- [docs/BUILD-SPEC.md](docs/BUILD-SPEC.md) — screen-by-screen product specification.
|
||
- [docs/BUILD-PLAN.md](docs/BUILD-PLAN.md) — phased build plan.
|
||
- [docs/FEATURE-SUMMARY.md](docs/FEATURE-SUMMARY.md) — plain-language feature list.
|
||
|
||
The planning documents describe the original long-range product and still mention deferred phases. This README reflects what is actually implemented today.
|
||
|
||
## Known gaps
|
||
|
||
- **SMS is not implemented.** SMS delivery was removed; queued SMS rows are suppressed. Default reminder rules may include an SMS channel, but only email is sent.
|
||
- Announcement bodies are still plain text; training lessons use the rich-text editor.
|
||
- Run sheets have a server-generated PDF booth sheet; rosters and history export as CSV, and the schedule/run-sheet pages still print from the browser. There is no XLSX export.
|
||
- Event seats/reminders are separate from the recurring-service slot pipeline.
|
||
- Reminder templates live in code; timing, channel set, sender identity, and storage paths are runtime settings.
|
||
- No built-in cron runner, delivery webhooks/bounce handling, or observability integration. Retention is implemented (`/api/dev/cron/retention`) but still needs a scheduler entry.
|
||
- `PUBLIC_ORIGIN` must be set in production, otherwise emailed links are derived from the request host.
|