supacraft

command module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README ΒΆ

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.

CI


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:

  1. The whole backend is one file, supacraft.json. Tables, permissions, endpoints, cron jobs: everything is declarative JSON that lives in your git repo.
  2. 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.
  3. 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/... routes built from steps: query, insert, if/else, loops, 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", "assign": "posts" },
        { "type": "response", "status_code": 200, "data": { "posts": "{{posts}}" } }
      ]
    },
    "create_post": {
      "route": { "path": "/fn/posts", "method": "POST", "auth_required": true },
      "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)
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
supacraft studio Open a read-only data browser
supacraft service install Install serve as a systemd service (Linux)

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.

MCP tools

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
get_logs Recent API errors

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=...

Deploying

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

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

Documentation ΒΆ

The Go Gopher

There is no documentation for this package.

Directories ΒΆ

Path Synopsis
Package cmd implements the supacraft CLI.
Package cmd implements the supacraft CLI.
internal
app
Package app runs the SupaCraft API server (REST, auth, files, pipeline functions and the cron scheduler) in-process.
Package app runs the SupaCraft API server (REST, auth, files, pipeline functions and the cron scheduler) in-process.
docs
Package docs embeds the supacraft.json reference served to AI agents.
Package docs embeds the supacraft.json reference served to AI agents.
mcpserver
Package mcpserver exposes a SupaCraft project to AI agents over MCP (stdio).
Package mcpserver exposes a SupaCraft project to AI agents over MCP (stdio).
project
Package project is the local, file-based source of truth for a SupaCraft backend.
Package project is the local, file-based source of truth for a SupaCraft backend.
sqlitedb
Package sqlitedb provisions per-tenant SQLite databases.
Package sqlitedb provisions per-tenant SQLite databases.
sqlitedb/ddl
Package ddl is SupaCraft's SQLite DDL engine.
Package ddl is SupaCraft's SQLite DDL engine.
studio
Package studio is a local, read-only database viewer for SupaCraft projects (Drizzle-Studio style).
Package studio is a local, read-only database viewer for SupaCraft projects (Drizzle-Studio style).
tenantfile
Package tenantfile reads and writes compiled tenant configs under {DataDir}/tenants/{id}.json β€” the same path internal/tenant.FileStore reads.
Package tenantfile reads and writes compiled tenant configs under {DataDir}/tenants/{id}.json β€” the same path internal/tenant.FileStore reads.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL