Standards

Archetype: Full-stack product

On this page
  1. Three sources of truth
  2. Repo shape
  3. Standards that apply
  4. Auth integration
  5. Checklist

A user-facing product: a Rust/Poem server that emits an OpenAPI contract, with native clients per platform, deployed to the homelab. The heavyweight archetype — every standard applies.

Reference: someproduct — a Rust/Poem server emitting an OpenAPI contract, with native clients.

Three sources of truth#

This is the organizing principle. Each concern has exactly one home:

  • Behaviour → the server. One implementation; every client calls it. No business logic is reimplemented per platform.
  • Contract → api/openapi.json. Emitted by the server, committed, and used to generate typed clients. CI fails if a client's generated code drifts from the spec.
  • UX → the web client. The reference design; native clients port features from it (not the other way round). See platform-ux.md.

Repo shape#

<product>/
├── server/                 Rust Cargo workspace (core, db, api, …); emits OpenAPI
├── apps/
│   ├── web/                React + Vite + Tailwind + shadcn (reference UX)
│   ├── apple/              SwiftUI iOS + macOS, shared SPM <Product>Kit
│   └── windows/            WinUI 3 + shared testable core
├── api/                    openapi.json (+ asyncapi) — generated, committed
├── branding/               code-as-truth asset generator (see branding.md)
├── deploy/                 Komodo sync TOML + compose + Caddyfile
├── .github/workflows/      *.build (→ GHCR) + *.release (→ registry); see ci-cd.md naming
├── .standards.conf         PRODUCT / ARCHETYPE identity, read by the standards cli
├── AGENTS.md               Standards: line (archetype, product) + repo overrides
└── VERSIONING.md           from the VERSIONING.md template

Standards that apply#

StandardHow it applies here
VersioningDerived MAJOR.MINOR.<count>; computed in CI, consumed by server/Docker/Xcode/web.
Identifiersdev.thmsn.<product> root; per-platform bundle ids; auth grants .{read,write,admin}.
Build infolibbuildinfo in the server (and shipped binaries); exposed via /version.
BrandingIn-repo generator produces all icons/tokens for every platform.
CI/CDSelf-hosted runners; *.build → GHCR :main; *.release → registry. Codegen drift + coverage gates.
Self-hosted agentsLinux/macOS runners via agentutil; dev Mac for Apple notarized builds.
DeploymentKomodo GitOps + Watchtower + Caddy; hostname <product>.dev.thmsn.dev; secrets in Komodo UI.
Registry publishingClient apps (iOS/macOS/Windows) ship to apps.dev.thmsn.dev.
Testing>80% tarpaulin on the server; vitest + hermetic Playwright on web; thin/none on native UI.
Platform UXNative per OS; web is the reference, ported natively.
WorkflowCommit to main; continuous deploy.
Service architectureWorkspace core→db→engine→api; poem-openapi; 10s drain.
Data & persistencesqlx + SQLite, .sql migrations, typed Id<T>.
Public idsStored short alias in URLs; the UUID stays internal.
Backupsstash-backup sidecar + committed backup.toml; SHORTCUTS entries for checking and restoring.
ContractsEmit OpenAPI/AsyncAPI; generate + drift-check clients.
Error handlingDomain Error→HTTP; liberror/valuable trinity.
Auth integrationCentral auth SDK; me() live authority; grant-gated.
Refresh tokensClients keep them in the platform secret store; rotate single-flight.
Configurationlibconfig Loader; <PRODUCT>_ + bare shared env.
Observabilityliblog/OTLP; /api/metrics; ids/timings only.
TracingAlways-on + collector tail sampling; short linked roots; client traceparent/x-<product>-*, Ref: on errors.
AlertingProvisioned rules, code-as-truth; alert on sustained failure, liveness at minimum.
Grafana dashboardsCommitted deploy/monitoring/grafana/<name>.dashboard.json; at least a <product>-overview.
Client analyticsEvery client records the reserved usage events through one recorder; the server serves POST <api base>/telemetry/events and re-emits them to ClickHouse.
SecurityArgon2, ChaCha20-Poly1305, CSP, SSRF/decompression caps.
Web & client archTanStack Query + Zustand; generated client; shared Kit.
Rust conventionsEdition 2024, clippy pedantic, git deps.
lib* ecosystemReuse shared lib* for cross-cutting concerns.
READMEsRoot README.md covers mechanism, layout, quickstart, what CI runs, and the codegen/drift rule; each app has its own.
ShortcutsRoot SHORTCUTS.md holds the routes to prod URLs, the live version, deploy lag, logs and dashboards.

Auth integration#

Products that sit behind central auth register an app id dev.thmsn.<product> and a Grants enum (Read/Write/Admin) via the auth SDK's #[derive(App)], registered idempotently on startup. Grants are dev.thmsn.<product>.{read,write,admin}.

Checklist#

  • Server emits api/openapi.json; clients are generated from it with a CI drift check.
  • No business logic duplicated outside the server.
  • Native clients exist per target OS, designed for that OS (not ported wrappers).
  • Branding generator present and run; no hand-edited icon assets.
  • deploy/ has Komodo sync TOML + compose + Caddyfile; secrets only in Komodo UI.
  • *.build/*.release workflows on self-hosted runners; version computed once.
  • Telemetry per ../observability.md (set_global() before init, always-on) and tracing per ../tracing.md: request span adopts a client's traceparent (continues a service's), every request leaves one http completed line (errors included), echoes x-<product>-trace-id + traceId; every client sends the header contract and shows Ref: on errors.
  • Alert rules per ../alerting.md (liveness at minimum).
  • The OTLP-exporting prod compose service carries dev.thmsn.telemetry=otlp (logs stored once; see ../observability.md).
  • Client analytics per ../client-analytics.md: every client emits the reserved events through one recorder, the server serves POST <api base>/telemetry/events, no third-party analytics SDK in any client.
  • Server ≥80% coverage; web has hermetic e2e; native UI not unit-tested.
  • Root AGENTS.md with the Standards: line, .standards.conf, and VERSIONING.md from the template.
  • Root README.md covers mechanism, layout, quickstart (with why each env var is required), what CI runs, and the codegen/drift rule; each app has its own (../readmes.md).