Archetype: Full-stack product
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#
| Standard | How it applies here |
|---|---|
| Versioning | Derived MAJOR.MINOR.<count>; computed in CI, consumed by server/Docker/Xcode/web. |
| Identifiers | dev.thmsn.<product> root; per-platform bundle ids; auth grants .{read,write,admin}. |
| Build info | libbuildinfo in the server (and shipped binaries); exposed via /version. |
| Branding | In-repo generator produces all icons/tokens for every platform. |
| CI/CD | Self-hosted runners; *.build → GHCR :main; *.release → registry. Codegen drift + coverage gates. |
| Self-hosted agents | Linux/macOS runners via agentutil; dev Mac for Apple notarized builds. |
| Deployment | Komodo GitOps + Watchtower + Caddy; hostname <product>.dev.thmsn.dev; secrets in Komodo UI. |
| Registry publishing | Client 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 UX | Native per OS; web is the reference, ported natively. |
| Workflow | Commit to main; continuous deploy. |
| Service architecture | Workspace core→db→engine→api; poem-openapi; 10s drain. |
| Data & persistence | sqlx + SQLite, .sql migrations, typed Id<T>. |
| Public ids | Stored short alias in URLs; the UUID stays internal. |
| Backups | stash-backup sidecar + committed backup.toml; SHORTCUTS entries for checking and restoring. |
| Contracts | Emit OpenAPI/AsyncAPI; generate + drift-check clients. |
| Error handling | Domain Error→HTTP; liberror/valuable trinity. |
| Auth integration | Central auth SDK; me() live authority; grant-gated. |
| Refresh tokens | Clients keep them in the platform secret store; rotate single-flight. |
| Configuration | libconfig Loader; <PRODUCT>_ + bare shared env. |
| Observability | liblog/OTLP; /api/metrics; ids/timings only. |
| Tracing | Always-on + collector tail sampling; short linked roots; client traceparent/x-<product>-*, Ref: on errors. |
| Alerting | Provisioned rules, code-as-truth; alert on sustained failure, liveness at minimum. |
| Grafana dashboards | Committed deploy/monitoring/grafana/<name>.dashboard.json; at least a <product>-overview. |
| Client analytics | Every client records the reserved usage events through one recorder; the server serves POST <api base>/telemetry/events and re-emits them to ClickHouse. |
| Security | Argon2, ChaCha20-Poly1305, CSP, SSRF/decompression caps. |
| Web & client arch | TanStack Query + Zustand; generated client; shared Kit. |
| Rust conventions | Edition 2024, clippy pedantic, git deps. |
lib* ecosystem | Reuse shared lib* for cross-cutting concerns. |
| READMEs | Root README.md covers mechanism, layout, quickstart, what CI runs, and the codegen/drift rule; each app has its own. |
| Shortcuts | Root 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/*.releaseworkflows 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'straceparent(continues a service's), every request leaves onehttp completedline (errors included), echoesx-<product>-trace-id+traceId; every client sends the header contract and showsRef: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 servesPOST <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.mdwith theStandards:line,.standards.conf, andVERSIONING.mdfrom the template. - Root
README.mdcovers 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).