Skip to content
profullstackPublic

About

DBML for AI agents: validate, review and convert database schemas over an HTTP API, MCP server and CLI. https://dbml.db.pit.world

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

dbml.db

DBML as a service for AI agents. Build, validate, review and convert database schemas written in DBML over an HTTP API, an MCP server and a CLI.

Free, no account, rate limited per caller. No AI model is called: every answer is deterministic.

What it does

API MCP tool CLI
Validate (errors with line/column) POST /api/v1/validate validate_dbml dbml validate
Parse to a JSON model POST /api/v1/parse parse_dbml dbml parse
Summary (counts, outline) POST /api/v1/summary summarize_dbml dbml summary
Review (lint, score 0-100) POST /api/v1/review review_dbml dbml review, dbml watch
Canonical format POST /api/v1/format format_dbml dbml format
DBML to SQL (postgres, mysql, mssql, oracle) POST /api/v1/dbml-to-sql dbml_to_sql dbml to-sql
SQL to DBML (postgres, mysql, mssql, oracle, snowflake, schemarb, json) POST /api/v1/sql-to-dbml sql_to_dbml dbml from-sql
Review rules GET /api/v1/rules list_review_rules dbml rules
DBML cheat sheet GET /api/v1/syntax dbml_syntax dbml syntax
curl -s https://dbml.db.pit.world/api/v1/review -H 'content-type: application/json' \
  -d '{"dbml":"Table users { id int [pk]\n email varchar }"}'

curl -s 'https://dbml.db.pit.world/api/v1/dbml-to-sql?dialect=mysql' \
  -H 'content-type: text/plain' --data-binary @schema.dbml

claude mcp add --transport http dbml https://dbml.db.pit.world/mcp

Invalid DBML answers 422 with errors: [{message, line, column, end_line, end_column, code}] (/validate answers 200 with valid: false).

Review rules

Missing primary keys, refs to non-unique columns, foreign key type mismatches, unindexed and nullable foreign keys, many-to-many refs, duplicate and redundant indexes, SQL reserved words, float money columns, varchar without length on MySQL/SQL Server, mixed naming styles and singular/plural table names, columns that look like keys with no ref, isolated tables, missing timestamps, unused enums and wide tables. GET /api/v1/rules is the list.

The DBA agent (Ask, pay as you go)

A DBA as a service: a database question in plain words gets an answer grounded in the engine. The schema's summary, every review finding and exact SQL go into the prompt, and the checker's exact output is added to convert and review answers. 5 cents per answered question from a prepaid balance; failures are free. Top up $5/$10/$20 through CoinPay's hosted checkout (no subscriptions).

  • People: the "Ask the DBA agent" button on the home page asks about the playground's schema in place; /ask is the full page with every past answer. Anyone gets a personal link there (POST /api/signup, 5 per IP per hour, SIGNUP_CREDIT_CENTS free credit, default 0).
  • Agents: POST /api/ask + GET /api/ask/<id> with Authorization: Bearer <token>, or the MCP tools ask_dba / ask_dba_result with the same header on the /mcp connection.
  • Models: c0mpute first through @profullstack/ai-providers. OpenAI or Claude is offered for a question only when its price is at least ASK_MIN_MARGIN (2) x the worst-case cost of the paid call (prompt at 3 chars/token, all 2,500 output tokens, plus any paid attempt that already failed). Rates per million tokens: AI_COST_OPENAI_IN/OUT (0.25/2, gpt-5-mini) and AI_COST_ANTHROPIC_IN/OUT (0.10/0.50, claude-haiku-5-5); set them when changing AI_OPENAI_MODEL / AI_ANTHROPIC_MODEL.

Operator (ADMIN_KEY from the vault):

DBML_ADMIN_KEY=... node bin/admin.js create "Name" --credit 1000   # prints the personal link
node bin/admin.js list | credit <id> <cents> | link <id> | revoke <id> | costs | backup <file>

State is one SQLite file in /data (the c0mpute app state directory).

Run it

pnpm install
pnpm start          # http://localhost:8080
pnpm test

Env: PORT (8080), HOST, SITE_URL (https://dbml.db.pit.world), RATE_LIMIT_PER_MIN (60). Paid tier (optional): COINPAY_X402_KEY (scoped CoinPay key with payments:create) and CRAWL_PAY_TO (EVM address); with both set, a caller over the free limit is offered a $1 day pass over x402 / CoinPay checkout instead of a plain 429. Keys live in the logicsrc vault profullstack/dbml-db--prod, never in the repo.

Deploy

c0mpute Apps (stateless, 2 copies, primary on vienna2, dev2 allowed):

sh deploy/deploy.sh                       # prints the app id
moshcode name c0mpute dbml.db <app_id>    # only when the app id changes

The Moshpit name dbml.db (ending .db) serves the app; the web2 address is https://dbml.db.pit.world.

TODO

  • Human review marketplace: let an agent request a paid review of its schema by a human DBA through c0mpute.com/humans. Not built.
  • Diagram rendering (SVG) of a schema.

Credits and license

Parsing and SQL import/export use @dbml/core by Holistics, licensed Apache-2.0 (see NOTICE). DBML is their language; this is an independent service. The code in this repository is MIT, Copyright (c) 2026 Profullstack, Inc.

About

DBML for AI agents: validate, review and convert database schemas over an HTTP API, MCP server and CLI. https://dbml.db.pit.world

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages