Files
photoreport/docs/ARCHITECTURE.md
T
spark c32012a0cd
ci / rust (push) Successful in 7m40s
ci / typescript (push) Successful in 10m49s
Shirt numbers: a shorts crop for football, next to the chest crop for handball
A sample of Liga Portugal 2026/27 photos (14 clubs) shows no chest numbers: the front number is on the shorts.
Each confirmed face now gives two samples (region CHEST and SHORTS); the reader tries both and keeps the more
confident reading. Faces collected before get the shorts crop once (faces.jersey_crops). Synthetic training
data also paints small side numbers.

Claude-Session: https://claude.ai/code/session_01HT6iXLYUUp9pJz5Kza9xCW
2026-10-13 21:30:38 +01:00

31 KiB
Raw Blame History

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 next environment; 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, behind engine/core. Not lightcraft-engine/catalog: our catalog is the API.
  • Faces: lightcraft-faces (YuNet detection + AuraFace v1 recognition, SFace optional; pure Rust) in workers/faces, a long-running process the background worker talks to over stdin/stdout. See "Faces" below. 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 · queues as PostgreSQL tables (FOR UPDATE SKIP LOCKED) · Socket.io fanned out with LISTEN/NOTIFY · sharp + ExifTool · local storage now, Garage (S3-compatible) later · SFTPGo (tusd later) · React + Vite + Tailwind (apps/app) · Next.js (apps/site) · Tauri 2 (apps/desktop) · Rust (engine, workers/render) · Python (workers/ml).

Realtime edits (Revelar)

One engine everywhere: engine/core wraps the LightCraft develop crates (settings, commands, decode, render). It runs natively in workers/render and in the browser as WASM (engine/wasm, about 2.5 MB, built into apps/app/public/engine/ and loaded by a Web Worker), so the desktop app (the web app in a Tauri shell) and the browser show the same pixels.

  • A window sends edit commands (never pixels) with POST /v1/photos/:id/edits ({clientId, ops: [{opId, command}]}). The API checks them against the pinned control list (controls.generated.json), assigns the per-photo seq under a row lock, stores them in photo_edits (a retried opId is stored once) and fans them out as photo.edited on the library channel. Last writer wins per control.
  • Each window replays the log with its own engine: confirmed settings plus its own unacknowledged edits on top, so edits show at once and remote ones slot in underneath. A gap in seq (lost message, reconnect) fetches GET /v1/photos/:id/develop?since=<seq>. Unsent edits stay in a per-photo outbox in local storage and are retried with back-off, so editing offline works and survives a reload.
  • Slider drags: the queued op is replaced until it is sent (about one op per 120 ms on the wire), one undo step per drag. Undo/redo are new ops that put the previous values back.
  • The worker keeps a settings snapshot per photo (develop_snapshot, snapshot_seq) and, two seconds after edits stop, renders edited thumb and preview from the original (photo.rendered with new URLs; source stays the unedited preview the editor renders on). Deliveries of edited photos are rendered by the engine from the original at the delivery size, camera EXIF copied back, orientation reset, IPTC written as before.
  • Measured: decode of a 24 MP JPEG to 2048 px about 0.5 s and a 1600 px render about 0.25 s in WASM (one thread); a 4000 px delivery render about 2 s natively.

Uploads and ingest

Camera -> SFTPGo (FTP/SFTP) into <INGEST_ROOT>/<ftp login>/. Each login is tied to one member of one organization (ftp_accounts, managed by admins). The worker (apps/api/src/worker.ts) picks a file up once its size and time stop changing, hashes it (duplicates are dropped), reads EXIF (capture time in Lisbon time unless the camera wrote an offset; a per-login clock offset fixes drifting bodies), routes it to the event the photographer is assigned to whose ingest window (default: 2 h before to 4 h after the start) holds the capture time, or to the inbox, moves it into storage and makes a 480 px thumb and a 2048 px preview. Unreadable files are kept and marked failed; non-JPEG and unknown logins are set aside in _unsupported/ and _unclaimed/. Measured locally: a dropped JPEG shows up in an open browser in about 2 s. FTP packages (ftp_plans, the old app's "pacotes", Membros → Pacotes FTP): days a login lasts and upload quotas in MB and files (0: none). Giving a login a plan sets its end date (now + days); "Renovar" adds another period from the end date, or from now once ended; the end date can also be set by hand. The auth hook refuses an ended login and hands SFTPGo expiration_date, quota_size and quota_files, which SFTPGo enforces as it counts uploads.

Local FTP (desktop app, apps/desktop/src-tauri/src/ftp.rs, libunftp): the camera sends to the photographer's own computer on the same network (port 2121, passive 50000-50100, all IPv4 interfaces), with as many logins as there are bodies, each switchable off. "Testar ligação" (ftp_check, run after every start) connects to each LAN address like a camera and reads the greeting, and on macOS reads the application firewall (socketfilterfw: block all, or PhotoReport blocked) to tell the photographer what to change. Another FTP server on the same port takes the connections, so the panel says to close it. Photos from the local FTP count as camera ingest (source DESKTOP), previews and full originals alike (the resumable start says desktop: true for an original), so the event's autopilot edits them; only hand uploads are left as sent. Faces and the autopilot work per event: photos with no event (the inbox) are analysed for faces but not grouped or edited. The face worker also queues, every minute, photos left at "no analysis" in organizations with biometrics on.

Uploads from the browser or desktop (POST /v1/orgs/:orgId/uploads, one photo per request) go through the same pipeline; an upload can target an open event directly. Still to come: resumable uploads (tus, preview first from the desktop), OCR and faces at ingest, and the final export replaying the edit op log (phase 2). Files live on local disk behind LocalStorage (originals and derivatives per organization); the API and the worker share that folder (Proxmox bind mount). Garage replaces it when files must be served from more than one host.

Galleries and shop

  • Sites: each domain (photoreport.pt, shootyourmove.com, ...) is a sites row: organization, skin (photoreport editorial light, shootyourmove dark with red) and texts. apps/site (Next.js) is one build for every domain; it asks the API with x-site-domain and proxies /v1 so browsers stay on the site's origin.
  • Galleries are made in the app (Vendas, or "Adicionar à galeria" on a library selection), usually from an event with its picks. Public (listed), unlisted (link only) or private (link + password; the unlock returns a token valid for a week, kept in a cookie). Photos on the sites are watermarked with the site's name (600 and 1600 px), made on first view from the edited preview and cached until the edit changes; URLs are signed.
  • Site home: search (title, teams, competition, venue and the players named in the photos), sport shortcuts, "Últimas do jogo" (the photos last added to public galleries) and "Mais vistas" (visits over 7 days, one per browser session, in gallery_views per gallery and day). A photo opened in a gallery shows its delivered IPTC caption and credit, when it was taken and its size, and has its own link (?foto=<id>, previewed with that photo).
  • Live galleries (live PICKS or ALL, linked to an event): the gallery fills itself while the match is on, from the event's picks or every ready photo that is not rejected. Photos it added leave again when they stop matching; photos taken out by hand are kept as exclusions and never come back; photos added by hand stay. The sync runs when someone looks (site or app, at most every 5 s per gallery); the site shows "Ao vivo", newest first, and refreshes every 20 s (paused while a photo is open). A live gallery can be published empty, before kick-off.
  • Proofing (ported from the old app's publicProofing): clients mark favourites and comment on photos. A visitor is one browser (signed token in localStorage, sent as x-proofing-visitor); name and email are optional and asked after the first heart. Comments show to others once the photographer approves them. In the app: who chose what, the most chosen photos, CSV export, file names to copy, and "label in the catalogue" (a colour label on every favourite, to filter, edit and deliver from the library).
  • ZIP: an order's ready downloads in one archive (stored, not compressed; CRCs worked out first so every unzip tool reads it; no ZIP64, so up to 4 GiB). Free-download galleries have "Descarregar todas": one free order with every photo (up to 200) in the largest digital size, then the order page with the ZIP.
  • Earnings (Vendas → Ganhos, apps/api/src/shop/earnings.ts): when an order is paid, each line owes its photographer a share of its net (VAT-free) amount (the organization's percentage, or the member's own) and the order owes its affiliate a commission on its net total. Earnings are written once (unique per line / per order), held for the refund window (14 days by default), then paid out per person: a Stripe Connect transfer from the organization's Stripe balance to the person's Express account (onboarding on Stripe's page; we keep only the account id), or a bank transfer recorded by hand with its reference. Transfers are idempotent per payout: refused ones release the earnings, unanswered ones stay pending and are retried. "Marcar reembolsada" on an order cancels what it still owed; what was already paid out is settled by hand. Photographers see their own sales, holds and payouts. Affiliates: links carry ?ref=CODE (remembered 30 days by the site), unknown or inactive codes are ignored.
  • Notifications (the bell in the app, apps/api/src/notifications): a sale of your photos and what it earns you, paid orders (admins), client comments waiting for approval (editors), payouts made to you, deliveries that gave up (admins). Unread notices with the same key fold into one with a count (a burst of comments on one gallery, failures on one target); read ones are dropped after 90 days. The app polls every minute and on focus; each notice links to its page (/shop?tab=earnings, /delivery).
  • Invoicing (apps/api/src/invoicing): with InvoiceXpress set up (Sites e pagamentos → Faturação: account, API key sealed like the Stripe keys), every paid order gets a certified invoice-receipt: queued in invoices when the order is paid, issued by the worker (create as draft with our id as proprietary_uid, finalize, email to the buyer), retried with backoff (1 min to 12 h, six tries); rejected data (422) or a bad key fails at once and tells the admins. Net unit prices per line, VAT as the account's taxes named IVA<rate>, reverse-charged orders at 0% with the exemption code set in the settings (M40 by default) and the mention "IVA - autoliquidação". The invoice number and link show on the order in the app and on the buyer's order page. Imported orders get none.
  • Press accounts (Vendas → Imprensa, apps/api/src/shop/press.ts): a newspaper, agency or club gets an account (email and a generated password, shown once). On the site, Imprensa signs it in (a signed token, 30 days, kept in the browser); its orders skip the payment, use its billing details and discount, and are paid at once on account (downloads render straight away, photographers' shares are recorded). After each month ends the worker queues one invoice per account with everything it bought (InvoiceXpress invoices, due in 30 days, a line per item with the order number); those orders get no invoice of their own. A closed account's token stops working.
  • Download limits: each bought file can be downloaded maxDownloads times (organization setting, 20 by default, 0: no limit), copied onto the order when it is made so a later change never takes downloads away; press orders have none. The order page shows what is left; the ZIP counts as one download of each file.
  • Photo packages (bundles, Vendas → Produtos → Pacotes; the old storefront's "pacotes"): N photos, or the whole gallery (0), of one digital product for one price, for one gallery or all of them. Buyers just fill the cart: applyBundles (contracts) finds the cheapest mix of single photos and packages per product, and the whole gallery when every ready photo is in the cart; the site prices the cart with it and the API charges with it, so they agree. A package's price is spread over its photos, so order lines, VAT, shares and refunds work as before (the line reads " · "); a press discount applies on top. The gallery page lists the packages and has "Comprar todas" for the whole-gallery one. Orders take up to 1000 lines for that.
  • Kiosk (Impressão → Quiosque; /e/<slug>/quiosque?k=<secret> on the events site): a tablet at the event shows the photographer's photos big and the front camera as a photobooth (3-2-1, then the picture), takes the guest's name and copies (1-5) and sends the print to the queue. Only the hash of the link's secret is kept; a new link retires the old one. The tablet is shared and staffed, so the per-guest limit doesn't apply; on a paid event the kiosk's prints wait for approval (paid at the counter) instead of going through Stripe. Full screen, screen kept on, back to the start after a minute without a touch.
  • Faces on edited photos: boxes are stored in the original frame; GET /v1/photos/:id/faces also gives each box in the rendered preview's frame (inPreview, the crop and straighten of the snapshot it was rendered from; null when cropped out), which is what the loupe draws (apps/api/src/faces/frame.ts).
  • PATCH bodies are parsed with patchOf(schema) (contracts): zod's .partial() keeps defaults, which made a title change turn a private gallery public; galleries, sites and print events use it.
  • Products per organization: JPEG downloads (long edge, 0 = original) and prints (size, lead days); prices are gross. Orders keep a copy of names and prices. VAT: seller's rate inside the price; EU businesses with a VIES-valid number from another member state get reverse charge (net price). OSS for EU consumers is not applied.
  • Payments: the organization's own Stripe account (keys sealed with AES-GCM), hosted Checkout with the methods switched on in its dashboard (cards; Multibanco and MB WAY where Stripe offers them). Webhooks (/v1/public/stripe/:orgId/webhook, signature checked over the raw body) mark orders paid, including late Multibanco payments. Free-download galleries skip payment for digital files.
  • Fulfilment: the worker renders each bought JPEG from the original with the photo's edit and full IPTC at the product's size (never enlarged), then emails the buyer the order link (SMTP). Downloads are counted (20 max). Prints are marked shipped in the app; the order closes when everything is done.

On-site printing

  • Print events (Impressão in the app) have a QR code to events.photoreport.pt/e/<slug> (apps/site). Guests send a photo from the phone or pick one of the photographer's (a gallery linked to the event); each becomes a print-ready JPEG at 300 dpi in the photo's orientation (cropped around what matters), with an optional border and a band with the event's text. Optional approval per photo and a limit per guest (a random key per phone).
  • Stations run apps/print-agent (CUPS) and pair with a one-time code (15 minutes) for a bearer token stored hashed. Every 15 s they report their printers; they claim the oldest queued job for a printer that has the job's paper loaded (operators tick sizes per printer), print with lp, and report the result (three tries, then failed; reprint from the app). The app's queue and the guest's page update live.

Faces

Only for organizations whose owner switched it on with a recorded legal basis (biometric data, GDPR art. 9). Each photo that arrives is queued (photos.faces_status); the worker runs workers/faces on the original: YuNet finds faces, each is aligned to the ArcFace template and embedded by AuraFace (512 numbers, Apache-2.0; model files pinned and checked by SHA-256, infra/faces/download-models.sh). Faces of the same person within an event are grouped (cosine to the group's mean, threshold per model). An editor names a group once (the "Caras" view of the library, or a suggestion from people confirmed in earlier events), and every photo with a face in it gets the name in Players, which goes to IPTC Title and Persons Shown; photos that arrive later and join the group are named on arrival. Suggestions never name photos on their own. Groups can be merged or ignored (public, staff). Measured locally on 2 cores: about 1 s per photo with AuraFace.

Shirt numbers come from our own model, because general OCR doesn't read shirts. Under each confirmed face two crops become training samples, labelled with the squad's number: the chest (handball kits carry the front number there) and waist to mid-thigh (football: Liga Portugal 2026/27 shirts have no chest number, the front number is on one leg of the shorts, as a sample of 14 clubs showed). The worker reads both and keeps the more confident reading. People check these samples in "Números das camisolas". workers/ml/jersey trains a ResNet18 on the checked samples (on a Mac with MPS) and exports it to ONNX.

With JERSEY_MODEL_DIR set, the worker reads the number of every clear face through onnxruntime-node, on the CPU. A group's number is the one more than half of its clear readings agree on; it is shown as #10 on the group.

When a group has no face match, it is suggested as the squad player who wears that number in either team of the event. This happens only when exactly one player matches, and the score is 0.9 × the mean reading. Suggestions still never name anyone on their own.

Next: back-of-shirt numbers. These are players with no face visible, and they need a box detector trained on hand-drawn boxes.

Sports data (squads, fixtures, player codes)

apps/api/src/sports rebuilds the old app's code-replacement system. The worker reads public federation data every 6 hours (SPORTS_SYNC=off turns it off). It is shared by every organisation:

  • Liga Portugal (ligaportugal.pt/api/v1): Betclic, Meu Super and Allianz Cup. Gives teams, squads (numbers, positions, official headshots) and the season's fixtures.
  • FPA (ws.fpa.pt agenda): every national handball competition (PO01, PO09, PO20...), with teams and fixtures. The FPA publishes no squads, so handball squads are still pasted or imported into people.
  • FPF (resultados.fpf.pt, HTML): competitions are added by link. It gives teams and fixtures, and squads from each match sheet, read from 1 h before to 2 h after kick-off.

What organisations do with it:

  • Code list: generated codes go into the organisation's code list. They live in a block at the top, and the editor's own lines keep priority. The block is regenerated when squads change. Code = team prefix + number, with the same prefixes and templates as the old app.
  • Events from fixtures: an event created from a fixture keeps fixtureId and both teams.
  • Generic events (press conferences, galas, presentations; "Evento genérico" in the form): home holds the name and away is empty. Nothing is guessed for the caption: the default IPTC template (GENERAL_TEMPLATE) has no caption, headline or event, and the form's "Legenda" fills caption and headline when typed. {event} is the name alone, and a match template left on such an event drops the dangling "x".
  • Agenda: each person can connect their own calendar by its secret iCal address (Google, iCloud, Outlook; webcal:// is read as https). It is sealed with the secret box in user_preferences.calendar_url, fetched only from public https hosts (private, loopback and link-local addresses refused, redirects checked again, 5 MB, 10 s) and cached 5 minutes. For a generic event the form lists the day's entries; picking one fills name, venue, city and time and suggests a caption ("Title, Venue, City.") to edit. Repeating entries show their first date only.
  • People from squads: squads become people (club, number, sportsPlayerId). With biometrics on, the Liga headshot becomes the reference photo, and number suggestions for faces use the event's squads.

Working without a network (desktop app)

A match does not stop when the venue's internet does. The desktop app keeps working and catches up on its own:

  • Opens offline. The interface is on disk (apps/desktop/src-tauri/src/ui.rs); the person last signed in carries on (auth.tsx), the session is checked again when the server answers.
  • Library and Revelar from cache (apps/app/src/offline/cache.ts, IndexedDB): events, each folder's photos, the edit state of photos opened in Revelar, thumbnails and previews already seen.
  • Photos arriving offline show at once (offline/local.ts): the local FTP feed makes a preview here and files the photo in the event of its capture time (the same rule as the server), with id local:<sha256>. It can be culled, named and edited before it is uploaded; the server's copy replaces it when the upload is done, keeping what was done.
  • Changes wait, in order (offline/queue.ts, localStorage): culling, players, IPTC and "send to" made without a network are kept and sent when the server answers (every 10 s and on online); changes to a photo not uploaded yet wait for it. Develop edits use the per-photo outbox (develop/session.ts) and follow the photo to its server id.
  • Uploads wait instead of failing: the queue pauses on a network error and resumes when the connection is back.
  • The autopilot runs on the server when the photo arrives, and never over a person's edit (made offline first).

Library realtime

Socket.io on the API (/v1/realtime, WebSocket only, access token in the handshake, one room per organization). Every message goes through PostgreSQL LISTEN/NOTIFY (photoreport_realtime): the worker and every API process publish, every API process delivers to its own sockets. No Redis/Valkey and no sticky sessions needed. Messages: photo.added, photo.updated (culling, players), delivery.updated.

Client delivery (Nextcloud, SFTP, FTP, Dropbox)

PhotoReport storage 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. Implemented (apps/api/src/delivery): editors send picks to a target; each photo becomes a queue item with its {n} fixed at that moment (capture order, never reused). The worker renders it (oriented, 4000 px, JPEG 100 4:4:4, camera EXIF and ICC kept, IPTC written to IIM and XMP with ExifTool), creates the folders (WebDAV MKCOL) and uploads (PUT), up to 4 at a time, retrying network and server errors with back-off (5 attempts); authentication and template errors fail at once. App passwords are stored encrypted (AES-256-GCM, DELIVERY_SECRET_KEY). Editors can create a read-only public link to an event folder (OCS). Large files may later need WebDAV chunked upload.

The same queue also delivers to SFTP, FTP/FTPS and Dropbox (delivery/transports.ts):

  • SFTP (A Bola: transfer.ringier.ch, folder /{event}/, originals at full size). Takes a password or a private key. The host key is remembered on the first connection and checked on every one after; a changed key fails the delivery until an admin resets it.
  • FTP: ftps:// for explicit TLS.
  • Dropbox: app key plus refresh token, or a long-lived access token.

Each target also has Photo Mechanic's uploader output options: fit-in-box size, JPEG quality, output sharpening, ppi, keep or drop the camera EXIF, and conversion to sRGB. Templates accept Photo Mechanic's variable names ({iptcyear4}, {iptcmonth0}, {iptcday0}, {datesort}, {timesort}, {event}), so a Cofina path such as /fotografia/{iptcyear4}.{iptcmonth0}.{iptcday0} {event} works as typed there. Targets can be duplicated (same server and credentials, another name and folder).

Rename on arrival (Live Ingest "Rename as"): photos arriving by FTP or the desktop app get a name from a template. The template is the organisation's, or the FTP login's own ("" keeps camera names). Names are made unique within the event (_2), and are redone when the photo moves to another event (a template that uses the event waits for one). The camera name is kept in originalName; deliveries use the new name as {originalName}.

Files with the same name are replaced (as in Photo Mechanic). Public links exist only for Nextcloud and Dropbox. The old app also mirrored raw uploads to Dropbox/FTP; here every delivery is the edited, captioned JPEG.

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.

Editor scope

JPEG first: most event and match photographers shoot JPEG for speed, so JPEG must be perfect before RAW. Default editor modules: Crop (with straighten and aspect presets) and Basic (white balance, exposure, contrast, highlights, shadows, whites, blacks, texture, clarity, dehaze, vibrance, saturation). Every other LightCraft module (curves, colour mixer, grading, masks, detail, optics...) is available but off by default; each user chooses which panels to show, and the choice syncs across their devices.

RAW support (secondary; 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 (low priority): collect real files from each body, add them to our reference set, contribute samples upstream.

Status

Phase 0 code is in place and verified: accounts, organizations and roles, web login (httpOnly refresh cookie, rotation with reuse detection), desktop login through the browser (device authorization) with the keychain, synced editor-panel preferences, deploy receiver and script. Remaining for phase 0: create the next containers and webhooks (docs/DEPLOY.md), and macOS/Windows runners for desktop installers.

Phase 1 so far (verified end to end locally: FTP drop -> live grid -> keyboard culling -> players by code -> IPTC preview -> delivery into the FPA folder layout): events with agenda and IPTC template, FTP ingest and routing, previews, the library (Lightroom-style grid and loupe, P/X/U, stars, colour labels, filters, live updates), code replacements, IPTC with the fields of the current Photo Mechanic pad (packages/metadata), Nextcloud delivery queue and share links, the per-event IPTC pad (same fields and order as Photo Mechanic), and admin screens for delivery targets (FPA and Liga presets) and FTP logins, uploads from the browser (drag and drop or Importar, 4 in parallel with progress, same pipeline as FTP), and the IPTC already in incoming files (XMP first; IIM written by Lightroom/Photo Mechanic on the Mac without a charset flag is read as Mac Roman), shown next to ours. SFTPGo authenticates cameras against the API (external auth hook; passwords made in the app). Browser and desktop uploads go in 4 MB chunks and resume after a dropped connection or a reload. Still open in phase 1: a real match run on the next containers (the phase gate).

Phases (gate to pass)

  1. Foundation: monorepo, CI, next containers, accounts, organizations, tokens (login on web and desktop).
  2. Ingest + library: SFTPGo/tus, routing, previews, IPTC, code replacements, culling, Nextcloud delivery (a real match arrives captioned and delivered with no manual step).
  3. Synced editor (done: WASM and native engine, op log, live sync, offline outbox, render worker, edited deliveries, crop with aspect presets and straighten, Basic and optional modules, copy/paste settings).
  4. Galleries and sales (done: both storefront skins, public/unlisted/private galleries, watermarks, cart, Stripe Checkout and webhooks, VIES reverse charge, rendered downloads with IPTC, order emails, print fulfilment, admin in the app, live galleries, client proofing, ZIP downloads, photographer shares and affiliates with payouts (Stripe Connect or bank), import of the old storefront (galleries, paid orders, affiliates), invoices through InvoiceXpress, press accounts on credit with a monthly invoice, photo packages, download limits, FTP packages with quotas).
  5. Events and printing (done: QR guest page, print layout with band and border, approval and limits, queue in the app, print agent with CUPS and pairing, paper per printer, paid prints through Stripe, kiosk mode on a tablet with photobooth capture, Windows agent (spooler through PowerShell). Open: the Windows agent on real hardware, a real event printed).
  6. Player identification: faces (done: detect, group, confirm, propagate, suggest across events), jersey numbers with squads, global search (parity with old projects validated).
  7. Cutover: final import, redirects, old projects read-only, then switched off.

Deploy

Push to main -> Gitea webhook per container -> pull, build, migrate, reload, health check, auto-rollback. Details: docs/DEPLOY.md.

Infrastructure (next)

Container Services Domain
pr-api apps/api + Socket.io (2 instances) api.next.photoreport.pt
pr-ingest SFTPGo + photoreport-worker (ingest + delivery) ftp.next.photoreport.pt (DNS-only)
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-storage /srv/photoreport-data bind mount shared by pr-api and pr-ingest (Garage later) internal
pr-workers workers/media + workers/render internal
pr-ml workers/ml internal