Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HT6iXLYUUp9pJz5Kza9xCW
5.5 KiB
Architecture
Living plan (Portuguese, editable): https://claude.ai/code/artifact/f64515d2-9d1f-47d5-ade1-743511fb3da2 This file is the in-repo summary agents work from. Decisions dated 2026-10-11.
Decisions
- One monorepo, one API, one PostgreSQL database, one account system, one UI for web and desktop.
- Built greenfield on new containers and the
nextenvironment; old projects keep running until cutover. Final domain:app.photoreport.pt. Data (accounts, galleries, sales, squads) is imported, not restarted. - Desktop = Tauri around the same React SPA (replaces the Flutter Studio).
- Develop engine = LightCraft crates (
lightcraft-develop,lightcraft-pipeline,lightcraft-raw,lightcraft-codecs,lightcraft-faces), pinned, behindengine/core. Notlightcraft-engine/catalog: our catalog is the API. - Faces:
lightcraft-faces(YuNet detection + SFace recognition, pure Rust) inworkers/render. Enabled for FPA (own photos, internal federation use for news and galleries); off by default elsewhere. - Jersey numbers: PaddleOCR in
workers/ml, matched against the squad. OpenAI fallback off by default. - CPU: no practical limit; workers scale to whatever cores are needed. Speed first.
- Priority cameras: Canon EOS R1 and R3, then pro Canon, Sony and Nikon bodies used by photojournalists.
Stack
Node 22 + TypeScript + Fastify · PostgreSQL 17 + pgvector · Prisma · BullMQ on Valkey · Socket.io (Valkey
adapter) · Garage (S3-compatible) · tusd + SFTPGo · React + Vite + Tailwind (apps/app) · Next.js
(apps/site) · Tauri 2 (apps/desktop) · Rust (engine, workers/render) · Python (workers/ml).
Realtime edits
Client sends EditEnvelope -> API validates permissions, assigns per-photo seq, stores in op log,
broadcasts EditBroadcast to user:<id> and event:<id>. Clients render locally with their own engine.
Reconnect = "everything since seq X". Offline queue: IndexedDB (web), SQLite (desktop). Conflict rule:
last writer wins per control. Slider drags are coalesced (about one command per 50 ms, one undo step per drag).
Uploads and ingest
Camera -> SFTPGo (FTP/SFTP, app passwords tied to the PhotoReport account) or desktop/browser -> tus.
Desktop sends a light preview first, original later; picks jump the queue. Routing picks the event from
camera serial, EXIF time and the photographer's schedule. Then: previews, event IPTC, OCR, faces.
Final export (workers/render) replays the op log on the original, so it matches the screen.
Client delivery (Nextcloud)
Garage is the source of truth; Nextcloud receives organised copies. Any client organization can have one or
more destinations on any Nextcloud instance, each with its own folder and file-name templates (variables
from packages/metadata). Default delivery: final edited JPEG, 4000 px long edge, maximum quality.
After upload (WebDAV chunked), create a read-only public share via OCS and store the link on the event.
| Instance | Client | Folders today | Files |
|---|---|---|---|
| cloud.photoreport.pt | FPA | /FPA/Fotos/2026_2027/Competições Nacionais/PO01 - Campeonato Betclic/20260923 - VSC x AAAS/ |
PS_<Home> x <Away>_<n>.jpg |
| liga.photoreport.pt | Liga Portugal | /LPBetclic 25-26/Jornada 1/1. Casa Pia x Sporting/; institutional events at root |
camera name (JMA27728.jpg) |
Archive import: folder names changed across seasons (LPbwin - 22-23, LPBetclic 2023-24,
LPBetclic - 24-25, LPBetclic 25-26), so the importer proposes a folder -> competition/match mapping that
an editor confirms before import.
RAW support (LightCraft rev pinned in Cargo.toml, checked 2026-10-11)
- Canon EOS R1, R3 (CR3): unverified; lossless and single-tile C-RAW decode, other CRX variants fall back to the embedded preview. No measured Canon colour calibration yet.
- Nikon Z 9, Z 8: NEF decodes except High Efficiency (HE / HE*), which is preview-only.
- Sony A9 / A9 II / A9 III: verified. Action: collect real files from each body, add them to our reference set, contribute samples upstream.
Phases (gate to pass)
- Foundation: monorepo, CI,
nextcontainers, accounts, organizations, tokens (login on web and desktop). - Ingest + library: SFTPGo/tus, routing, previews, IPTC, code replacements, culling, Nextcloud delivery (a real match arrives captioned and delivered with no manual step).
- Synced editor: native + WASM engine, op log, Socket.io, offline, render worker (PoC demo: same photo edited on web and desktop).
- Galleries and sales: PhotoReport and ShootYourMove storefronts, private galleries, Stripe, VAT/VIES, payouts, affiliates, press accounts, data import dry runs (end-to-end test purchase with invoice and payout).
- Events and printing: QR guest flow, templates, print jobs, Print Agent (a real event printed).
- Player identification: jersey OCR, faces, global search (parity with old projects validated).
- Cutover: final import, redirects, old projects read-only, then switched off.
Infrastructure (next)
| Container | Services | Domain |
|---|---|---|
| pr-api | apps/api + Socket.io (2 instances) |
api.next.photoreport.pt |
| pr-app | apps/app static |
app.next.photoreport.pt |
| pr-site | apps/site |
next.photoreport.pt + brand domains |
| pr-db | PostgreSQL 17 + pgvector, pgBackRest | internal |
| pr-queue | Valkey | internal |
| pr-storage | Garage | files.next.photoreport.pt |
| pr-ingest | SFTPGo + tusd | ftp.next.photoreport.pt (DNS-only), upload.next.photoreport.pt |
| pr-workers | workers/media + workers/render |
internal |
| pr-ml | workers/ml |
internal |