A self-hosted coffee-shop database appliance built with TanStack Start, CMS, DB,
and optional AI. Base lives in app/base; the library demonstrations remain in
examples/.
From this directory:
docker compose up --buildOpen http://127.0.0.1:3000. The first-run screen creates your owner account. The coffee shop is already seeded; choose Agent → Shop setup to inspect the schema and accept your shop preferences. No AI API key is required.
For development, from the repository root:
pnpm install
pnpm --filter base devUse one server process per data volume. SQLite, uploads, and the generated
session-signing secret persist under CMS_DATA_DIR (default .data). The Docker
volume mounts this directory at /data. Rebuilds and restarts preserve changes.
The default Compose configuration binds only to host loopback.
Base builds on the shared TanStack CMS admin from @tanstack/cms-ui-react. The
dashboard, content list, block editor, and review queue below come straight from
the libraries; Base adds its coffee-shop collections, onboarding, and reports on
top.
- Collections (admin): create collections, add fields, and review schema changes before publishing. Definitions are stored in the database.
- Shop: collection viewers backed by TanStack DB live queries. Use Content to create, edit, publish, or delete records.
- Agent → Shop setup: guided coffee-template onboarding. Expand Show me what you built to inspect fields, the low-stock comparison, and report definition.
- Agent → On-demand trends: run a deterministic report for October 10, 2026. Oat-milk latte sales are 40% above their trailing daily baseline. House beans are low on stock. Pairings count receipts containing both products.
- Submit for review: recomputes a snapshot and sends it to Review. Approve
to publish the report at
/r/coffee-trends-2026-10-10; reruns create revisions of the same report after approval. Rejected previews never alter the live report.
The seed has 35 days of daily aggregate receipts, not individual customer transactions. New sales can use real receipt line items. Revenue uses integer USD cents; dates and report windows use UTC. A report compares its final seven days to the preceding 28 days and flags increases of at least 30%. Missing early history and zero baselines are reported explicitly. Saved reports are snapshots; they do not update automatically when records change.
Open Pages & reports. As an admin, choose New page or New report, set its title and URL name, then describe what you want. The builder creates a working preview through TanStack AI code mode when a text model is configured. Follow-up requests revise the current interface. Without an AI key, choose a collection template or edit the JSON definition and saved code directly.
For example, start from Recipes to get a searchable table and a Markdown
instructions panel. Preview the filters and record selection, then choose
Submit for review. Approve in Review to publish at /p/recipe-book.
Saved definitions, code, review changes, and revisions are CMS features;
Base supplies the routes and navigation. Open the content editor from the
builder for revision history, restoration, or unpublishing.
Pages and live reports rerun saved data sources against the current user's authorized records, with manual refresh and subscriptions to collection events. Only components that query a changed collection rerun, with full reads on reconnect and a 30-second fallback. Reports can also capture an immutable snapshot when submitted for review. A new approved revision refreshes a snapshot. Snapshot payloads are private database metadata, so full-volume backup/restore preserves them; document-only exports do not. Restricted readers cannot open snapshots containing fields they cannot read. Collections with per-document read predicates use live reports.
Saved button handlers can propose a record update through CMS review, while preview actions simulate the proposal. Views, refreshes, and saved actions do not call a model or require a rebuild. The initial component palette includes layouts, Markdown/media, metrics, tables, bar charts, inputs, selects, and buttons.
Snapshot reports can enable Schedule snapshot refreshes with UTC hourly, daily, weekly, or custom cron timing. Review approval authorizes automatic snapshot revisions from the approved definition. The server worker runs while Base is idle and rechecks the schedule owner's current account and source access. Pending edits defer refreshes. Failures preserve the last good snapshot, retry with backoff, and pause after five failures. The builder shows status and provides pause/resume and Run approved snapshot now controls. Missed runs coalesce after restart; full backups preserve schedule status.
See persistent interfaces for the shared CMS format, bindings, and runtime limits.
Open Collections as an administrator. Choose New collection, enter its permanent name and display label, and add fields. Every new collection starts with a text title field. Its label can be changed. Supported new fields are text, textarea, Markdown, number, boolean, date, datetime, email, URL, select, multiselect, relation, JSON, Object, and Array of objects. Choose a compound type and use Add nested field to define its children. Definitions and nested migrations come from TanStack CMS; Base exposes its editors.
Choose Save draft & validate to persist a proposal and inspect its changes and affected records. A draft does not change the running collection. Choose Publish schema to validate again, migrate existing records and pending content changes, and publish the definition in one transaction. Invalid data, a stale draft, or a failed write leaves the published schema and records intact. A discarded new-collection draft frees its name for reuse.
Schemas, drafts, and published history are metadata in the same database as
records. They survive restarts and the documented full-volume backup/restore.
Published definitions drive Content, /c/:collection, the shop navigation, and
the authorized API/MCP surfaces. They load on each request/navigation; an
already open page can be refreshed to pick up new fields. Publishing requires
no app rebuild or server restart.
This delivery supports adding fields (including inside published objects/arrays)
and changing labels. Defaults fill
existing records without changing their content revision; older content
revisions are upgraded when restored. Required additions to existing records or array items need a valid
default. Required fields in a new array item can be filled when adding the item. Enter default values as JSON, such as "Welcome", 10, or false.
Select fields need distinct choices; relations target published user
collections. Internal shop settings and reports are protected, and existing
coffee fields retain their names/types so the report contracts remain valid.
Removing or renaming published fields, changing their types/constraints/defaults,
changing title fields, and deleting collections are blocked until explicit
migration plans are supported. Executable code is never stored in schemas.
For a recipe database, create an ingredients Array of objects with child
fields name (text), quantity (number), and unit (text or select). Add a
Markdown instructions field to the recipe. Use Content to add, remove, and
reorder ingredient items, and to edit any object fields. A later child-field
addition fills its default in every existing ingredient while preserving
quantities and order, including pending changes and restored content revisions.
The generic collection viewer continues to display nested values as JSON.
Only an unscoped admin can read drafts or change schemas. Editors/viewers can use published collections under their normal content permissions. Every schema operation checks authorization, uses version checks for concurrent admin edits, and records the actor in the audit log. Schema draft/publication operations are available through Start and HTTP. MCP discovery and content tools use the same published definitions; schema publication is not exposed as an automatic agent tool.
Base still supports one Node process per data volume. Each request uses a schema snapshot; transactions reject an outdated snapshot so concurrent content writes cannot overwrite migrated fields. Multiple app instances require a separate coordination design before they are supported.
Authentication uses the CMS database auth provider: scrypt password hashes and HttpOnly, SameSite cookies signed with a random secret. Owner setup is available only while the user table is empty. There is no public signup.
In Settings → Users, an admin can create an account with a password, or omit
the password to generate an invitation token. Give the token to the user directly;
they enter it at /accept-invite and choose a password. Tokens expire after seven
days and can be consumed only once. Base sends no email.
Use Access in Settings to override a user's role by email or user ID:
- admin: shop setup, users, API keys, and all content operations.
- editor: content CRUD and report approval.
- viewer: reads and report previews; cannot save or approve changes.
Disabling a user blocks existing sessions on their next request. Signing out clears the current browser cookie. Sessions expire after seven days; v0 does not maintain a per-device session list. Role/scope changes apply on the next request. Avoid disabling or demoting your only administrator.
Set CMS_AUTH_SECRET to at least 32 random characters if you manage secrets
externally. Otherwise Base creates /data/auth-secret with private file
permissions. Preserve it with backups. Replacing it invalidates all cookies.
Local HTTP uses cookies without Secure; HTTPS deployment uses secure cookies.
API keys are created in Settings and continue to authenticate the CMS HTTP/MCP surfaces. Restrict each key's role and collection scope to its intended use. Trends require read access to products, sales, inventory, and shop settings; saved reports also require access to reports.
Install Docker on the Mini and Tailscale on the phones, tablets, and computers that need access. Enable MagicDNS and HTTPS certificates in your tailnet. Create a Tailscale enrollment key and configure your tailnet policy to allow only the intended devices/users to reach this appliance's HTTPS service.
Copy .env.example to .env, set TS_AUTHKEY, and set BASE_ORIGIN to the exact
HTTPS origin for the appliance, for example:
TS_AUTHKEY=your-enrollment-key
BASE_ORIGIN=https://tanstack-base.your-tailnet.ts.netThe hostname may receive a suffix if another node already uses tanstack-base.
Check the Tailscale admin console and update BASE_ORIGIN if necessary.
Stop the localhost configuration before switching:
docker compose down
docker compose -f compose.tailnet.yaml up --build -dThe app shares the Tailscale sidecar's network namespace and listens on loopback. Serve proxies HTTPS to the app. No backend host port is published and Funnel is disabled. Tailscale controls network access; database accounts still handle sign-in and roles. Open the tailnet URL and create the owner account promptly on the first launch. Verify sign-in from a second enrolled device.
The configuration follows the official Tailscale Docker guide.
Both deployment files use the same tanstack-base Compose project and data volume.
Run only one configuration at a time.
Open Chat at /agent. With a text provider configured, chat is the default
assistant view. Describe a collection, approve its validated schema proposal,
then ask for records or query the saved data. For example:
- “Create a recipe collection with ingredients as an array of name, quantity, and unit objects, a food image URL, and Markdown instructions.”
- Inspect the collection card and choose Approve collection. Drafts do not change the active schema until approval. Protected collections stay protected.
- “Add a carrot soup recipe.” Inspect the proposed record and choose Approve record, or use Review. Record proposals do not appear in committed queries.
- “How many recipes do I have? Which ingredients are in carrot soup?” Answers use authorized CMS tools, and the chat shows query evidence with the actual rows.
Schema proposals are administrator-only. Queries and record proposals respect
current collection, field, and role permissions. Publication is never a model
tool. The shared CMS AgentChat component supplies the conversation, Markdown,
query tables, and record review controls; Base supplies its schema proposal cards.
Approving a schema refreshes the current runtime metadata without rebuilding.
For local development, put provider keys in the repository or app/base
.env.local; app files take precedence. Only AI settings are read, and explicit
process environment variables override files, including empty values used by tests.
Keys stay on the server. Anthropic is preferred when both keys are present;
OpenAI is used when only its key is configured. Optional settings:
BASE_AI_PROVIDER=anthropic # or openai
BASE_AI_MODEL=claude-sonnet-4-6 # OpenAI default: gpt-5.2For Docker, set ANTHROPIC_API_KEY or OPENAI_API_KEY in the Compose .env and
recreate the app container. BASE_AI_PROVIDER and BASE_AI_MODEL can also be
set there. Model overrides must be supported by the installed adapter.
Scripted setup and deterministic reports still work without a key. Chat history
lives in the current browser view; approved schemas and records are persisted.
Provider calls use the configured account. Images can be supplied by URL or
uploaded in the editor; the assistant does not invent image URLs.
Update a local checkout with git pull, then rebuild your active configuration:
docker compose up --build -d
# Or: docker compose -f compose.tailnet.yaml up --build -dFor a simple v0 backup, stop Base before copying the data volume:
mkdir -p backups
chmod 700 backups
docker compose stop base
docker compose run --rm --no-deps -T base tar -C /data -czf - . > backups/base-data.tgz
docker compose start baseUse the same -f compose.tailnet.yaml flag on every command for a tailnet
installation. Protect the archive: it contains shop data, password hashes,
API-key hashes, and the signing secret. Back up the Tailscale state volume
separately if you also want to preserve the appliance's node identity.
To restore, stop Base, restore base-data.tgz into an empty data volume
owned by UID 1000, and start Base. Restore the entire directory, including the
SQLite WAL/SHM files if present, uploads, and auth-secret. Do not copy only a
running cms.db file. Check health, sign-in, and a saved report after restoration.
For lost owner credentials, use the included recover-owner.mjs from an offline
maintenance container; see its usage below. Recovery resets the named existing
account, restores its admin role, removes role overrides, and rotates the signing
secret to invalidate existing cookies. Supply the new password through stdin:
docker compose stop base
read -s BASE_RECOVERY_PASSWORD
printf '%s' "$BASE_RECOVERY_PASSWORD" | docker compose run --rm --no-deps -T base \
node scripts/recover-owner.mjs owner@example.com
unset BASE_RECOVERY_PASSWORD
docker compose start baseIf CMS_AUTH_SECRET is supplied externally, rotate that value yourself as part
of recovery. Recovery is a local maintenance action, not an HTTP endpoint.
V0 includes seeded collections, DB auth, generic routes, scripted onboarding, manual deterministic trends, CMS review/revisions, SQLite persistence, and Docker/Tailscale deployment. V0 used fixed schemas; the v1 foundation now stores collection schemas as versioned database metadata. Navigation and report snapshots are data. This is the Base distribution, consuming the CMS libraries.
The next phase brings the former v2 features forward, starting with collection management. Steps 1–3 are implemented for the additive schema changes described above; library integration and AI schema proposals remain next.
- Persist versioned collection/field definitions in the database, initially seeded from the coffee template.
- Let admins create collections and edit fields through the UI. Published definitions appear in Content, generic viewers, navigation, and API/MCP without a rebuild. Protect internal collections and existing report contracts.
- Use draft → validate → migrate → publish for schema changes. Preview the diff and affected records, detect concurrent edits, and audit changes. Start with additive changes; destructive changes require explicit migration plans. A failed migration preserves the previous schema and data.
- Scheduled snapshots and live interface subscriptions now use CMS eventing
and cron. Extend these into standing analyses, then integrate Postgres,
faceted search, and feature flags (
resolveFlags) through the CMS libraries. - Add natural-language schema proposals and query generation over the same authorized, validated operations.
The first delivery supports admin collection creation, record CRUD, and safe field additions without source edits or rebuilding. Definitions and records survive restart and backup/restore. Non-admin schema writes and invalid or conflicting changes are rejected without altering the published database.
The eject interview and CLI follow database mechanics. Generate the standalone TanStack Start app, migrations, seed, and Compose/Postgres configuration from the published registry and migration history.
Advanced reporting charts, model routing/local fallback, multi-user polish, and automated backup/restore. Other deferred work includes blank reset UI, learned skills, MFA, automated email, and password-reset UI.
From the repository root:
pnpm --filter base test:lib
pnpm --filter base test:types
pnpm --filter base test:oxlint
pnpm --filter base build
pnpm --filter base exec playwright install --only-shell chromium
pnpm --filter base test:e2e
pnpm --filter base test:production # built Node server, disposable data
pnpm --filter base test:docker # requires a running Docker engineBrowser tests use an isolated database under node_modules/.e2e-data on port 3035. Unit tests use temporary databases. Neither alters your shop data.
The production smoke checks cover first-run auth, report approval, dynamic
schemas and migrations, restricted reads, scheduled snapshots, cross-request
SSE, restarts, and full-data backup/restore. The Node check also verifies that
a scheduled report refreshes after restart before any external request. Both
runners use disposable accounts and data. The Docker runner builds its image
and uses temporary containers and volumes; set BASE_DOCKER_IMAGE to reuse
an existing test image.
Run pnpm --filter base exec playwright install chromium once, then
pnpm --filter base test:review to watch the complete browser suite in a visible
Chromium window at a slower pace. Each run saves videos for all tests, traces,
and an HTML report under app/base/playwright-report/reviews/<timestamp>.
Recordings show the test title, click targets, and pointer, including the
separate viewer session. These runs use the same disposable test database as
the ordinary browser suite.
When ffmpeg and ffprobe are on your PATH, the command also produces a combined
html/full-flow.mp4 and a chapter-based player at html/review.html. Otherwise,
the player uses the individual recordings. The command prints the report-server
command and replay URL. playwright-report/latest-review.txt points to the latest
player. Recordings stay separate from ordinary test results and are ignored by Git.
Use BASE_REVIEW_SLOWMO=100 pnpm --filter base test:review for a faster review.
CLI filters are forwarded to Playwright, but the current suite has serial setup
dependencies, so run it in full for the customer workflow. This review covers
the key-free builder and saved code; it does not call a real AI provider.

