APOKRYPHA the pattern archive
Colophon · how the node is built

A small archive,
built like a terminal.

Every layer here encodes a real thing. The reader's device holds the session; the edge serves the canon; a thin set of functions do the rest, each service behind a switch that stays dark until it is needed. This is the map.

01 · the stack

Three tiers, one request.

the reader's device
SvelteKit app device-local state service worker · offline
vercel · edge + functions
prerendered canon SSR + /api (fluid) Edge Config · flags + models firewall · observability · spend
state & intelligence
Neon Postgres Better Auth AI Gateway Exa Upstash

The browser keeps all session state until the Wire phase. The server is stateless per request; canon is served from the edge. Every record body block carries a permanent locator (s1 · s2 · …): an address, once issued, never renumbers, so a citation holds for as long as the node does.

02 · who pays for AI

One rule, one place.

The operator's AI runs on the app's keys. Everyone else runs on the keys they brought. No visitor ever spends the app's budget.

an AI request
signed in?
no
sign in
yes
operator?
yes
app keysgateway + live model
no
their keysbrought & encrypted
has the keys?
yes
run
no
add your keysnames what's missing
03 · the key vault

Your key, sealed before it lands.

Visitors bring their own provider keys. Each is encrypted before it touches the database, opened only for the instant of a request, and never logged or shown back.

  1. 1
    paste
    the visitor pastes a provider key
  2. 2
    seal
    AES-256-GCM · key derived from the auth secret, never stored
  3. 3
    store
    only the ciphertext + last four reach Neon
  4. 4
    open
    decrypted in memory for one request, then dropped

Never logged. Never returned to the browser. Deletable at once.

04 · the parallel oracle

Search, ground, propose.

subject
Exa · web searchneural, content-extracting
fence sourcesuntrusted data · never obeyed
model · synthesisin the node's register
validate urlsagainst the retrieval
candidatesfor the Synod, never canon
05 · clockwork

Self-reporting, self-healing.

The node watches itself. It pages the owner for exactly four things and handles the rest quietly.

a 5xx anomalyAI diagnosis attached
spend at the capbelow it: Slack only
a cert or domain lapsethe node going dark
a missing heartbeatthe cron never ran
firewall auto-arms attack mode spend self-throttles dropped writes reconcile a bad deploy rolls back in one tap
06 · the build

How it got here.

  1. v1the node live · records, doctrines, ledger, carrier, burn
  2. v1.1the Synod · community governance
  3. v2.0the opening · plain language, visual journey, sign-in, library, canvas
  4. v2.5Obsidian & Echo · reskin, new mark, PWA, notifications
  5. v3.0the polish pass · overflow, states, contrast, a11y
  6. v4.0the operable node · control room, switchboard, clockwork spine
  7. v4.2the oracle · AI gate, BYOK, admin-editable models
  8. v4.4the wire · semantic search, bound identity, moderation, presence
  9. v5.0the open node · thirty features, the board flagship, the commons
  10. v6.0the wire · carrier truth, the margins, the memo, the detractor

Full detail lives in the repo: docs/ARCHITECTURE.md, docs/STACK_V4.md, KNOWLEDGE_BASE.md.