diff --git a/README.md b/README.md index d298647..ce18a64 100644 --- a/README.md +++ b/README.md @@ -1,105 +1,658 @@ # Luminary -A browser-based photo catalog and editor built for a small team: events, ratings, -filtering, and a non-destructive RAW-capable develop module. +A browser-based photo catalog and non-destructive editor built for a small team: +event organisation, culling, ratings and flags, client proofing, and a RAW-capable +develop module with lens correction, local masks, HDR/panorama/focus merges and +print/export. -Two ways to run it: +The app runs in two modes. With no server it is a private, offline catalog stored in +IndexedDB. With the included team server it gains accounts, a shared SQLite catalog, +RAW decoding, client galleries, storage quotas and email notifications. -| Mode | Storage | Raw support | -| --- | --- | --- | -| Browser only (`npm run dev`) | IndexedDB on this device | No — raw files need the server | -| Team server (`npm run server` + `npm run dev`) | SQLite + files on disk under `server/data` | Yes — LibRaw demosaic for all vendors | +| Mode | How to run | Catalog storage | RAW files | Accounts / galleries | +| --- | --- | --- | --- | --- | +| Browser only | `npm run dev` | IndexedDB on this device | No — raw needs the server | No | +| Team server | `npm run server` + `npm run dev` (or `npm start` behind a build) | SQLite + files under `server/data` | Yes — LibRaw demosaic | Yes | + +Everything edits the same `Edits` JSON document, so a photo edited locally keeps its +look when it is later uploaded to a server workspace. + +--- + +## Contents + +- [Feature tour](#feature-tour) +- [Requirements](#requirements) +- [Quick start](#quick-start) +- [Configuration](#configuration) +- [Production deployment](#production-deployment) +- [Docker](#docker) +- [Architecture](#architecture) +- [Data model and storage](#data-model-and-storage) +- [HTTP API](#http-api) +- [Accounts, sessions and workspaces](#accounts-sessions-and-workspaces) +- [Quotas, warnings and scheduled pruning](#quotas-warnings-and-scheduled-pruning) +- [Email setup](#email-setup) +- [Media Team Hub bridge](#media-team-hub-bridge) +- [Raw pipeline](#raw-pipeline) +- [Detail-preserving denoise](#detail-preserving-denoise) +- [Lens profiles](#lens-profiles) +- [Development workflow](#development-workflow) +- [Troubleshooting](#troubleshooting) +- [Limitations](#limitations) +- [Third-party software and licences](#third-party-software-and-licences) + +--- + +## Feature tour + +**Library.** Events in a sidebar (create, rename, delete, drag to reorder; drop photos +onto an event to move them), drag to reorder photos inside a view, star ratings, +pick/reject flags, five colour labels, and filters over rating, unrated, flag, labels, +"edited only" and free text (name, camera, lens, keywords). Sort by capture date, +import date, name, rating or manual order. Multi-select with shift-ranges and bulk +actions; rubber-band selection by dragging on empty space. Right-click any photo for +rating, flags, labels, open, copy/paste settings, export and delete. Deleted photos go +to Trash with restore, permanent delete and empty-all. Select 2–4 photos and press +**C** for a full-screen compare survey; double-click a frame to develop it. Selected +photos can be grouped into a stack that collapses to one card with a count badge. +**⌘K / Ctrl+K** opens a command palette that searches the whole catalog without +changing the current filters. + +**Develop.** A WebGL2 multi-pass pipeline (`src/gl/renderer.ts`), per photo, +non-destructive: + +- white balance, exposure, contrast, highlights/shadows/whites/blacks +- texture, clarity, dehaze, vibrance, saturation, black & white mix +- RGB and per-channel tone curves +- 8-band HSL colour mixer, split toning / colour grading +- sharpening, luminance noise reduction +- vignette, grain +- crop with nine aspect ratios, straighten, 90° rotation, flips +- local adjustments (up to four layers): brush, linear gradient and radial masks with + feather, invert, luminance/hue/saturation ranges, and per-layer exposure, contrast, + highlights, shadows, temperature, tint and saturation. Masks follow crops, zoom, + healing and lens correction; Copy mask / Paste mask move one layer between photos +- full Lensfun profiles: distortion, transverse chromatic aberration and vignetting + from the official database, with manual lens search, "Match EXIF lens" + auto-detection, per-correction switches and automatic edge scaling. Read the focal + length and aperture from each photo, save a profile as the default for a camera + + EXIF lens pair, and matching imports apply it automatically +- manual perspective correction: vertical/horizontal keystone, fine rotation and + scale, applied while sampling the source +- spot healing brush (**Q**): click a blemish, drag to move it, Alt-drag the sample, + adjustable size and feather +- scroll-wheel zoom with a Fit / 100% readout, drag to pan, double-click to toggle; + right-click the canvas for zoom, crop, copy/paste and export +- histogram, built-in and saved presets, history with undo/redo, selective + copy/paste and batch sync, named snapshots, virtual copies, before/after (**\**) +- on-device auto subject, sky and background masks (no model download), an + ISO/camera-aware noise starting point, edge-aware lens-softness compensation, and an + approximate paper soft-proof preview +- HDR merge with alignment, horizontal panorama stitching and focus stacking; each + result is added to the catalog as a new editable photo +- browser print layouts (A4, Letter, 5×7) rendered through the develop pipeline + +**Proofing galleries.** Turn an event into a public link (`/g/`) from **Share**. +Clients need no account: they see that event's live photos, heart favourites, leave +per-photo comments, mark a photo approved or needing changes, and download proofs +individually or as one ZIP. Feedback shows up on the library grid and in the "Client +picks", "Approved" and "Changes" filters. Revoking a link drops its picks and feedback. + +**Team accounts.** The first signup becomes the admin. Admins create single-use invite +links (`/join/`) with an optional email lock and 1–30 day expiry, copy them from +the admin panel, see who joined, disable or delete accounts, and revoke pending links. +Accounts are workspaces: each user sees only their own events and photos, while admins +get an overview of every account, event and byte in the catalog. + +**Storage quotas.** Every account has a quota (100 GiB by default). At 90% the user is +warned in the app and by email (at most one reminder per day). Admins can change a +quota, schedule a 24-hour cleanup of the oldest content, send a warning immediately, or +cancel a scheduled cleanup. Cleanups stop at a target percentage of the quota instead +of deleting the whole original plan. + +**Catalog workflow.** Editable title, caption, creator, copyright and keyword chips +with a keyword library and reusable metadata presets. Save the current filters and sort +order as a smart collection. Virtual copies share the master file but keep independent +edits; named snapshots preserve alternative looks. + +**Export and print.** JPEG, PNG, WebP or uncompressed 16-bit TIFF; quality; resize by +long edge or percent; filename template (`{name}`, `{date}`, `{time}`, `{index}`); saved +export recipes; output sharpening; watermark; XMP metadata embedded in JPEGs; an +embedded sRGB ICC profile; batch export as one ZIP or separate files. Full-resolution +export runs through the same renderer as the screen preview. + +**Administration.** Users, roles, invites, catalog backup/restore, per-account quotas, +email settings and a storage relocation tool are all in one panel. + +--- + +## Requirements + +| Component | Requirement | +| --- | --- | +| Node.js | 24 LTS (what the Docker image uses). `node:sqlite` requires 22.5+, so older releases will not boot | +| CPU / RAM | 1–2 cores and 1 GB run the app; RAW import wants ~2.5 GB with the default 4 worker pool | +| Browser | WebGL2-capable Chromium, Firefox or Safari (the Develop module requires WebGL2) | +| Disk | Originals dominate. Budget several hundred MB per shoot and set quotas accordingly | + +`sharp` and `libraw-wasm` ship prebuilt binaries for Linux, macOS and Windows; no +compiler or native toolchain is needed. `sharp` is optional at runtime: without it the +server encodes proxies as PNG and skips EXIF-aware resizing. + +--- ## Quick start ```bash npm install -# browser-only library -npm run dev # http://localhost:5173 +# Terminal 1 — the team server (creates server/data on first run) +LUMINARY_INVITE=our-team npm run server # http://localhost:8787 -# with the team server (enables raw + sharing) -LUMINARY_INVITE=our-team npm run server # http://localhost:8787 -npm run dev # proxies /api to the server +# Terminal 2 — the Vite dev server (proxies /api to 8787) +npm run dev # http://localhost:5173 ``` -Open the **Local only / Sign in** pill in the top bar. The first account becomes -the admin. After that, invite people from **Administration → Invites**: each link -is single-use, can be locked to an email address, expires automatically and can -be revoked. Setting `LUMINARY_INVITE` also enables a shared code for people who -prefer to register from the sign-in panel. Until you sign in, the app keeps -working exactly as it did before — entirely local. +Open . Until you sign in, the app is a local-only catalog. The +**Local only / Sign in** pill in the top bar opens the account panel; the first account +that registers becomes the admin, and later signups need an invite. -### Production +Browser-only mode is just `npm run dev` with no server running. The catalog then lives +in IndexedDB under the database name `lumenroom` (the pre-rebrand name is kept so an +existing catalog opens without a migration). + +### Everyday scripts + +| Script | What it does | +| --- | --- | +| `npm run dev` | Vite dev server on 5173, proxying `/api` to `127.0.0.1:8787` | +| `npm run server` | Node server on 8787 (creates and migrates the catalog) | +| `npm run server:dev` | Same, with `node --watch` restarting on change | +| `npm run build` | `tsc --noEmit` then `vite build` into `dist/` | +| `npm start` | One process serving `dist/` and the API (production) | +| `npm run preview` | Vite preview of the built bundle | +| `npm run typecheck` | TypeScript check only | +| `npm test` | Vitest unit suite | + +The Vite proxy target is hard-coded to port 8787, so leave `PORT` at its default while +developing with `npm run dev`. + +### First run + +On boot the server creates `DATA_DIR` (default `server/data`) and its `originals/`, +`previews/`, `thumbs/`, `denoised/`, `proofs/` and `proofThumbs/` folders, then opens +(or creates) the SQLite catalog `lumenroom.db` and applies any schema migrations. +`GET /api/health` reports `needsSetup: true` while there are no accounts. + +--- + +## Configuration + +Settings are read from the environment, with an optional legacy `LUMENROOM_*` fallback +for deployments that predate the rename (see below). A few settings can also be changed +at runtime by an admin; the admin panel value wins over the environment for mail and +storage, while quotas are stored per account in the database. + +| Variable | Default | Purpose | +| --- | --- | --- | +| `PORT` | `8787` | HTTP port (**not** prefixed with `LUMINARY_`) | +| `HOST` | `0.0.0.0` | Bind address (**not** prefixed) | +| `LUMINARY_DATA` | `server/data` | Where the database and image folders live | +| `LUMINARY_INVITE` | *(empty)* | Shared registration code for teammates; personal invite links work without it | +| `LUMINARY_MAX_UPLOAD` | `314572800` (300 MB) | Largest accepted upload, in bytes | +| `LUMINARY_RAW_EDGE` | `6000` | Long edge of the editable JPEG proxy made from a raw | +| `LUMINARY_RAW_WORKERS` | `min(4, cores−1)` | Concurrent LibRaw decoders; each holds a worker and a few hundred MB | +| `LUMINARY_RAW_IDLE_MS` | `90000` | Idle decoders are disposed after this to release memory | +| `LUMINARY_DENOISE_WORKERS` | `min(4, cores−1)` | Concurrent detail-denoise jobs (read directly from the environment) | +| `LUMINARY_QUOTA_BYTES` | `107374182400` (100 GiB) | Default per-account storage allowance | +| `LUMINARY_QUOTA_WARN_RATIO` | `0.9` | Fraction of the quota that triggers warnings, clamped to 0.5–0.99 | +| `LUMINARY_QUOTA_TARGET_RATIO` | `0.8` | Fraction a scheduled cleanup aims to leave behind, clamped to 0.5–0.95 | +| `LUMINARY_PUBLIC_URL` | *(empty)* | Public app URL used in notification emails; when empty, emails omit links | +| `LUMINARY_SMTP_HOST` | `smtp.gmail.com` | SMTP host for notifications | +| `LUMINARY_SMTP_PORT` | `465` | SMTP port | +| `LUMINARY_SMTP_SECURE` | `true` | Implicit TLS; set `false` for STARTTLS ports | +| `LUMINARY_SMTP_USER` | *(empty)* | Sending account (Gmail address by default) | +| `LUMINARY_SMTP_APP_PASSWORD` | *(empty)* | App password for that account, not the normal login password | +| `LUMINARY_SMTP_FROM` | `SMTP_USER` | Optional From address | +| `GLENLOCH_URL` | *(empty)* | Media Team Hub dashboard base URL; empty disables the bridge (**not** prefixed) | +| `BRIDGE_SECRET` | *(empty)* | Shared HMAC secret for bridge tokens (**not** prefixed) | +| `LUMINARY_BRIDGE_TTL_HOURS` | `12` | How long an imported bridge event survives without being reopened | + +**Legacy names.** Any setting resolved through the internal `setting()` helper accepts +`LUMENROOM_` as a fallback, e.g. `LUMENROOM_INVITE` or `LUMENROOM_QUOTA_BYTES`. +`PORT`, `HOST`, `GLENLOCH_URL`, `BRIDGE_SECRET` and `LUMINARY_DENOISE_WORKERS` are read +directly and have no legacy alias. + +**Non-obvious defaults.** + +- Sessions last 30 days and are stored server-side; passwords use `scrypt` with a + per-user salt and a 64-byte derived key. +- The session cookie is named `lumen_session` and is `HttpOnly; SameSite=Lax`. It is + marked `Secure` only when the request arrives with `X-Forwarded-Proto: https`. +- There is no TLS in the server. Terminate HTTPS at a reverse proxy. +- The SQLite file, the IndexedDB database and the Compose volume all keep the + `lumenroom` name so older deployments upgrade in place. + +--- + +## Production deployment ```bash -npm run build # type-checks, then bundles into dist/ -npm start # serves dist/ and the API from one process +npm ci +npm run build # type-checks and bundles dist/ +npm start # serves dist/ and /api from one Node process ``` -### Docker +The server serves the built UI with an SPA fallback (unknown non-API paths return +`index.html`), caches `/assets/*` for a year as immutable, and returns `503` with a +build hint if `dist/index.html` is missing. JSON responses are `no-store`; image bytes +are private and cacheable for an hour by default. -The image builds the UI and runs one Node process that serves both the app and -the API. Only `/data` needs to persist. +### Reverse proxy + +Forward the original scheme so session cookies are marked `Secure`: + +```nginx +server { + listen 443 ssl; + server_name photos.example.org; + + # Uploads default to a 300 MB ceiling; keep the proxy above it. + client_max_body_size 320m; + + location / { + proxy_pass http://127.0.0.1:8787; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + # RAW import uploads can take a while on a small box. + proxy_read_timeout 300s; + } +} +``` + +### Run as a service + +```ini +[Unit] +Description=Luminary photo catalog +After=network.target + +[Service] +WorkingDirectory=/srv/luminary +Environment=NODE_ENV=production +Environment=LUMINARY_DATA=/srv/luminary-data +Environment=LUMINARY_PUBLIC_URL=https://photos.example.org +ExecStart=/usr/bin/node server/index.mjs +User=luminary +Restart=on-failure +RestartSec=3 + +[Install] +WantedBy=multi-user.target +``` + +### Backups + +Two independent things to back up: + +1. **The catalog plus originals** — copy the whole data directory (or the Docker + volume). Stop the server, or accept that SQLite is in WAL mode and copy + `lumenroom.db`, `lumenroom.db-wal` and `lumenroom.db-shm` together. +2. **A logical catalog export** — an admin can download a JSON backup (events, photo + records, presets and key/value settings) from the admin panel, or via + `GET /api/admin/catalog`, and restore it with `POST /api/admin/catalog`. This does + not include image bytes; keep a file-level backup for those. + +--- + +## Docker + +The image is a multi-stage build on `node:24-bookworm-slim`: dependencies, a Vite +build, production-only `node_modules`, then a runtime layer that runs as the +unprivileged `node` user. It installs the UI and the API in one container, verifies +`dist/index.html` and the bundled user guide exist, exposes 8787 and defines a +`HEALTHCHECK` against `/api/health`. Only `/data` needs to persist. ```bash docker build -t luminary . + docker run -d --name luminary \ -p 8787:8787 \ -e LUMINARY_INVITE=our-team \ + -e LUMINARY_PUBLIC_URL=https://photos.example.org \ -v lumenroom-data:/data \ luminary ``` -The named volume deliberately keeps its original `lumenroom-data` name so an -existing Luminary catalog upgrades in place. +The default data directory inside the image is `/data`; the volume is deliberately +named `lumenroom-data` so an existing catalog upgrades in place. -Or with Compose, which wires up the volume and env vars for you: +Compose wires up the volume, environment and restart policy: ```bash LUMINARY_INVITE=our-team docker compose up -d --build ``` -The container runs as the unprivileged `node` user (uid 1000), ships a -`HEALTHCHECK` on `/api/health`, and exposes port 8787. To put it behind a TLS -proxy, forward `X-Forwarded-Proto: https` so session cookies are marked `Secure`. +Compose reads `LUMINARY_PORT` for the published port and passes through the invite, +upload, RAW, quota, mail, public-URL and bridge settings. The container port is always +8787. -Back up the catalog by copying the volume: +Back up the volume without stopping the service: ```bash docker run --rm -v lumenroom-data:/data -v "$PWD":/backup alpine \ tar czf /backup/luminary-$(date +%F).tar.gz -C /data . ``` -Environment variables: +--- -| Variable | Default | Purpose | +## Architecture + +One Node process serves the SPA and the API. There is no framework and no native +database dependency: the HTTP layer is `node:http` with a small hand-rolled router, and +the catalog is `node:sqlite` in WAL mode. + +``` +Browser + React 18 + Vite, WebGL2 develop pipeline + IndexedDB cache (offline library and local-only mode) + │ fetch /api/* (same-origin cookie session) + ▼ +Node server (node:http, port 8787) + index.mjs routes, auth gate, uploads, static hosting, SPA fallback + db.mjs SQLite schema, migrations, prepared statements + auth.mjs scrypt hashes, sessions, cookie/Bearer resolution + storage.mjs image folders, safe ids, relocation with rollback + raw.mjs LibRaw demosaic, embedded-preview fallback + libraw-*.mjs Node <-> browser shim and decoder worker pool + imaging.mjs sharp encode/resize, dependency-free PNG fallback + denoise.mjs job queue and on-disk render cache + quota.mjs usage accounting, prune plans, warnings, worker + mail.mjs nodemailer transport, admin-editable settings + bridge.mjs dashboard token verification and metadata import + zip.mjs stored-ZIP writer for gallery downloads + ▼ +Data directory + lumenroom.db SQLite (WAL) — accounts, catalog, feedback, quotas + originals/ uploaded files, byte-for-byte, original extension kept + previews/ editable JPEG proxies (raw) and normalised previews + thumbs/ grid thumbnails (server-rendered proofs are 560 px) + denoised/ full-strength denoise renders keyed by pipeline version + proofs/ rendered proofs for client galleries + proofThumbs/ thumbnails of those proofs +``` + +### Request flow + +1. `/api/*` is matched against an ordered route table (`method` + `/path/:param`). + Unmatched API paths return a JSON `404`; everything else is static hosting. +2. `currentUser()` resolves the `lumen_session` cookie first, then falls back to + `Authorization: Bearer `. A disabled account or expired session is rejected. +3. Ownership is enforced per row: events and photos carry `owner_id`, and a request for + someone else's row returns `404` rather than `403` so ids do not leak. Admin routes + use a separate `requireAdmin()` gate. +4. Errors are JSON `{ "error": "…" }` with `400`, `401`, `403`, `404`, `409`, `422` or + `500`. Bodies are parsed with per-route limits (64 KB for auth and admin user + calls, 256 KB for events, 512 KB for presets, 8 MB for photo records and JSON, and + `LUMINARY_MAX_UPLOAD` for image bytes). +5. Every response gets `X-Frame-Options: SAMEORIGIN` and `Referrer-Policy: same-origin`; + image responses add `X-Content-Type-Options: nosniff`. + +### Client structure + +| Path | Responsibility | +| --- | --- | +| `src/App.tsx` | Catalog state, filtering, sorting, sync, drag-and-drop, shortcuts | +| `src/components/` | Library grid, develop view, panels, modals, admin, galleries | +| `src/gl/renderer.ts` | WebGL2 grade → blur → finish passes, crop/geometry sampling | +| `src/gl/masks.ts` | Local adjustment mask generation and masking signatures | +| `src/lib/api.ts` | Typed client for every endpoint | +| `src/lib/db.ts` | IndexedDB stores for photos, assets, events and key/value state | +| `src/lib/edits.ts` | Edit document model, defaults, section copy, local layers | +| `src/lib/import.ts` | File ingest, EXIF read, preview/thumb creation, upload scheduling | +| `src/lib/export.ts` | Renderer-driven export, recipes, watermark, filenames, ZIP | +| `src/lib/tiff.ts`, `icc.ts` | Dependency-free 16-bit TIFF writer and sRGB profile | +| `src/lib/lensfun.ts`, `lensNames.ts`, `lensDefaults.ts` | Lensfun client, EXIF matching, saved defaults | +| `src/lib/merge.ts` | HDR / panorama / focus-stack composition | +| `src/lib/autoMask.ts`, `noiseProfile.ts` | On-device masks and ISO-aware noise starting points | +| `src/lib/curves.ts`, `whiteBalance.ts`, `clipPreview.ts`, `presets.ts` | Curve sampling, WB maths, clipping display, presets | +| `docs/user-guide/` | Source of the in-app user guide (`guide.html`), also shipped as PDF | + +The built guide is served from `/luminary-user-guide.pdf` and linked from the top bar. + +--- + +## Data model and storage + +SQLite is created and migrated at boot. All statements are prepared once in `db.mjs`. + +| Table | Contents | +| --- | --- | +| `users` | id, email (unique), name, scrypt `pass_hash`, `role`, `disabled`, `created_at` | +| `sessions` | token (primary key), user, created/expiry; purged when a session is created | +| `events` | id, `owner_id`, sort index, creation time, JSON `data` (name, notes, share token) | +| `photos` | id, `owner_id`, `event_id`, sort index, `updated_at`, `raw` flag, JSON `data` | +| `kv` | small key/value settings: presets, storage root, mail settings | +| `gallery_picks` | per-token, per-photo, per-client favourites | +| `gallery_comments` | per-token client comments with author name and timestamp | +| `gallery_reviews` | per-token, per-photo, per-client approved / changes status | +| `invites` | token, optional email lock, role, expiry, acceptance and revocation | +| `bridge_events` | imported event id, dashboard session, encrypted-at-rest token, TTL | +| `user_quota` | limit, scheduled prune time/plan, last warning timestamps | + +Photo and event records are JSON documents with a few extracted columns for ordering, +ownership and accounting. A photo's `size` drives quota maths and `deletedAt` marks +Trash. Migrations are additive and idempotent: `disabled`, `owner_id`, `share_token`, +`prune_plan` and `prune_notified_at` are added to older databases in place, and rows +that predate workspaces are assigned to the oldest account. + +### Image files + +| Folder | Naming | Notes | | --- | --- | --- | -| `PORT` | `8787` | Server port | -| `LUMINARY_DATA` | `server/data` | Where originals, previews and the database live | -| `LUMINARY_INVITE` | *(empty)* | Optional shared invite code for new accounts; personal invite links work without it | -| `LUMINARY_MAX_UPLOAD` | `300 MB` | Upload ceiling (bytes) | -| `LUMINARY_RAW_EDGE` | `6000` | Long edge of the editable proxy generated for raws | -| `LUMINARY_RAW_WORKERS` | `4` (capped at cores−1) | Raws demosaiced at once; each worker holds a LibRaw instance | -| `LUMINARY_RAW_IDLE_MS` | `90000` | Idle decoders are disposed after this, to hand memory back | -| `LUMINARY_QUOTA_BYTES` | `100 GiB` | Default per-account storage allowance (bytes) | -| `LUMINARY_QUOTA_WARN_RATIO` | `0.9` | Fraction of the quota that triggers the in-app and email warning | -| `LUMINARY_PUBLIC_URL` | *(empty)* | Public app URL included in notification emails | -| `LUMINARY_SMTP_USER` | *(empty)* | Gmail address used as the mail sender | -| `LUMINARY_SMTP_APP_PASSWORD` | *(empty)* | Gmail app password (not the normal account password) | -| `LUMINARY_SMTP_FROM` | sender address | Optional From address for notifications | +| `originals/` | `.` | Uploaded bytes, untouched; extension preserved | +| `previews/` | `.jpg` or `.png` | Editable proxies; PNG when `sharp` is unavailable | +| `thumbs/` | `.jpg` | Grid thumbnails; server-rendered proof thumbnails are 560 px | +| `denoised/` | `..jpg` | Key encodes the pipeline version; old keys are pruned | +| `proofs/` | `.jpg` | Rendered client-gallery proofs | +| `proofThumbs/` | `.jpg` | Thumbnails of those proofs | -The pre-rebrand `LUMENROOM_*` environment variable names are still accepted as -fallbacks, so existing deployments can upgrade without changing their config. +Asset ids are validated against `^[A-Za-z0-9_-]{1,80}$`; read paths treat an invalid id +as "no file" instead of throwing. Deleting a photo removes its original, preview, +thumbnail, proof, proof thumbnail and denoise renders. -## Bridge from the Media Team Hub +### Relocating image storage -A separate dashboard can hand an event over to this editor without sharing -passwords or copying the library. The dashboard signs a short-lived token, sends -the browser to `/api/bridge/login?token=…`, and this server verifies it with the -shared `BRIDGE_SECRET`, creates or reuses a user by email, imports the event's -photo list and redirects into the app with that event open. Photo bytes are -proxied from the dashboard on demand, so the import is metadata only. +An admin can point image storage at another absolute folder; the SQLite database always +stays in `LUMINARY_DATA`. The server validates the target, proves it is writable with a +probe file, moves all six asset folders (rename, falling back to copy across +filesystems), records the new root in `kv`, and rolls every file back if the move fails +partway. `GET/PUT /api/admin/storage` expose the same operation. + +--- + +## HTTP API + +Conventions: JSON in and out, `{ "error": "…" }` on failure, cookie session or +`Authorization: Bearer `. "Owner" means the caller must own the event or photo +(or be finishing an ownerless record created before workspaces existed). Gallery +routes are public and are gated only by the share token. + +### Health and auth + +| Method | Path | Auth | Purpose | +| --- | --- | --- | --- | +| GET | `/api/health` | public | Version, setup/registration state, photo count, bytes, storage root, RAW engine status and formats | +| POST | `/api/auth/register` | public | Create an account; first account becomes admin, later ones need an invite token or `LUMINARY_INVITE` | +| POST | `/api/auth/login` | public | Email + password, sets the session cookie | +| POST | `/api/auth/logout` | session | Destroys the session and clears the cookie | +| GET | `/api/auth/me` | session | Current user, or `401` | +| GET | `/api/invites/:token` | public | Invite status for the join page (email lock, role, expiry) | + +### Catalog and assets + +| Method | Path | Auth | Purpose | +| --- | --- | --- | --- | +| GET | `/api/sync` | session | Everything the workspace needs: user, events, photos, presets, proof summary | +| GET | `/api/proofs` | session | Client pick/comment/review summary for the owner's events | +| PUT | `/api/presets` | session | Replace the stored preset library | +| PUT | `/api/events/:id` | owner | Upsert an event record | +| DELETE | `/api/events/:id` | owner | Delete an event (photos are handled separately) | +| PUT | `/api/photos/:id` | owner | Upsert a photo record; accepts a data-URL thumbnail, which is written to `thumbs/` | +| DELETE | `/api/photos/:id` | owner | Delete a photo record and every asset file | +| POST | `/api/photos/:id/original?name=&mime=` | owner | Upload the original bytes; raw files are decoded to an editable proxy in the same call | +| GET | `/api/photos/:id/original` | owner | Stream the original (proxied from the dashboard for bridge photos) | +| GET | `/api/photos/:id/preview` | owner | Stream the editable proxy | +| GET | `/api/photos/:id/thumb` | owner | Stream the thumbnail (proof thumbnail first, if present) | +| POST | `/api/photos/:id/proof` | owner | Store a rendered JPEG proof and its thumbnail from base64 | +| POST | `/api/photos/:id/denoise` | owner | Queue a full-strength denoise render; returns a job id | +| GET | `/api/denoise/jobs/:id` | session | Job state: running/done/error, timing, stats, cache hit | +| GET | `/api/photos/:id/denoised?v=` | owner | Stream the cached denoise render | +| DELETE | `/api/photos/:id/denoised` | owner | Drop all denoise renders for the photo | +| GET | `/api/quota` | session | The caller's quota state | + +### Proofing galleries + +| Method | Path | Auth | Purpose | +| --- | --- | --- | --- | +| GET | `/api/events/:id/share` | owner | Share token, picks and recent feedback | +| POST | `/api/events/:id/share` | owner | Create (or return) the public token | +| DELETE | `/api/events/:id/share` | owner | Revoke the link and clear its picks, comments and reviews | +| GET | `/api/galleries/:token` | public | Event header plus live photos, pick counts and per-client feedback | +| GET | `/api/galleries/:token/photos/:id/thumb` | public | Gallery thumbnail | +| GET | `/api/galleries/:token/photos/:id/preview` | public | Gallery preview | +| GET | `/api/galleries/:token/photos/:id/download` | public | Download one proof | +| GET | `/api/galleries/:token/download-all?client=` | public | ZIP of the event's proofs, generated in-stream | +| POST | `/api/galleries/:token/picks` | public | Add or remove a client favourite | +| POST | `/api/galleries/:token/comments` | public | Append a client comment | +| POST | `/api/galleries/:token/reviews` | public | Set approved / changes / none | + +### Administration + +| Method | Path | Purpose | +| --- | --- | --- | +| GET | `/api/admin/overview` | Users, events with owner and totals, invites, catalog totals, storage, quotas, mail status | +| POST | `/api/admin/users` | Create an account directly (no invite needed) | +| PATCH | `/api/admin/users/:id` | Rename, change role, disable/enable, reset password | +| DELETE | `/api/admin/users/:id` | Delete an account (the last active admin is protected) | +| POST | `/api/admin/invites` | Create a single-use invite with optional email lock, role and 1–30 day expiry | +| DELETE | `/api/admin/invites/:token` | Revoke a pending invite | +| PUT | `/api/admin/events/:id` | Rename any account's event | +| DELETE | `/api/admin/events/:id` | Delete any account's event | +| GET | `/api/admin/catalog` | Logical catalog backup (events, photos, presets, kv) | +| POST | `/api/admin/catalog` | Restore a backup produced by the GET | +| GET | `/api/admin/storage` | Current and default storage roots, custom flag | +| PUT | `/api/admin/storage` | Move image storage to another absolute path | +| PATCH | `/api/admin/quotas/:id` | Set an account's byte limit | +| POST | `/api/admin/quotas/:id/prune` | Compute the oldest-first plan and schedule it 24 h out | +| DELETE | `/api/admin/quotas/:id/prune` | Cancel a scheduled cleanup | +| POST | `/api/admin/quotas/:id/warn` | Send the quota warning now | +| GET | `/api/admin/mail` | Mail status (never returns the password) | +| PUT | `/api/admin/mail` | Save SMTP sender settings | +| POST | `/api/admin/mail/test` | Send a test message | + +### Bridge + +| Method | Path | Auth | Purpose | +| --- | --- | --- | --- | +| GET | `/api/bridge/login?token=…` | signed token | Verify the dashboard token, link/create the account, import the event, redirect into the app | +| POST | `/api/bridge/export` | owner | Render and save an edited JPEG back to the dashboard event | + +--- + +## Accounts, sessions and workspaces + +- **Registration.** With zero accounts, `/api/auth/register` creates the first user as + admin and opens registration. After that, registration needs either a pending invite + token (`/join/`, single-use, optionally email-locked and expiring in 1–30 days) + or the shared `LUMINARY_INVITE` code. `GET /api/health` advertises + `registrationOpen` so the UI can hide the form. +- **Passwords and sessions.** Passwords are hashed with `scrypt` and a 16-byte salt, and + compared in constant time. Sessions are random 32-byte tokens stored server-side with a + fixed 30-day lifetime; logout deletes the row. Deleting or disabling a user invalidates + their sessions. +- **Workspaces.** `events.owner_id` and `photos.owner_id` scope every read and write. + `/api/sync` returns only the caller's rows, and the browser tags its IndexedDB records + with `workspace: `, so signing into a different account does not leak cached + photos into that account's library. When a signed-in account has no remote data, the + library built on that device while signed out can be claimed by it once. +- **Admins** see every account and event through `/api/admin/overview`, can rename or + delete any event, reset passwords, disable accounts and restore a catalog backup. The + last active admin cannot be removed or demoted. +- **Local-only mode.** No session and no server means no API calls: the catalog, assets + and edits live entirely in IndexedDB. Photos added locally can be claimed by a + workspace later; nothing is uploaded until then. + +--- + +## Quotas, warnings and scheduled pruning + +Usage is the sum of every photo record the account owns, **including Trash** — bytes are +only released when Trash is emptied or a photo is deleted permanently. The limit comes +from `user_quota.bytes_limit`, falling back to `LUMINARY_QUOTA_BYTES`. + +- At `LUMINARY_QUOTA_WARN_RATIO` (default 90%) `quotaState().warn` turns true, the app + shows the warning, and at most one warning email goes out per 24 hours. +- An admin can schedule a cleanup. The server computes a plan from the oldest events + first, then loose photos oldest-first, until projected usage reaches + `limit × LUMINARY_QUOTA_TARGET_RATIO`. The plan is stored on the quota row, so photos + uploaded after the warning are never caught by it. +- The user immediately receives an email listing exactly which events and photos will + be removed, then the server waits 24 hours. Deleting photos or emptying Trash in that + window cancels or shrinks the job. +- At execution the server re-checks usage. If the account is already under target, the + cleanup is cancelled, the plan is cleared, and the owner gets a "cleanup cancelled" + email; nothing is deleted. Otherwise it removes photos one by one, stopping as soon as + usage is back under the target, then reports what was freed. +- Admins can cancel a scheduled cleanup at any time and can send a warning on demand. + +Notification emails include an "open Luminary" link only when `LUMINARY_PUBLIC_URL` is +set; otherwise the link is omitted rather than pointing at `localhost`. + +--- + +## Email setup + +Notifications use SMTP through `nodemailer`. The defaults target Gmail with an app +password (Google requires 2-Step Verification before app passwords can be created): + +```bash +LUMINARY_SMTP_USER=studio@gmail.com +LUMINARY_SMTP_APP_PASSWORD=xxxxxxxxxxxxxxxx +LUMINARY_PUBLIC_URL=https://photos.example.org +npm start +``` + +An admin can also save the same settings in **Administration → Quotas**, plus a custom +host, port and TLS mode for non-Gmail providers; the saved values take precedence over +the environment, and **Send test email** verifies the transport. The API never returns +the stored password — only `hasPassword`. If email is not configured, quota warnings, +prune notices and cancellations are skipped or fail softly; the catalog keeps working. + +--- + +## Media Team Hub bridge + +A separate dashboard can hand an event to Luminary without sharing passwords or copying +the library: + +1. The dashboard signs a short-lived token for a session, event and user, then sends the + browser to `/api/bridge/login?token=…`. +2. Luminary verifies the HMAC (`g1..`, SHA-256, timing-safe), checks the + expiry, exchanges the login token for a server-side service token, and creates or + reuses a local account by email. +3. The event's photo list is mirrored into the catalog as metadata only, with ids prefixed + `br-`. Previews and thumbnails are fetched from the dashboard on demand and cached; + originals stay in the dashboard's media storage. Raws are edited on a 4000 px JPEG + proxy produced upstream, JPEG/PNG originals stream at full size. +4. The editor shows **Save to event** — which renders the open photo in the browser and + stores it on the dashboard event as the edited JPEG — and **Back to dashboard**. + +Bridge accounts get a random password hash, so they can only be reached through the +dashboard link, not the sign-in form. Imported events expire after +`LUMINARY_BRIDGE_TTL_HOURS` (default 12) and are swept on the next bridge login. ```bash GLENLOCH_URL=https://media.example.org \ @@ -108,136 +661,34 @@ LUMINARY_INVITE=our-team \ docker compose up -d --build ``` -| Variable | Default | Purpose | -| --- | --- | --- | -| `GLENLOCH_URL` | *(empty)* | Dashboard base URL; empty disables the bridge | -| `BRIDGE_SECRET` | *(empty)* | Shared HMAC secret for bridge tokens | -| `LUMINARY_BRIDGE_TTL_HOURS` | `12` | How long an imported bridge event survives | +Empty `GLENLOCH_URL` or `BRIDGE_SECRET` disables the bridge entirely. -The editor shows a banner with **Save to event** — it renders the open photo in -the browser and stores it on the dashboard event as the edited JPEG — and **Back -to dashboard**. Imported events and their catalog rows are temporary: expired -bridge events are swept on the next bridge login. Originals stay on the -dashboard's media storage; only previews and thumbnails are cached under -`LUMINARY_DATA`. RAW files are edited on a 4000 px JPEG proxy generated by the -dashboard and cached here; JPEG/PNG originals are streamed at full size. Bridge accounts have a random password hash, so they can only -be reached through the dashboard link, not the normal sign-in form. +--- -## Features +## Raw pipeline -**Library** — events in the sidebar (create, rename, delete, drag to reorder, -drop photos onto an event to move them), drag photos to reorder within a view, -star ratings, pick/reject flags, five color labels, filters (rating, unrated, -flag, labels, "edited only", free text over name/camera/lens/keywords), sorting -by capture date, import date, name, rating or manual order, multi-select with -shift-ranges and bulk actions. Right-click any photo for a menu with the star -rating, flags and color labels plus open, copy/paste settings, export and delete. -Deleted photos move to a Trash with restore, permanent delete and empty trash. -Select 2–4 photos and press **C** (or click Compare) for a full-screen survey; -double-click a frame to develop it. Selected photos can also be grouped into a -stack (`Stack`, or right-click → Stack selected): the grid collapses a stack to -one card with a count badge, and clicking the badge expands or collapses it. -Right-click → Unstack removes the grouping. +The browser cannot demosaic camera raw, so the server does it during upload: -**Develop** — a WebGL2 multi-pass pipeline, per photo, non-destructive: +1. The original file is stored byte-for-byte in `originals/` with its real extension. +2. LibRaw (`libraw-wasm`) opens it in a pooled worker with camera white balance, sRGB + output and the container's orientation, then `sharp` encodes an editable JPEG proxy + at `LUMINARY_RAW_EDGE` (6000 px by default). +3. If LibRaw cannot open the file, the largest JPEG embedded in the container is + extracted and normalised instead. The grid marks such photos `RAW` and the Info panel + reports which engine produced the proxy, so exotic or very new cameras still import. +4. Non-raw images are stored untouched and previewed by the browser; `?drop=1` forces + the server proxy path when needed. -- white balance, exposure, contrast, highlights/shadows/whites/blacks -- texture, clarity, dehaze, vibrance, saturation, black & white mix -- RGB + per-channel tone curves -- 8-band HSL color mixer, split toning / color grading -- sharpening, luminance noise reduction -- vignette, grain -- crop with nine aspect ratios, straighten, 90° rotation, flips -- local adjustments (up to four layers): brush, linear gradient and radial - masks with feather, invert, luminance/hue/saturation ranges, and per-layer - exposure, contrast, highlights, shadows, temperature, tint and saturation; - masks follow crops, zoom, healing and lens correction, and Copy mask / Paste - mask carry one layer between photos -- full Lensfun lens profiles: distortion, transverse chromatic aberration and - vignetting from the official calibration database, with manual lens search, - "Match EXIF lens" auto-detection, per-correction switches and automatic - edge scaling; focal length and aperture are read from each photo. Save a - profile as the default for a camera + EXIF lens pair and matching imports - apply it automatically, the Optics panel can show a draggable before/after - split for the lens correction, and a Settings view lists and removes saved - camera-lens defaults -- manual perspective correction: vertical/horizontal keystone, fine rotation - and scale, applied while sampling the source -- spot healing brush (Q): click a blemish, drag to move it, Alt-drag the sample, - adjustable size and feather -- scroll-wheel zoom with a Fit / 100% readout, drag to pan, double-click to zoom - in or back out; right-click the canvas for zoom, crop, copy/paste and export -- histogram, presets (built-in + saved), history with undo, selective - copy/paste and batch sync, named snapshots, virtual copies, before/after -- on-device auto subject, sky and background masks (no model download), an - ISO/camera-aware noise starting point, edge-aware lens-softness compensation, - and an approximate paper soft-proof preview -- HDR merge with alignment, horizontal panorama stitching and focus stacking; - each result is added to the catalog as a new editable photo -- browser print layouts (A4, Letter, 5×7) rendered through the develop pipeline +Formats: CR2/CR3/CRW, NEF/NRW, ARW/SRF/SR2, ORF, RW2/RWL/RAW, RAF, PEF, DNG, SRW, 3FR, +FFF, IIQ, X3F, ERF, K25/KDC, DCR, MOS, MRW, MEF, SRAW. Content sniffing checks the +container signature before wasting a decode attempt. -**Proofing galleries** — turn any event into a public link (`/g/`) from -**Share** in the top bar. Clients open it without an account, see only that -event's live photos, heart favourites, leave per-photo comments, mark a photo -approved or needing changes, and download the proof. Feedback appears on the -library grid and in the "Client picks", "Approved" and "Changes" filters. -Links can be revoked, which drops their picks and feedback. - -**Team accounts** — the first signup becomes the admin. Admins create single-use -invite links (`/join/`) with an optional email lock and 1–30 day expiry, -copy them from the admin panel, see who joined, and revoke a link at any time. - -**Storage quotas and pruning** — every account starts with a 100 GB quota. At 90% -the user sees a warning in the app and receives at most one reminder email per -day. Admins can change a quota in **Administration → Quotas**, request the oldest -content be deleted, and schedule the cleanup. Scheduling sends the user a -warning email with the exact events and photos that will be removed, then waits -24 hours before deleting them. Content added after the warning is never included -in that prune. Email uses Gmail SMTP with a Google app password, configured in -the same tab or via the `LUMINARY_SMTP_*` variables above. - -**Catalog workflow** — editable title, caption, creator, copyright and keyword -chips with a keyword library and reusable metadata presets. Save the current -filters and sort as a smart collection. Virtual copies share the master file -but keep independent edits; named snapshots preserve alternative looks. - -**Export and print** — format (JPEG/PNG/WebP), quality, resize by long edge or -percent, filename template (`{name}`, `{date}`, `{time}`, `{index}`), saved -export recipes, output sharpening, watermark, embedded XMP metadata in JPEGs, -batch export as one ZIP (or separate files), and browser print layouts. -Full-resolution export runs through the same renderer. - -## Lens profile data - -Lens correction uses the official [Lensfun](https://lensfun.github.io/) database -and its WebAssembly build (`@neoanaloglabkk/lensfun-wasm`). The runtime assets -are served from `public/lensfun/`: the library is LGPL-3.0-or-later, the camera -and lens database is CC BY-SA 3.0, and the bundled notices and license texts sit -next to the assets. This is a non-commercial project; if the database is reused -or redistributed, keep the attribution and share-alike terms. - -Profiles load lazily the first time the Optics panel needs one, so a library -that never uses them does not download the ~5 MB database. - -## Raw support - -The browser cannot decode camera raw, so the server does it: - -1. The original file is stored byte-for-byte (`server/data/originals`). -2. LibRaw (`libraw-wasm`) demosaics it with the camera's white balance and - orientation, and `sharp` encodes an editable JPEG proxy (long edge - `LUMINARY_RAW_EDGE`). -3. If LibRaw cannot open a file, the largest JPEG embedded in the container is - used instead, so exotic or very new cameras still import. The grid marks such - photos `RAW` and the Info panel reports which engine produced the proxy. - -Formats: CR2/CR3/CRW, NEF/NRW, ARW/SRF/SR2, ORF, RW2/RWL, RAF, PEF, DNG, SRW, -3FR, FFF, IIQ, X3F, ERF, K25/KDC, DCR, MOS, MRW, MEF. - -**Parallel import.** Decoding runs in a small pool of LibRaw workers (default 4, -`LUMINARY_RAW_WORKERS`) and the browser uploads four files at a time, so a card -imports several times faster than one file after another. Measured on this repo -with 8 mixed raws (20 MP average): +**Parallel import.** Decoding runs in a bounded pool of LibRaw workers (default +`min(4, cores−1)`, `LUMINARY_RAW_WORKERS`), and the browser uploads several files at a +time. Each instance owns one worker thread; extra jobs queue. Idle instances are +disposed after `LUMINARY_RAW_IDLE_MS` and recreated on demand, so a burst of imports +does not pin memory forever. A decoder that reports a dead worker is recycled rather +than returned to the pool. Measured on this repo with 8 mixed raws (20 MP average): | Workers | 8 files | Speedup | Peak memory | | --- | --- | --- | --- | @@ -245,51 +696,147 @@ with 8 mixed raws (20 MP average): | 4 | 5.2 s | 3.7× | ~2.5 GB | | 8 | 3.5 s | 5.4× | ~3.5 GB | -Raise the worker count on a big machine; keep it low on a small VPS, where each -worker can hold a few hundred MB while decoding. Workers idle for 90 s are -disposed and recreated on demand, so a burst of imports does not pin memory -forever. `GET /api/health` reports the pool size. +Raise the worker count on a big machine; keep it low on a small VPS, where each worker +can hold a few hundred MB while decoding. `GET /api/health` reports the pool size and +busy count. -## Layout +--- -``` -src/ - App.tsx state, filtering, sync, drag-and-drop, shortcuts - gl/renderer.ts WebGL2 pipeline (grade → blur → finish) - lib/lensfun.ts lazy Lensfun client, profile matching and CPU map math - lib/ db, api client, edits model, import/export, presets - components/ library grid, develop, panels, modals -public/lensfun/ vendored Lensfun WASM runtime, database and licenses -server/ - index.mjs HTTP API + static hosting - db.mjs SQLite schema (node:sqlite, no native deps) - raw.mjs LibRaw decode + embedded-preview fallback - imaging.mjs sharp encoding, PNG fallback -``` +## Detail-preserving denoise + +`server/denoise/` is a dependency-free pipeline (planes, noise estimation, colour, +detail, RGB reconstruction) copied from the `raw-noise` project. It reconstructs each +pixel as a crossfade between the source and a denoised base, so the result is bounded by +the original pixels and cannot ring or overshoot: flat noise is replaced, structure is +handed back verbatim. + +- The server always renders the full-strength denoise and the GPU blends it, so the + Amount slider is instant, one file serves every amount, and the amount cannot be + applied twice. +- Renders are cached in `denoised/` under a key that includes `PIPELINE_VERSION`. Bump + that constant whenever the copied pipeline changes output, or stale renders will be + served as current. +- Each run is seconds of CPU, so jobs go through a capped queue + (`LUMINARY_DENOISE_WORKERS`, default `min(4, cores−1)`). A second request for the same + photo joins the run already in progress instead of starting an identical one. +- The job table keeps the newest 40 entries and never drops a queued or running job. + +--- + +## Lens profiles + +Lens correction uses the official [Lensfun](https://lensfun.github.io/) database through +its WebAssembly build (`@neoanaloglabkk/lensfun-wasm`). Runtime assets are served from +`public/lensfun/`: the library is LGPL-3.0-or-later and the camera/lens database is +CC BY-SA 3.0; the bundled `LICENSE`, `NOTICE.md`, `THIRD_PARTY_LICENSES.md` and +`UPSTREAM.md` sit next to the assets. + +Profiles load lazily the first time the Optics panel needs one, so a library that never +uses lens correction does not download the ~5 MB database. A profile is built for the +photo's current focal length and aperture; it is not interpolated between zoom +positions. Camera-lens defaults require both a normalised camera and lens name to match. + +--- + +## Development workflow + +| Command | Use | +| --- | --- | +| `npm install` | Install dependencies (prebuilt `sharp`, `libraw-wasm`, Lensfun WASM) | +| `npm run server:dev` | Server with `node --watch` | +| `npm run dev` | Vite HMR on 5173 | +| `npm run typecheck` | `tsc --noEmit` | +| `npm test` | Vitest, one pass then exit | + +Conventions worth knowing before changing code: + +- The server is plain ESM (`.mjs`) with no build step. Keep it framework-free and avoid + native modules; `node:sqlite` is deliberate, and `sharp` must stay optional. +- The client is strict TypeScript with `noEmit`; Vite builds only `src/` and `public/`. +- Edits are data, not pixels: adding a control means extending `src/types.ts`, the + renderer uniforms/shaders, `normalizeEdits()` defaults, the export path and the panel + UI. The export path builds a second `Renderer`, so anything wired only into the + on-screen canvas disappears from exports. +- New image stages must be mirrored in both `src/App.tsx` (preview) and + `src/lib/export.ts` (output), or exported files will silently differ. +- Denoise output changes require a `PIPELINE_VERSION` bump in `server/denoise.mjs`. +- The SQLite schema only grows by idempotent migrations; existing catalogs must keep + opening without a manual step. + +### Tests + +`npm test` runs six Vitest files, all pure-logic: + +| File | Covers | +| --- | --- | +| `src/lib/export.test.ts` | Output dimensions for uncropped, quarter-turn, straightened and cropped frames | +| `src/lib/tiff.test.ts` | Little-endian 16-bit TIFF layout and the ICC profile tag | +| `src/lib/icc.test.ts` | The generated sRGB v2 display profile | +| `src/lib/lensNames.test.ts` | EXIF lens-name normalisation, search variants and match scoring | +| `src/lib/lensDefaults.test.ts` | Camera + lens default selection and rejection rules | +| `src/lib/editSections.test.ts` | Selective settings copy and the ISO-aware auto-noise curve | + +There are no server integration tests; the API is exercised through the UI. + +--- + +## Troubleshooting + +| Symptom | Cause and fix | +| --- | --- | +| "Cannot reach the Luminary server" in the app | The Vite dev proxy targets `127.0.0.1:8787`. Start `npm run server`, and do not change `PORT` while using `npm run dev` | +| `503` "The web build is missing" | `npm start` was run without `dist/`. Run `npm run build` first, or use `npm run dev` | +| Raw upload returns `422` | LibRaw could not decode the file and no embedded preview was found. Check `GET /api/health` → `raw.libraw`; install dependencies and confirm the camera is supported | +| Import is slow or the machine swaps | Lower `LUMINARY_RAW_WORKERS`; each decoder holds a worker and a few hundred MB | +| Emails never arrive | Gmail needs 2-Step Verification and an app password, not the account password. Use **Send test email**; admin-saved settings override the environment | +| Quota looks wrong after deleting | Trash still counts toward usage. Empty Trash to release the bytes | +| Cookies not marked `Secure` behind HTTPS | The proxy must forward `X-Forwarded-Proto: https` | +| Login page hidden after the first account | Registration is closed without an invite. Create an invite link in the admin panel or set `LUMINARY_INVITE` | +| Images moved but thumbnails 404 | Check the storage root in the admin panel; a moved library needs all six asset folders writable by the server user | +| Old deployment keeps its config | `LUMENROOM_*` names are still honoured, and the database/volume name `lumenroom` is intentionally unchanged | + +--- ## Limitations -- No cloud hosting or tethered capture. Compare is a still survey rather than a - synchronised zoom/pan view. Merge tools are translation-aligned and aimed at - bracketed, stacked or horizontal panorama sequences, not handheld multi-row - composites. -- Lens profiles are matched from the bundled Lensfun database. A photo whose - EXIF has no lens name needs a manual profile choice; a profile is built for - the photo's current focal length and aperture, not interpolated between - zoom positions. Camera defaults require both a camera and a lens name, and - only apply when the normalized EXIF pair matches one saved default. -- Raw editing works on the decoded proxy (6,000 px default), not the full sensor - mosaic; export size is bounded by the proxy. -- Temperature/tint are relative to the as-shot white balance. -- Auto masks are a lightweight on-device saliency/colour estimate, not a - downloaded segmentation model. They are a starting point that can be - feathered or inverted; complex hair and foliage edges still need a brush. -- Soft proofing approximates paper white, black point and a print gamut; it does - not apply a printer ICC profile. Use the browser print dialog for final ICC - handling. -- Denoise auto-profile is an ISO/camera-aware curve over the existing sliders, - not a calibrated per-sensor noise profile or a learned denoiser. -- Sync is whole-record: the last writer wins per photo. It is designed for a - handful of people sharing one catalog, not for concurrent batch workflows. -- Trash is a soft-delete inside the catalog; there is no automatic catalog - backup. +- **Not a cloud service.** No hosted deployment, no tethered capture, no sync client + beyond one browser tab's whole-record push. The last writer wins per photo; it is + designed for a handful of people, not concurrent batch workflows. +- **Per-account catalogs.** Workspaces are private to their owner; there is no shared + library between two members. Collaboration happens through client proofing links and + the admin overview. +- **Proxy-bounded raw.** Raw editing works on the demosaiced JPEG proxy (6000 px + default), not the sensor mosaic; export size is bounded by the proxy. +- **Approximate tools.** Temperature/tint are relative to the as-shot white balance. + Auto masks are an on-device saliency/colour estimate, not a segmentation model. Soft + proofing approximates paper white, black point and print gamut but does not apply a + printer ICC profile; use the browser print dialog for final ICC handling. The + auto-noise profile is an ISO/camera heuristic over the existing sliders, not a + calibrated sensor model. +- **Merge scope.** HDR, panorama and focus stacking are translation-aligned and aimed at + bracketed, stacked or horizontal sequences, not handheld multi-row composites. They + compose at a reduced working edge (2600 px). +- **Compare is a survey.** It shows 2–4 stills side by side, not a synchronised + zoom/pan view. +- **No automatic catalog backup.** Trash is a soft delete inside the catalog; the + database and asset folders are yours to back up (see [Backups](#backups)). +- **No TLS, 2FA or single sign-on.** Sessions are bearer tokens; serve the app behind + HTTPS and treat gallery links as public secrets. +- **Storage accounting is logical.** Quotas count photo-record `size` values, while the + disk also holds previews, thumbnails, proofs and denoise renders, so actual disk use is + higher than the quota total. + +--- + +## Third-party software and licences + +| Component | Licence / terms | +| --- | --- | +| Lensfun database and WASM build | Library LGPL-3.0-or-later; database CC BY-SA 3.0. Keep attribution and share-alike terms if reused or redistributed | +| LibRaw (`libraw-wasm`) | LGPL-2.1 / CDDL-1.0 (LibRaw terms); used for raw demosaic | +| `sharp` / libvips | Apache-2.0 | +| React, Vite, TypeScript | MIT / Apache-2.0 | +| Luminary application code | Non-commercial project; no licence file is included in this repository | + +Lensfun notices and licence texts ship in `public/lensfun/` and are served with the +assets, as the database terms require.