SupaCraft
Describe a backend in plain English. Get a running REST API.
SupaCraft is an open-source backend that an AI agent builds for you: database, user accounts,
API endpoints, file uploads, emails and scheduled jobs, all defined in one JSON file and
served by one small binary.

What is this?
Most apps need the same backend: a database, sign-up and login, a few endpoints that read and
write data, maybe file uploads, an email now and then, a nightly cleanup job. Writing it by hand
takes days. Firebase and Supabase are quicker, but you then depend on a hosted platform and its
dashboard.
SupaCraft goes another way:
- The whole backend is one file,
supacraft.json. Tables, permissions, endpoints, cron
jobs: everything is declarative JSON that lives in your git repo.
- An AI agent writes that file for you. SupaCraft ships an MCP
server, so Claude Code, Cursor or any MCP-capable agent can design the schema, add endpoints
and test them, while SupaCraft checks every change.
- One binary runs it.
supacraft dev turns the file into a live API backed by SQLite.
You don't need Docker, a cloud account or a separate database server. It runs the same on
your laptop and on a $5 VPS.
It is built for lightning-fast MVPs, prototypes, internal tools and side projects, where you
want a real backend in minutes rather than days and you don't want to run anyone's platform.
What you get
|
|
| ποΈ Database |
SQLite tables generated from your schema, migrated automatically when you add tables or columns |
| π Auth |
/auth/register, /auth/login, /auth/refresh with JWT; per-endpoint auth and row-level policies |
| β‘ Custom endpoints |
/fn/posts/{id} routes built from steps: queries with joins and aggregates, transactions, input validation, if/else, loops, try/catch, math, HTTP calls, emails |
| β° Cron jobs |
The same steps on a schedule (0 3 * * *) |
| π File storage |
Upload/download endpoints backed by local disk, S3/R2/MinIO, GCS, Azure, FTP or SFTP |
| βοΈ Email |
SMTP with templates |
| π€ AI-native |
Built-in MCP server: the agent edits, validates, migrates, calls endpoints and queries data |
| π Studio |
Read-only web UI to browse your data |
How it feels
you βΊ Build me a blog backend: posts with comments, anyone can read,
only logged-in users can write, and email the author on each new comment.
agent βΊ set_table posts β set_table comments β set_relations β
set_function list_posts β set_function create_post β
set_function add_comment β steps[2].template_id: unknown email template "new_comment"
update_api_settings (email template new_comment) β
set_function add_comment β
call_endpoint POST /auth/register β 201
call_endpoint POST /fn/posts β 201
call_endpoint GET /fn/posts β 200 [1 post]
Done. Your API is running on http://localhost:8080.
The agent never hand-edits files blindly: every change is validated before it's saved.
If something is wrong, it gets an exact error such as
functions.add_comment.steps[2].template_id: unknown email template, fixes it and tries again.
Your supacraft.json is never left in a broken state.
Quick start
Install (Go 1.26+, or grab a binary from Releases):
go install github.com/attisvalentin/supacraft@latest
Create a project:
mkdir my-app && cd my-app
supacraft init
This creates:
my-app/
βββ supacraft.json β your entire backend
βββ .env β secrets (git-ignored)
βββ .gitignore
βββ .mcp.json β registers the SupaCraft MCP server for your AI agent
Build it with AI. Open the folder in Claude Code (or any MCP client that reads .mcp.json)
and describe what you want. The agent starts supacraft mcp, which also serves the API.
β¦or by hand. Edit supacraft.json and run:
supacraft dev # API on http://localhost:8080, re-applied on every save
A complete example
This file is a working blog API with users, posts and two endpoints:
{
"name": "blog",
"auth_enabled": true,
"schema": {
"tables": [
{
"name": "posts",
"columns": [
{ "name": "id", "type": "uuid", "primary": true },
{ "name": "title", "type": "varchar", "nullable": false },
{ "name": "author_id", "type": "uuid" },
{ "name": "created_at", "type": "timestamptz", "default_value": "NOW()" }
]
}
]
},
"functions": {
"list_posts": {
"route": { "path": "/fn/posts", "method": "GET" },
"steps": [
{ "type": "db.select", "table": "posts", "order_by": "created_at desc", "limit": 20, "assign": "posts" },
{ "type": "response", "status_code": 200, "data": { "posts": "{{posts}}" } }
]
},
"get_post": {
"route": { "path": "/fn/posts/{id}", "method": "GET" },
"steps": [
{ "type": "db.select", "table": "posts", "where": { "id": "{{params.id}}" }, "single": true, "assign": "post" },
{ "type": "if", "condition": "{{post}} == null", "then": [
{ "type": "fail", "status_code": 404, "message": "post not found" }
] },
{ "type": "response", "status_code": 200, "data": { "post": "{{post}}" } }
]
},
"create_post": {
"route": {
"path": "/fn/posts", "method": "POST", "auth_required": true,
"input": { "title": { "type": "string", "required": true, "min": 1, "max": 200 } }
},
"steps": [
{
"type": "db.insert", "table": "posts", "assign": "post",
"data": { "title": "{{request.title}}", "author_id": "{{auth.user_id}}" }
},
{ "type": "response", "status_code": 201, "data": { "post": "{{post}}" } }
]
}
}
}
Try it:
curl -X POST localhost:8080/auth/register -d '{"email":"a@b.co","password":"Secret123!"}'
TOKEN=$(curl -s -X POST localhost:8080/auth/login \
-d '{"email":"a@b.co","password":"Secret123!"}' | jq -r .data.token)
curl -X POST localhost:8080/fn/posts -H "Authorization: Bearer $TOKEN" -d '{"title":"Hello"}'
curl localhost:8080/fn/posts
The users table and the auth endpoints come from "auth_enabled": true; you don't declare them.
How it works
ββββββββββββββββββββββββ
AI agent βββΊβ supacraft mcp β validate β save β migrate β reload
(MCP) ββββββββββββ¬ββββββββββββ
βΌ
you ββeditβββΊ supacraft.json βββΊ compile βββΊ .supacraft/tenants/<app>.json βββΊ REST API
β (:8080)
ββββββββΊ additive migration βββΊ .supacraft/<app>.db (SQLite)
supacraft.json is the only source of truth. Everything is referenced by name (tables,
columns, functions), never by generated IDs, so the file stays readable and diff-friendly.
- Validation checks column types, that referenced tables and columns exist, step types and
their required fields, function calls, cron expressions, math expressions and more.
- Migrations are additive. New tables and columns are created automatically. SupaCraft never
drops or renames anything in your data.
- Runtime state (the SQLite database, uploaded files and the compiled config) lives in
.supacraft/, which is git-ignored.
Commands
| Command |
Description |
supacraft init [name] |
Create a new project (--auth=false to skip built-in users) |
supacraft dev |
Run the API and re-apply supacraft.json / .env on every change |
supacraft serve |
Apply once and run the API (production); --data-dir serves every tenant of a central server |
supacraft mcp |
MCP server for AI agents on stdio; also serves the API |
supacraft validate |
Check supacraft.json and print errors and warnings |
supacraft apply |
Migrate the database and write the compiled config (--data-dir = into a central server) |
supacraft tenants |
list, disable, enable, remove [--purge] tenants of a central server |
supacraft deploy |
Send supacraft.json to a central server: validate, migrate, go live (--dry-run first). Values from .env are never sent; write secrets as ${NAME} references, since literal values in supacraft.json are sent |
supacraft secrets |
set, unset, list a tenant's secrets on a central server (values never leave the server) |
supacraft studio |
Open a read-only data browser |
supacraft service install |
Install serve as a systemd service (Linux); --data-dir for a central server |
Every command accepts --dir / -C to point at a project directory.
dev, mcp and studio listen on 127.0.0.1 only, so your work-in-progress API is not reachable
from the network. Pass --host 0.0.0.0 to expose it (for example to test from a phone).
serve listens on all interfaces.
| Tool |
Purpose |
get_config, get_reference |
Read the project and the full format reference |
set_table, delete_table, set_relations |
Shape the database |
set_function, delete_function |
Custom /fn/... endpoints |
set_cronjob, delete_cronjob |
Scheduled jobs |
update_api_settings, set_auth |
Permissions, CORS, rate limits, email, storage, env |
validate, apply |
Check, or apply hand-made edits |
call_endpoint |
Send a real HTTP request to the running API |
query_db |
Read-only SQL against the database (the JWT key and password hashes are not readable) |
get_logs |
Recent API errors |
check_secrets |
Which ${NAME} secrets are missing (names only), and the command the user runs to set them |
The full supacraft.json reference is internal/docs/reference.md.
Agents get it as the supacraft://reference resource.
Secrets
Secrets never go into supacraft.json. Reference them as "${NAME}" and put the value in .env
or the process environment:
"api_settings": {
"env": { "STRIPE_KEY": "${STRIPE_KEY}" },
"email": { "smtp": { "host": "smtp.resend.com", "password": "${SMTP_PASSWORD}" } }
}
# .env
STRIPE_KEY=sk_live_...
SMTP_PASSWORD=...
On a central server, secrets are kept only on the server (<data-dir>/env/<tenant>.json, mode
0600). Deploys and compiled configs carry just the ${NAME} references; the server fills them in
when it loads a tenant, so a new value takes effect within seconds. You set them from your
machine, typing the value into a hidden prompt:
# in the project's .env (not secret values, just how to reach the server)
SUPACRAFT_SERVER=https://api.example.com
SUPACRAFT_ADMIN_SECRET=... # same value as on the server
supacraft secrets list # names only: which are set, which are missing
supacraft secrets set STRIPE_KEY # Value for STRIPE_KEY (input hidden): β’β’β’β’
supacraft deploy # refuses, listing the names, while a secret is missing
The AI agent never sees the values: its check_secrets tool reports names and gives you the
command to run.
Deploying
Many APIs on one server
One supacraft serve process can run every API you have. Each project is a tenant in a
central data directory, and the X-Tenant-ID header of each request picks the API:
# on the server, once
sudo supacraft service install --data-dir /var/lib/supacraft
# to manage secrets from your machine (see Secrets), the service reads
# /var/lib/supacraft/.env (chmod 600): SUPACRAFT_ADMIN_SECRET=<openssl rand -hex 32>
# from your machine: add or update an API β the server validates it, creates or migrates
# its database and serves it within seconds, without a restart
cd shop && supacraft deploy # --dry-run shows the migration first
# or on the server itself
supacraft apply -C ./shop --data-dir /var/lib/supacraft
curl -H "X-Tenant-ID: shop" https://api.example.com/fn/products
/var/lib/supacraft/
βββ tenants/shop.json β compiled config of each tenant
βββ tenants/blog.json
βββ shop.db β one SQLite database per tenant
βββ blog.db
βββ env/shop.json β server-side secrets of each tenant (0600)
βββ storage/<tenant>/ β uploaded files
βββ errors.db
The tenant id comes from the project name ("name": "My Shop" β my_shop). Manage tenants with
supacraft tenants list | disable <id> | enable <id> | remove <id> [--purge]. A disabled tenant
answers 503 and its cron jobs pause until you enable it again; applying it again doesn't re-enable
it. remove keeps the database unless you add --purge, which deletes the database and locally stored uploads (files in S3 or another remote storage driver have to be removed there). Pass --default-tenant <id> to
serve if requests without the header should go to one tenant.
Back up the whole data directory, for example with Litestream.
One project
SupaCraft is a single static binary. Copy your project folder to a server and run:
supacraft serve --port 8080 # or:
sudo supacraft service install # systemd, restarts on failure
Put a reverse proxy (Caddy, nginx) in front for HTTPS. In that setup, run with --host 127.0.0.1
so only the proxy can reach the API, and set TRUST_PROXY=1 so rate limits see real client
addresses. To back up the app, back up .supacraft/
(for example with Litestream for continuous SQLite replication).
Server settings
| Variable |
Default |
Purpose |
HOST / PORT |
see above / 8080 |
Listen address (same as --host / --port) |
TRUST_PROXY |
off |
Read client IPs from X-Real-IP / X-Forwarded-For (only behind a proxy) |
MAX_BODY_SIZE |
1048576 |
Max JSON request body in bytes |
MAX_FILE_SIZE |
104857600 |
Max upload size in bytes |
STUDIO_SECRET |
random |
Studio password |
SUPACRAFT_DATA_DIR |
β |
Central data directory (same as --data-dir) |
SUPACRAFT_ADMIN_SECRET |
off |
Signs remote management (deploys, secrets) of a central server; at least 32 characters (openssl rand -hex 32). Admin endpoints are off without it |
SUPACRAFT_SERVER |
β |
On your machine: URL of the central server for supacraft deploy and supacraft secrets |
Security
Found a vulnerability? Please report it privately through
GitHub Security Advisories
rather than in a public issue.
Is it for me?
Good fit: MVPs, hackathons, prototypes, internal tools, side projects, mobile or SPA
backends, and anything where "working today" beats "infinitely flexible".
Not (yet) a fit: large multi-node deployments (SQLite, one process), apps that need
destructive schema migrations, or complex business logic that really wants a general-purpose
language.
Roadmap ideas
These are open for discussion, and PRs are welcome:
- OpenAPI export so agents and frontends can generate typed clients
- Destructive migrations (rename/drop) with explicit confirmation
- Optional visual schema viewer in Studio
- PostgreSQL as an alternative storage driver
Contributing
Issues and pull requests are welcome. Please read CONTRIBUTING.md first.
Every PR gets an automated review from CodeRabbit and must pass CI and
a maintainer review before it can be merged.
License
MIT