SPB Git

Repository Public

overview.md 4.1 KB

# Architecture

flowchart LR
  V[Visitor] -->|HTTPS| C[Caddy · BHS64<br/>TLS, compression]
  O[Owner] -->|HTTPS + passkey| C
  C -->|WireGuard| W[orix-web · Next.js 16<br/>node m4mm :8830]
  W --> DB[(SQLite<br/>orix.db)]
  W --> UP[uploads/]
  W --> AR[artifacts/<br/>approved DMGs]
  W -->|read-only JSON API| G[SPB Git<br/>git.spboucher.ai]
  R[Release script] -->|signed webhook| C
  B[orix-backup · 03:40] --> DB

One Next.js process serves everything: public pages (server-rendered on each request from SQLite), the admin area, the JSON API and the download route. There is no separate backend, queue or cache server.

# Layers

Path Role
src/models/ app.ts (zod schema of an application document), constants.ts (vocabularies, dependency-free for client bundles), filter.ts (pure catalog search/filter/sort).
src/lib/database/db.ts Opens the database, applies migrations, exposes db(), tx(), settings.
src/lib/catalog.ts CMS operations: seed, draft, publish, unpublish, archive.
src/lib/git/spbgit.ts Forge client: timeout, retries with exponential backoff, asset URL allow-list.
src/lib/releases/ sync.ts (discovery), pipeline.ts (approval, checksum, notarization, withdrawal), store.ts, version.ts.
src/lib/testflight/ Invitation URL rule, server-side link check, betaAccess() decision.
src/lib/downloads/metrics.ts Anonymous daily counters.
src/lib/auth/ enroll.ts (one-time tokens), webauthn.ts (ceremonies), session.ts (cookies, CSRF).
src/lib/security/ Crypto helpers, HTTP error handling, rate limiter.
src/lib/view.ts The single function that decides what a primary button does (primaryAction).
src/app/[locale]/ Public pages. English at the root, French-Canadian under /fr (src/proxy.ts rewrites).
src/app/admin/ Passkey sign-in, dashboard, application editor, release review, announcements.
src/app/api/ health, metrics/click, hooks/release, auth/*, admin/*.
src/app/download/ The only route that serves a release image.

# Data model (SQLite)

Table Content
apps One row per application: published document (data), pending draft (draft), publish state.
releases One row per forge tag/asset: declared and computed SHA-256, state, notarization evidence, local artifact path.
repo_meta, sync_runs Last forge metadata per app; history of synchronizations with their outcome.
announcements Editorial entries of What's New (EN + FR, draft/published/archived).
admins, credentials, sessions, enroll_tokens, challenges Passkey authentication. Tokens and sessions are stored as SHA-256 hashes.
downloads (day, slug, version, kind) → n. Nothing else.
audit, webhook_nonces, settings Audit trail, replay protection, publication policy.

# Release states

stateDiagram-v2
  [*] --> note: tag without a DMG
  [*] --> validated: DMG + size + SHA-256 + forge URL
  [*] --> invalid: anything missing or foreign
  validated --> published: admin approves · checksum ok · notarized
  validated --> held: approved but notarization not verified
  validated --> invalid: checksum / size / download failure
  held --> published: re-verified, or policy switched off
  published --> withdrawn: admin, or asset changed upstream
  held --> withdrawn
  withdrawn --> validated: re-queue (manual withdrawals only)

Only published rows with a file on disk are downloadable. The default download is the highest published stable version, so withdrawing it rolls back to the previous one automatically.

# Rendering and performance

  • Pages are dynamic but cheap: synchronous SQLite reads, no network call on the request path.
  • Client JavaScript is limited to: header, hero parallax, universe, catalog filtering, gallery lightbox, scroll reveals, click beacon. The schema library (zod) is kept out of client bundles.
  • Images go through next/image (AVIF/WebP, responsive srcset, lazy loading below the fold).
  • Animation uses transform, opacity and CSS motion paths; everything pauses off screen and under prefers-reduced-motion.
Files main
Menu

Theme