Undercroft
An immutable raw lake, declarative connectors, and a schema you define yourself.
An undercroft is the vaulted chamber beneath a building — the part that holds everything up and outlives what stands on it. That is the whole architecture in one word: the raw lake is the only durable layer, and everything above it is a projection you can drop and rebuild.
Status: pre-alpha. Under active construction; nothing is stable yet.
Undercroft is a partner of Kanna, a self-hosted web UI for the Claude Code and Codex agents.
What it does
Connect your accounts, declare what to pull in YAML, and write your own SQL on top.
your APIs ──▶ raw lake (S3/MinIO) ──▶ raw.records (Postgres) ──▶ dbt ──▶ BI
immutable, content-addressed one generic table your models
- The raw lake is create-only and content-addressed. Re-storing identical bytes writes nothing. Nothing is ever overwritten in place. It is the one layer that cannot be recomputed, so it is the one layer treated as durable.
- Connectors are YAML, not code. Base URL, auth, pagination, entities, cursors.
A spec is data, validated against
specs/schema/connector.v1.json, so a new REST source needs no migration. It ships in the worker image, and the control plane lists the sources it can connect, so offering one to users is a small code change and a release. HubSpot and Xero ship as examples inspecs/connectors/. - No business schema ships. Records land in one generic table; every table above it is a dbt model you wrote. Undercroft has no opinion about what a "customer" is.
- Multi-tenant. Per-tenant credentials sealed with AES-256-GCM, and a control-plane UI where someone connects their own accounts. Each tenant's rows are fenced by row-level security, and what each of its people may do is a set of permissions: those their role holds -- viewer, member, builder, admin, or a role the customer defines -- and any granted to them, standing or until a date. Nobody gives a permission they do not hold, and the last admin is never removed; access control is the how-to.
- Anything can ingest. A REST lake API means a shell script or an orchestrator can land data too — through the same create-only, content-addressed path.
- Documents, not only records. Gmail and Drive are first-party collectors, because a PDF is bytes and a YAML spec cannot describe bytes. Their text is extracted and lands beside the records. A tenant can connect several mailboxes and drives, and each one is a source of its own. A file is recognised by its type first, Google Docs, Sheets and Slides are exported, and a signed OpenAttestation record is verified before any of it is read; the file-format reference lists every type.
- Search the whole lake. One box over both payloads and document text, folded so that Vietnamese matches with or without tone marks, and stemmed for English.
- The BI is first-party. Questions and dashboards live in the Reports division, and every one runs as the tenant's own read-only login — not as the web process. A question is a saved query over the built models plus how to draw it, what other BI tools call a saved query or a chart; onboarding defines the words.
- It says when a sync breaks. A failed run, a grant about to lapse and an ingest key about to expire are emailed to the tenant's admins. A failure, and the run that next succeeds, can also post to the operators' Lark group.
- Every action is on the record. What a person does, in the browser, the CLI, over MCP or through the assistant, lands in an append-only audit log, refusals included -- and so does every read an agent makes, and every sign-in, sign-out and refused token. Each person reads their own on the account page, an admin a customer's in People, a superadmin all of it.
- An assistant with exactly your permissions. It reaches the platform's own procedures through the real permission checks, so it can refuse you; a change is proposed as a proof you strike, and a separate model checks you asked for it before one is ever offered.
- A CLI for people and agents.
undercroftdoes everything the web UI does, one command per API procedure, as the person who signed in — never more. Writes stay off for each profile until a person turns them on. - An MCP server for any agent. claude.ai, Claude Desktop, Claude Code and any other MCP
client get every procedure as a tool at
/mcp, signed in with Google or a personal token, with a read or write grant the person chooses. Query results and live runs render as widgets in the chat. - Skills that teach an agent the workflows. One family, installed with
npx skillsor served by/mcpitself, works over either door. The model builder interviews the person, checks the SQL before it saves, and asks before it builds; the access-control skill turns "let Lan read the raw data until month end" into the smallest role or grant, and asks first.
Installing it
The setup wizard installs Undercroft with Docker on Windows, macOS or Linux, either for one person on their own machine or for a team on a server. It installs the same stack the hosted server runs, and installing Undercroft is the guide. Choose the desktop app, a window and a tray icon, if you would rather not open a terminal; the terminal wizard does the same and also runs unattended.
Ways in
Every way in reaches the same procedures through the same permission checks, as the person who signed in. This page only says which to choose; each runbook says how. Bringing a new person in, from invitation to their first session with an agent, is onboarding, in Vietnamese and English.
| Way in | Choose it when | How |
|---|---|---|
| The web UI | you are a person at a browser | sign-in |
The undercroft CLI |
you work in a terminal or a script (Node 22+) | the CLI |
The undercroft skills |
your agent should know the workflows, not just the tools: over MCP or the CLI | agent skills |
MCP at /mcp |
your agent speaks MCP: claude.ai, Claude Desktop, Claude Code | connecting over MCP |
| The assistant | you want to ask in plain words inside the web UI | the assistant |
Two things stay a person's on every agent path: signing in, and allowing writes. The decisions are ADR 0044 (the CLI), ADR 0060 and ADR 0061 (MCP).
Design rules
- Raw is the only durable layer. Everything in Postgres is a projection and may be dropped and rebuilt. Raw cannot be recomputed.
- Never guess; return nothing and say why. An empty cell is visibly missing; a wrong
value is invisibly false. "No evidence" is never "pass". Money is a string end to end,
and an unreadable amount is
null, never0. - One writer, many callers. Every byte enters through the lake's create-only path, whatever called it.
Stack
TypeScript on Bun, end to end. Postgres, S3 (MinIO, run as the
pgsty/minio community build; see
ADR 0050),
Kestra for scheduling, dbt for transforms, and
charts in the control plane itself — plus a read-only Postgres role for any BI tool you
would rather point at it.
Development
Every operation goes through Task, and task ci:verify is the gate:
it runs with no Docker, no network and no credentials. CONTRIBUTING.md
has the setup, the local stack and the checks outside the gate.
Documentation
This README is an index. How to do a thing lives in its runbook, why it is that way lives in its ADR, and what exactly it accepts lives in a reference page.
- Architecture: the map of the system: its services, data layers, key flows and security model, with diagrams.
- Runbooks, one per way in or per thing to set up (
docs/runbook/):- Installing it: on your own machine or a server, with the desktop app or the terminal wizard
- Getting started: onboarding a new person
- Using it: the CLI, connecting an agent over MCP, agent skills
- Managing who may do what: roles and grants
- Setting it up: sign-in, the assistant, Google ingestion, Xero, HubSpot
- Running it: deployment
- Changing it: visual regression tests for the UI's screens
- Decisions:
docs/adr/. Each ADR records the options that were rejected and why. - Reference: file formats a Gmail or Drive connection can land, what an ingest run counts.
- Design: the CLI's home page and sign-in, operator and reader paths.
- Blog: blog.undercroft.lowbit.link, articles in
Vietnamese and English on Xero, Gmail, Google Drive and HubSpot integration, ETL vs ELT and
the raw lake. Its source is
apps/blog, and how to write a post. - Working on the code: CLAUDE.md, also linked as
AGENTS.md, is the map of the conventions. The rules it points to live in.claude/rules/. - Changes: CHANGELOG.md, maintained by release-please.
Contributing
See CONTRIBUTING.md and the code of conduct. Report vulnerabilities privately, as SECURITY.md describes.