The Spine domain model
Everything in Spine is one of about ten primitives. Once you can name them and say how they connect, the whole system — admin UI, APIs, automation — is just compositions of the diagram below.
┌──────────────────────── IDENTITY ────────────────────────┐
│ │
auth.users (Supabase) │ account ──< people >── role │
│ │ (tenant, (human, (permission │
│ auth_uid │ tree via auth_uid, set; system_admin │
▼ │ parent_id account_id, is the seeded root) │
JWT / x-api-key ──────┤ + account_ role_id) │
│ │ paths) │
▼ └──────────────────────────┬─────────────────────────────┘
principal ─────────── every request resolves one │
(anonymous | human | machine | system) │
▼
┌──────────────────────── SCHEMA ─────────────────────────┐
│ type (kind + slug) → design_schema → validation_schema │
│ fields · views · record_permissions · scope │
└──────────────────────────┬─────────────────────────────┘
│ stamped at create
▼
┌──────────────────────── RECORDS ────────────────────────┐
│ items · threads · messages · links · attachments · │
│ watchers (+ accounts, people as records) │
│ system columns + data jsonb + stamped schemas │
└──────────────────────────┬─────────────────────────────┘
│ CRUD via /api/admin-data
┌──────────────────────── APPS ◄────────────┘ renders / consumes
│ generic | custom | none │
│ app row: slug, route_prefix, renderer, ▼
│ nav_items, roles ┌────────────────────── AUTOMATION ───────┐
└───────────────┬────────────────┤ triggers (event) → pipelines (stages) │
│ seeds/owns │ timers (cron/interval/once) ──┘ │
▼ │ integrations (adapters+creds) │
┌──────────────────────── AI ────┤ ai_agents · prompt_configs · │
│ embeddings (pgvector search) │ embeddings │
└────────────────────────────────┴──────────────┬────────────────────────┘
▼
┌──────────────────────── OBSERVE ────────────────────────┐
│ logs · observability · pipeline_executions · │
│ trigger_executions · webhook_deliveries · │
│ api_key_usage_logs · audit │
└─────────────────────────────────────────────────────────┘Identity: account → person → role → principal
- Account (
public.accounts) — the tenant. Accounts form a hierarchy viaparent_id+ theaccount_pathsclosure table; the seededspine-systemaccount is the platform root (.framework/migrations/011_spine_system_account.sql). - Person (
public.people) — a human user, bound toauth.usersbyauth_uid, placed in oneaccount_id, holding onerole_id. Like every runtime record, a person row also carriestype_idanddata. - Role (
public.roles) — a named permission set with a globally uniqueslug.system_adminis seeded, protected, and bypasses record-level checks (.framework/migrations/003_core_system_data.sql). - Principal — the resolved identity of a request, computed per call by
.framework/functions/_shared/principal.ts:x-api-keyheader → machine principal (verified againstapi_keyshash), internal-invoke headers → cron/trigger/system,Authorization: BearerJWT → human principal, anything else → anonymous. Handlers receive it asctx.principalwithctx.accountId.
Schema: type → design_schema → validation_schema
A type (public.types) is the schema for a record kind. kind selects the runtime table — item, thread, message, link, attachment, watcher, account, person — and (kind, slug) is unique. Its design_schema JSON carries:
fields— each withdata_type,label,required, and optionalsystemflag.views—default_list/default_detailconsumed by the generic UI.record_permissions— per-role base grant ofcreate/read/update/delete;fields.*.permissionsexists only to override that base per field (.framework/functions/_shared/permissions.ts).scope—account(tenant data, the default) orplatform(record is re-anchored to thespine-systemaccount at create).
validation_schema is generated from design_schema on every save (.framework/functions/types.ts via _shared/schema-utils.ts) — never hand-edit it.
Records: the runtime tables
Six typed record tables — items, threads, messages, links, attachments, watchers — plus accounts and people in the same shape (.framework/migrations/001_core_schema.sql). Every record has:
- system columns —
id,type_id,account_id,app_id,created_at,updated_at,created_by,is_active, plus kind-specific ones (items.title/status,threads.target_type/target_id,messages.thread_id/sequence,links.source_*/target_*,attachments.storage_path,watchers.person_id). datajsonb — where all non-system schema fields live. Convention:system: truefields read fromrecord.<field>; everything else fromrecord.data.<field>(seeGenericDetailPagesplitting onfieldDef.systemin.framework/src/components/app-shell/GenericDetailPage.tsx).- stamped
design_schema+validation_schema— copied from the type at create time byadmin-data(createin.framework/functions/admin-data.ts), so the record is the source of truth for its own permissions even if the type changes later.
All CRUD flows through /api/admin-data (action=list|get|stats|create| update|remove, entity=<table>; GET for reads, POST/PATCH/DELETE for writes). The handler maps entity → kind (ENTITY_TO_KIND), resolves type_slug/type_id, evaluates record/field permissions, writes, then fires create/update/delete triggers.
Apps: registry + two renderers
An app (public.apps) is a registered application: slug, route_prefix, renderer, nav_items, min_role/required_roles, config, is_active, is_system. The authenticated router (.framework/src/App.tsx) mounts every routable app at its route_prefix:
renderer: 'generic'—GenericAppShellbuilds the UI from data: the sidebar comes fromnav_items, and each nav item with atype_sluggets list/new/detail routes rendered byGenericListPage/GenericDetailPagestraight from the type'sviews(.framework/src/components/app-shell/GenericAppShell.tsx).renderer: 'custom'—CustomAppLoaderlazy-loadscustom/apps/<slug>/index.tsx(falling back to.framework/src/apps/<slug>/index.tsx) (.framework/src/components/CustomAppLoader.tsx). Custom apps render their own pages but still use/api/admin-datafor record CRUD.renderer: 'none'— registry-only; not routable.
Automation: triggers → pipelines, timers → pipelines
- Pipeline (
public.pipelines) — astagesarray executed in order byrunPipeline(.framework/functions/_shared/pipeline-runner.ts). Each stage'sstage_typeresolves to apublic.actionsrow or a built-in handler (update_item,create_record,http_request,send_notification,send_email,run_pipeline,query_items,agent_inference,search_knowledge,generate_embeddings,revoke_embeddings,kb_ingest,kb_revoke,create_interaction). Every run writes apipeline_executionsrow. - Trigger (
public.triggers) —event_type+pipeline_id(+ optionalconfigfilters).admin-datacallsfireCreate/Update/DeleteTriggersafter each write; events are named<entity>_<created|updated|deleted>(e.g.item_created). A match enqueues apipeline_executionsrow and dispatches to thepipeline-runner-backgroundfunction over HTTP — which requiresINTERNAL_INVOKE_SECRETto be set (.framework/functions/_shared/trigger-engine.ts). - Timer (
public.timers) —timer_type(interval|cron|once— a label the scheduler never reads) +pipeline_id+ interval inconfig(interval_minutes/interval_seconds; there is no cron-expression evaluator — true cron lives onpublic.schedules). The scheduled functiontrigger-scheduler(every minute,netlify.toml) runssystem-cron, which calls theget_due_timersRPC and executes each due timer's pipeline under atimer:*machine principal (.framework/functions/system-cron.ts).
Integrations and AI
- Integration (
public.integrations) — a named adapter +config+credentials({"env_var": "NAME"}resolved in the function environment, or a literal{"value": …}). Inbound webhooks arrive viaintegration-routes; outbound calls go throughintegration-outbound, which records each attempt inpublic.webhook_deliveries(the deliveries ledger —system-cronretries pending ones via.framework/functions/_shared/retry-deliveries.ts). - AI agent (
public.ai_agents) — a model/prompt/tool config invocable via/api/ai-agents?action=runor theagent_inferencepipeline stage. Prompt config (public.prompt_configs) — named, versioned prompt templates agents and stages reference. - Embedding (
public.embeddings) — pgvector vectors with thematch_embeddings/search_similar_embeddingsRPCs (.framework/migrations/004_core_rpc_and_broker.sql), powering semantic search and thesearch_knowledgestage type.
Observability: everything leaves a trail
public.logs (per-account log stream), public.observability (metrics), pipeline_executions + trigger_executions (automation history), webhook_deliveries (outbound attempts), api_key_usage_logs (machine principal usage), and audit events emitted by emitAudit on privileged actions. The admin UI surfaces them under Observability, Deliveries, and Executions (.framework/functions/logs.ts, .framework/functions/observability.ts, .framework/functions/pipeline-executions.ts, .framework/functions/deliveries.ts).
Where to go next
- Entity deep-dives: types, apps, roles, pipelines, triggers, timers, integrations, ai-agents, prompts, api-keys, deliveries.
- Build something: 04-first-app.md.
- Terminology: 05-glossary.md.