SchemaForge
Define your data model once. Get migrations, CRUD endpoints, and API docs automatically.
SchemaForge is a Rust toolkit that turns human-readable schema definitions into fully operational backends -- no recompilation required. Write a schema file (or describe what you need in plain English), and SchemaForge generates database tables, CRUD API endpoints, migrations, authorization policies, and API documentation at runtime.
schema Contact {
name: text(max: 255) required indexed
email: text(max: 512) required indexed
phone: text
priority: enum("low", "medium", "high") default("medium")
company: -> Company
tags: text[]
notes: richtext
is_active: boolean default(true)
}
From this single file, SchemaForge generates:
- Database tables with type enforcement and constraints (SurrealDB)
- REST API routes with input validation for every entity
- Migration plans that diff against your existing schema
- Cedar authorization policies for access control
- OpenAPI specifications that stay in sync with your schemas
Try it in 2 minutes
The repo ships a demo with twelve seeded entities and a React admin UI. Testcontainers starts a disposable SurrealDB server for the demo.
Prerequisites
| Tool |
Why it's needed |
| Rust 1.97.1+ |
The demo builds the CLI from source |
| Docker |
Runs the disposable SurrealDB server |
| Task |
Runs the bundled demo recipes |
| pnpm + Node 20+ |
Builds and serves the React admin |
Run the demo
git clone https://github.com/Govcraft/schemaforge
cd schemaforge
task demo # starts a disposable database and backend on :3000, seeds 12 entities
In a second terminal:
task site:dev # regenerates the React admin and serves it on :5173
Open http://localhost:5173 and sign in with admin / changeme.
The separate database server keeps demo data in memory, so nothing persists between runs; press Ctrl+C in the task demo terminal to stop. For a persistent SurrealDB or PostgreSQL deployment, see Install for a Real Project.
Table of Contents
Why SchemaForge
Traditional backend development requires you to define your model in code, write a migration, build CRUD handlers, add validation, wire up authorization, and generate API docs -- separately, for every entity. When a schema changes, you repeat the cycle.
SchemaForge collapses that workflow. One schema file is the single source of truth for your entire entity lifecycle. Change the schema, and everything downstream updates automatically: migrations are computed by diffing versions, routes adapt, validation adjusts, and the OpenAPI spec regenerates.
The AI agent takes this further. Describe what you need in plain English, and an LLM generates the schema, validates it through the tool execution loop (self-correcting any errors), and applies it to your database -- all without writing DSL by hand.
Install for a Real Project
This section walks through running SchemaForge against a real SurrealDB,
PostgreSQL, or Microsoft SQL Server instance: install the binary, scaffold a
project, define a schema, and serve it. If you only want to kick the tires, the
self-contained demo above is faster.
Prerequisites
- A running SurrealDB 3.3+, PostgreSQL 14+, or Microsoft SQL Server instance (SurrealDB embedded mode works for development)
- Rust 1.97.1+ only if you intend to build from source
Install the Prebuilt Binary
Each release ships a single statically-linked schemaforge binary for Linux x86_64, built against exactly one database backend. Pick the flavor that matches your target database and run the matching one-liner:
# PostgreSQL build
TAG=$(curl -fsSL https://api.github.com/repos/Govcraft/schemaforge/releases/latest | grep '"tag_name"' | cut -d'"' -f4) && \
curl -fsSL "https://github.com/Govcraft/schemaforge/releases/download/${TAG}/schemaforge-${TAG}-x86_64-unknown-linux-gnu-postgres.tar.gz" \
| sudo tar -xz -C /usr/local/bin
# SurrealDB build
TAG=$(curl -fsSL https://api.github.com/repos/Govcraft/schemaforge/releases/latest | grep '"tag_name"' | cut -d'"' -f4) && \
curl -fsSL "https://github.com/Govcraft/schemaforge/releases/download/${TAG}/schemaforge-${TAG}-x86_64-unknown-linux-gnu-surrealdb.tar.gz" \
| sudo tar -xz -C /usr/local/bin
# Microsoft SQL Server build
TAG=$(curl -fsSL https://api.github.com/repos/Govcraft/schemaforge/releases/latest | grep '"tag_name"' | cut -d'"' -f4) && \
curl -fsSL "https://github.com/Govcraft/schemaforge/releases/download/${TAG}/schemaforge-${TAG}-x86_64-unknown-linux-gnu-mssql.tar.gz" \
| sudo tar -xz -C /usr/local/bin
For Windows with Microsoft SQL Server support, download
schemaforge-<version>-x86_64-pc-windows-msvc-mssql.zip. The archive contains
schemaforge.exe and its keyless Sigstore bundle,
schemaforge.exe.sigstore.json.
Each command downloads the latest release tarball, extracts the schemaforge binary into /usr/local/bin, and leaves it immediately runnable. To install somewhere on your PATH without sudo, swap /usr/local/bin for a user-writable directory such as ~/.local/bin.
The backend is compiled in — there is no runtime flag to switch among PostgreSQL,
SurrealDB, and Microsoft SQL Server. If you need multiple backends, download the
corresponding tarballs and rename the binaries (for example schemaforge-pg and
schemaforge-mssql).
Verify the install:
schemaforge --version
Verify Release Authenticity
Every release ships a SHA256SUMS manifest plus a Sigstore keyless signature (SHA256SUMS.sig + SHA256SUMS.pem). The signing certificate is bound via OIDC to the release.yml workflow on a tag in this repo and logged to the public Rekor transparency log — no long-lived signing keys are involved.
For production or audited deployments, verify before running the binary:
TAG=$(curl -fsSL https://api.github.com/repos/Govcraft/schemaforge/releases/latest | grep '"tag_name"' | cut -d'"' -f4)
BASE="https://github.com/Govcraft/schemaforge/releases/download/${TAG}"
# 1. Download the tarball you want plus the manifest and signature
curl -fsSLO "${BASE}/schemaforge-${TAG}-x86_64-unknown-linux-gnu-postgres.tar.gz"
curl -fsSLO "${BASE}/SHA256SUMS"
curl -fsSLO "${BASE}/SHA256SUMS.sig"
curl -fsSLO "${BASE}/SHA256SUMS.pem"
# 2. Verify the checksum matches
sha256sum --ignore-missing -c SHA256SUMS
# 3. Verify the signature was produced by this repo's release workflow
cosign verify-blob \
--certificate SHA256SUMS.pem \
--signature SHA256SUMS.sig \
--certificate-identity-regexp "^https://github.com/Govcraft/schemaforge/\\.github/workflows/release\\.yml@refs/tags/" \
--certificate-oidc-issuer https://token.actions.githubusercontent.com \
SHA256SUMS
A successful run prints Verified OK. The cosign binary is available from sigstore/cosign (single static binary, no daemon).
The Windows executable is also signed directly. After extracting its ZIP,
verify it from PowerShell before execution:
cosign verify-blob `
--bundle schemaforge.exe.sigstore.json `
--certificate-identity-regexp '^https://github\.com/Govcraft/schemaforge/\.github/workflows/release\.yml@refs/tags/' `
--certificate-oidc-issuer https://token.actions.githubusercontent.com `
schemaforge.exe
This is a Sigstore signature tied to the tagged GitHub Actions workflow, not an
Authenticode publisher certificate.
Build from Source (alternative)
If you need a different target triple, or want to track main:
# PostgreSQL build
cargo install --git https://github.com/Govcraft/schemaforge schema-forge-cli \
--no-default-features --features postgres
# SurrealDB build
cargo install --git https://github.com/Govcraft/schemaforge schema-forge-cli \
--no-default-features --features surrealdb
# Microsoft SQL Server build (SQL credentials or integrated authentication)
cargo install --git https://github.com/Govcraft/schemaforge schema-forge-cli \
--no-default-features --features mssql
# FIPS-validated PostgreSQL build (federal deployments)
cargo install --git https://github.com/Govcraft/schemaforge schema-forge-cli \
--no-default-features --features postgres,fips
FIPS builds
The fips feature routes rustls through aws-lc-rs compiled against the
FIPS-validated AWS-LC C library (aws-lc-fips-sys). When enabled,
SchemaForge installs aws_lc_rs as the process-wide rustls
CryptoProvider at startup so every TLS-using subsystem — sqlx
(PostgreSQL), reqwest (S3), tonic (hook dispatcher) — terminates through
the FIPS module.
Build requirements:
- CMake 3.10+
- Clang 14–18 (FIPS module integrity checks reject the relocation
sections clang ≥19 emits; AWS-LC-FIPS 3.0.x targets clang ≤18). Point
cargo at the right compiler with
CC=/path/to/clang-18 CXX=/path/to/clang++-18 for the build.
- Perl
- Go 1.18+ (required by AWS-LC's
delocate tool when targeting FIPS)
- Supported platform per aws-lc-fips-sys
Note: the surrealdb backend pulls rustls with ring transitively and
is not suitable for FIPS deployments. Pair fips with postgres.
Microsoft SQL Server and Windows authentication
SQL Server uses acton-service's canonical [database] configuration. Use an
ADO-style connection string; set mssql_auth = "integrated" to authenticate as
the service process through SSPI on Windows or Kerberos/GSSAPI on Unix:
[database]
url = "Server=sql01;Database=schemaforge;TrustServerCertificate=true"
mssql_auth = "integrated"
SchemaForge can also consume Windows identities from a trusted reverse proxy
that has completed HTTP Negotiate authentication. The proxy must connect with
mTLS, its certificate SAN must appear in both allowlists below, and the
listener's [tls].client_ca_path must trust the proxy certificate issuer.
Forwarded identity headers from any other caller are ignored.
[caller_auth]
mode = "mtls-or-bearer"
allowlist = ["schemaforge-auth-proxy.internal"]
[caller_auth.windows]
trusted_proxies = ["schemaforge-auth-proxy.internal"]
identity_header = "x-windows-user"
groups_header = "x-windows-groups"
group_roles = { "CONTOSO\\SchemaForge Admins" = "admin" }
The resulting Windows principal and mapped roles become the same unified
claims used by SchemaForge's tenant and Cedar authorization layers. Bearer
authentication remains available because the caller mode is
mtls-or-bearer.
Scaffold a Project
schemaforge init my-platform
cd my-platform
This creates:
my-platform/
├── Cargo.toml
├── config.toml
├── acton-ai.toml
├── schemas/
├── policies/
│ ├── generated/
│ └── custom/
└── src/
└── main.rs
The generated config.toml is seeded with [schema_forge] project_name = "my-platform" — the human-facing name shown to users in invitation emails and used as the default email From display-name. Edit it to whatever your users should recognize.
Define a Schema
Create a file at schemas/crm.schema:
@version(1)
@display("name")
schema Company {
name: text(max: 255) required indexed
website: text(max: 500)
industry: enum("fintech", "saas", "healthcare", "other")
employee_count: integer(min: 1)
address: composite {
street: text
city: text required
state: text
zip: text
country: text required
}
}
@version(1)
@display("email")
schema Contact {
first_name: text(max: 100) required
last_name: text(max: 100) required
email: text(max: 255) required indexed
phone: text(max: 20)
status: enum("active", "inactive", "lead") default("lead")
company: -> Company
tags: text[]
notes: richtext
}
Validate, Apply, and Serve
# Parse and validate your schemas
schemaforge parse schemas/
# Apply schemas to SurrealDB (creates tables, fields, indexes)
schemaforge apply schemas/ --db-url ws://localhost:8000
# Preview migration steps without applying
schemaforge apply schemas/ --dry-run
# Start the API server with dynamic CRUD routes
schemaforge serve --schemas schemas/ --db-url ws://localhost:8000 --db-ns app --db-name main
Once served, every registered schema automatically gets REST endpoints:
POST /forge/entities/contact Create a contact
GET /forge/entities/contact List/query contacts
GET /forge/entities/contact/:id Get a contact by ID
PUT /forge/entities/contact/:id Update a contact
DELETE /forge/entities/contact/:id Delete a contact
GET /forge/schemas List all schemas
GET /forge/openapi.json Dynamic OpenAPI specification
The paths above use the unversioned /forge/... prefix. The schemaforge entity CLI calls the same routes under the versioned base /api/v1/forge/...