feat: API skeleton, edit contracts and app/package placeholders

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HT6iXLYUUp9pJz5Kza9xCW
This commit is contained in:
sparkandClaude Opus 5.5 committed 2026-10-11 13:53:01 +01:00
1 parent a587551e95
commit 500bb9fd87
18 files changed
+194

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
PORT=3000
LOG_LEVEL=info
APP_VERSION=dev
# DATABASE_URL=postgresql://photoreport:***@pr-db:5432/photoreport
# VALKEY_URL=redis://pr-queue:6379
+17
View File
@@ -0,0 +1,17 @@
{
"name": "@photoreport/api",
"version": "0.1.0",
"private": true,
"type": "module",
"scripts": {
"dev": "tsx watch src/server.ts",
"build": "tsc -p tsconfig.json",
"start": "node dist/server.js",
"typecheck": "tsc -p tsconfig.json --noEmit",
"test": "vitest run"
},
"dependencies": {
"@photoreport/contracts": "workspace:*",
"fastify": "^5.4.0"
}
}
+16
View File
@@ -0,0 +1,16 @@
import { describe, expect, it } from "vitest";
import { buildApp } from "./app.js";
describe("api", () => {
it("reports health", async () => {
const app = buildApp({ version: "test" });
const res = await app.inject({ method: "GET", url: "/health" });
expect(res.json()).toEqual({ status: "ok", version: "test" });
});
it("rejects malformed edits", async () => {
const app = buildApp({ version: "test" });
const res = await app.inject({ method: "POST", url: "/v1/edits/validate", payload: { edit: {} } });
expect(res.statusCode).toBe(400);
});
});
+27
View File
@@ -0,0 +1,27 @@
import Fastify, { type FastifyInstance } from "fastify";
import { EditEnvelope } from "@photoreport/contracts";
export interface AppOptions {
version: string;
}
/**
* Builds the API. Modules (accounts, ingest, library, oplog, galleries, sales, events, print, nextcloud)
* register here as Fastify plugins as they are ported.
*/
export function buildApp(opts: AppOptions): FastifyInstance {
const app = Fastify({ logger: { level: process.env.LOG_LEVEL ?? "info" } });
app.get("/health", async () => ({ status: "ok", version: opts.version }));
// Validation-only endpoint for the edit contract; the realtime path reuses the same schema.
app.post("/v1/edits/validate", async (req, reply) => {
const parsed = EditEnvelope.safeParse(req.body);
if (!parsed.success) {
return reply.code(400).send({ error: "invalid_edit", issues: parsed.error.issues });
}
return { ok: true };
});
return app;
}
+9
View File
@@ -0,0 +1,9 @@
import { buildApp } from "./app.js";
const port = Number(process.env.PORT ?? 3000);
const app = buildApp({ version: process.env.APP_VERSION ?? "dev" });
app.listen({ port, host: "0.0.0.0" }).catch((err: unknown) => {
app.log.error(err);
process.exit(1);
});
+1
View File
@@ -0,0 +1 @@
{ "extends": "../../tsconfig.base.json", "compilerOptions": { "outDir": "dist", "rootDir": "src" }, "include": ["src"], "exclude": ["src/**/*.test.ts"] }
+7
View File
@@ -0,0 +1,7 @@
# apps/app
React + TypeScript + Vite SPA: backoffice, library (culling, metadata) and the Lightroom-style editor.
The same build runs in the browser and inside `apps/desktop` (Tauri).
Port from: `app.photoreport.pt/frontend` (screens only, redesigned), `PhotoReport_Studio` (culling rules, IPTC editor behaviour).
Design base: ShootYourMove design handoff (`tokens.css`, `BACKOFFICE.md`) via `packages/ui`.
+6
View File
@@ -0,0 +1,6 @@
# apps/desktop
Tauri 2 shell around `apps/app`. Adds: native `engine/core` (Rust), local FTP receive from cameras,
disk access for RAW files, offline command queue (SQLite), auto-updater fed by Gitea releases.
Replaces: `PhotoReport_Studio` (Flutter) and the archived `bridge.photoreport.pt`.
+6
View File
@@ -0,0 +1,6 @@
# apps/print-agent
Print Station agent (Node + TypeScript, packaged per OS). Pairs with the API, claims print jobs, prints via a
PrintProvider (Mock / CUPS / Windows).
Port from: `events.photoreport.pt/agent` (almost unchanged; only the API base and pairing endpoints move).
+6
View File
@@ -0,0 +1,6 @@
# apps/site
Next.js public sites, multi-domain: photoreport.pt, shootyourmove.com, events guest flow (`/{eventSlug}`).
Domain -> organization, brand, theme and templates.
Port from: `app.photoreport.pt/storefront`, `events.photoreport.pt/web` (guest flow), ShootYourMove mockup.
+15
View File
@@ -0,0 +1,15 @@
{
"name": "@photoreport/contracts",
"version": "0.1.0",
"private": true,
"type": "module",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": { ".": { "types": "./dist/index.d.ts", "default": "./dist/index.js" } },
"scripts": {
"build": "tsc -p tsconfig.json",
"typecheck": "tsc -p tsconfig.json --noEmit",
"test": "vitest run"
},
"dependencies": { "zod": "^4.0.5" }
}
+23
View File
@@ -0,0 +1,23 @@
import { describe, expect, it } from "vitest";
import { EditCommand, EditEnvelope } from "./commands.js";
describe("EditCommand", () => {
it("accepts a develop.set with control ids", () => {
const parsed = EditCommand.parse({ command: "develop.set", params: { values: { "light.exposure": 0.4 } } });
expect(parsed.command).toBe("develop.set");
});
it("rejects non-numeric values", () => {
expect(() => EditCommand.parse({ command: "develop.set", params: { values: { "light.exposure": "x" } } })).toThrow();
});
it("wraps commands in an envelope", () => {
const ok = EditEnvelope.safeParse({
photoId: "3f2a9c1e-5b7d-4e8a-9c21-7d4e5f6a8b90",
clientId: "desktop-1",
clientOpId: "op-1",
edit: { command: "develop.reset" },
});
expect(ok.success).toBe(true);
});
});
+42
View File
@@ -0,0 +1,42 @@
import { z } from "zod";
/**
* Edit commands mirror `engine/core` (`EditCommand`). They carry no pixels: only control ids and values,
* so they are cheap to broadcast and to store in the op log.
*/
export const DevelopSetCommand = z.object({
command: z.literal("develop.set"),
params: z.object({ values: z.record(z.string().regex(/^[a-z]+(\.[a-zA-Z0-9_]+)+$/), z.number().finite()) }),
});
export const DevelopMergeCommand = z.object({
command: z.literal("develop.merge"),
params: z.object({ partial: z.record(z.string(), z.unknown()) }),
});
export const DevelopResetCommand = z.object({ command: z.literal("develop.reset") });
export const EditCommand = z.discriminatedUnion("command", [DevelopSetCommand, DevelopMergeCommand, DevelopResetCommand]);
export type EditCommand = z.infer<typeof EditCommand>;
/** What a client sends over the realtime channel. */
export const EditEnvelope = z.object({
photoId: z.uuid(),
clientId: z.string().min(1).max(64),
/** Client-side id so the sender can match the server ack and drop it from its offline queue. */
clientOpId: z.string().min(1).max(64),
edit: EditCommand,
});
export type EditEnvelope = z.infer<typeof EditEnvelope>;
/** What the server broadcasts after persisting: the envelope plus the per-photo sequence it assigned. */
export const EditBroadcast = EditEnvelope.extend({
seq: z.number().int().nonnegative(),
userId: z.uuid(),
at: z.iso.datetime(),
});
export type EditBroadcast = z.infer<typeof EditBroadcast>;
/** Realtime rooms. A user's own windows share `user:<id>`; a whole event's team shares `event:<id>`. */
export const roomForUser = (userId: string): string => `user:${userId}`;
export const roomForEvent = (eventId: string): string => `event:${eventId}`;
+1
View File
@@ -0,0 +1 @@
export * from "./commands.js";
+1
View File
@@ -0,0 +1 @@
{ "extends": "../../tsconfig.base.json", "compilerOptions": { "outDir": "dist", "rootDir": "src" }, "include": ["src"], "exclude": ["src/**/*.test.ts"] }
+6
View File
@@ -0,0 +1,6 @@
# packages/metadata
Photo Mechanic-style variables, code replacements, caption/IPTC templates and folder/file-name templates
(also used for per-client Nextcloud destinations). Shared by web, desktop and server.
Port from: `PhotoReport_Studio` (120+ variables), `app.photoreport.pt` (`codeReplacements*`, `renameTemplateService`, `iptcWriteService`).
+3
View File
@@ -0,0 +1,3 @@
# packages/sdk
Typed API client + realtime command sync (Socket.io, sequence numbers, offline queue, replay on reconnect).
+3
View File
@@ -0,0 +1,3 @@
# packages/ui
Shared React components and Tailwind design tokens (PhotoReport light, ShootYourMove dark) for `apps/app`, `apps/site`, `apps/desktop`.