
BackendGen
io.github.SiTouhemiPublished by GitHub account SiTouhemiv0.2.2Updated Oct 24, 2026
Validate compact backend specs and generate tested NestJS, Prisma, and PostgreSQL repositories.
Overview
Lets an assistant validate compact backend specs and generate tested NestJS, Prisma, and PostgreSQL repositories locally.
- What you can do
- BackendGen is a deterministic backend compiler exposed over MCP. An assistant can discover supported backend features, validate a versioned YAML or JSON specification, preview changes with a diff, generate a standalone NestJS 11 + Prisma 6 + PostgreSQL repository, run the generated tests, and return a frontend handoff contract plus customization guidance. Migration SQL is returned only when explicitly requested for review, and generated source is omitted from normal responses.
- When to use it
- Use it when an AI agent needs a real backend behind a frontend and you want structured, tested code instead of models, permissions, routes, and migrations invented from scratch. It suits local or design-partner projects where a developer will review, customize, and deploy the generated repository.
- Requirements
- Runs locally over stdio as an npm package; no BackendGen account or network listener is required. Needs Node.js 22 or newer and npm 10 or newer. PostgreSQL is needed only to run a generated project's integration tests. The optional BACKENDGEN_ALLOWED_ROOTS environment variable limits the filesystem roots it may read and write.
Installation
In SourceWeft
- Open BackendGen in the dashboard and add it to a workspace.
- Enable the server for the chats that should use its tools.
Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.
Other MCP clients
Follow the launch instructions in the repository.
README
BackendGen
BackendGen is a deterministic backend compiler for AI coding agents. Give an agent a compact, versioned YAML or JSON specification and it can generate a structured, tested backend instead of inventing database models, permissions, API routes, and migrations from scratch.
It currently generates NestJS 11 + Prisma 6 + PostgreSQL repositories,
including a typed TypeScript client and a small frontend-contract.json for
the frontend agent to consume. Generated projects have no BackendGen runtime
dependency.
Alpha status: BackendGen is ready for design-partner trials and local projects. Review generated applications before production use; it has not yet completed independent security review or three design-partner trials.
npm CLI · npm MCP server · Report an issue · Design-partner program
What it is for
BackendGen is useful when an AI agent needs a real backend behind a frontend:
- model entities, relations, filters, sorting, and pagination;
- add authentication, roles, row ownership, organizations, and tenant isolation;
- generate reservations, notifications, webhooks, durable jobs, and uploads;
- preserve a clean boundary between compiler-owned code and application-owned custom code;
- safely regenerate after a specification changes, with incremental migrations and explicit review gates for destructive changes.
BackendGen is not a hosted backend service, deployment platform, or frontend builder. It runs locally and produces code that a developer or coding agent can review, customize, test, deploy, and connect to a frontend.
Requirements
- Node.js 22 or newer
- npm 10 or newer
- PostgreSQL only when you want to run a generated project's integration tests
Try it in five minutes
You do not need an npm account or this repository to try BackendGen.
The generated project runs prisma generate during installation, so this
first-run path does not require a separate Prisma command. From the parent
directory, use
npx -y @2hemi/backendgen test-generated --output ./team-api --install when an
agent should perform installation, validation, build, and unit tests through
one bounded compiler command.
init creates a valid starter specification. Edit backend.yaml, then run
validate and generate again. Before regenerating an existing project, use
diff to preview what would change:
Test a complete SaaS example
The repository includes working specifications from basic CRUD to a full-featured backend. This multi-tenant task example is a good first test:
Browse every example and what it demonstrates in examples/README.md:
Use it with an AI coding agent (MCP)
The MCP package lets an AI agent discover supported backend features, validate a spec, preview changes, generate a backend, run generated tests, return the frontend handoff contract and customization guidance. It can also explain customization points. It runs locally over stdio—no BackendGen account or network listener is required.
Migration SQL is returned only when the agent explicitly requests it for review; generated source remains omitted from normal responses.
Add this server to an MCP-capable client, giving it only a directory you trust:
For Codex, Claude Code, Cursor, ChatGPT desktop, Windows, Lovable Desktop, and the correct v0 handoff, follow the client-specific commands in docs/AI_BUILDERS.md. The complete MCP security and tool reference is in docs/MCP.md.
Once connected, give your agent a request such as:
Create a multi-tenant task-management backend. First inspect BackendGen's capabilities and relevant features. Write a spec, validate it, preview the generation, generate it inside this project, and run the generated tests. Keep custom behavior in the documented customization points.
What is generated
For a valid specification, BackendGen produces a standalone repository with:
- a NestJS API, Prisma schema, PostgreSQL migrations, OpenAPI setup, and tests;
- generated endpoints and permission rules derived from the normalized spec;
src/generated/for compiler-owned code andsrc/custom/for code you own;- a
.backendgen/manifest.jsonthat records ownership and hashes; frontend-contract.jsonand a typed TypeScript client for frontend agents.
On regeneration, BackendGen preserves custom files, refuses to overwrite edited
generated files unless you explicitly use --force, and requires explicit
review for destructive or data-dependent schema changes. Read
docs/MIGRATIONS.md before changing a live schema.
Verification and limits
The repository's CI verifies compiler, CLI, MCP, security-contract fuzzing, package-installation, and generated-project scenarios. Generated projects are also built and tested against PostgreSQL in the release test matrix. See the local verification record and security contract for the exact evidence.
That evidence does not prove that every generated application is safe for production. You remain responsible for reviewing the specification, generated code, secrets, infrastructure, and deployment configuration.
Current boundaries:
- one production target: NestJS + Prisma + PostgreSQL;
- FastAPI and other backend targets are intentionally out of scope;
- no hosted BackendGen SaaS or direct browser-v0 MCP integration yet;
- do not make token-savings claims until the paired benchmark has real results.
Documentation
Feedback and support
We are looking for developers and AI builders who will test BackendGen on a real, non-production project. Please open an issue with:
- what you were trying to build;
- your sanitized
backend.yamlspecification; - the command or MCP client you used;
- what worked, what was confusing, and what you expected instead.
Never include API keys, .env files, private customer code, or production
database data. For security vulnerabilities, follow SECURITY.md
instead of opening a public issue. Full support details are in SUPPORT.md.
Development
To work on BackendGen itself:
Maintainers preparing a release can run the same non-publishing gate through
npm run verify:release. PostgreSQL-backed execution remains the separate
npm run verify:local:postgres workflow described in
local testing.
BackendGen is licensed under Apache-2.0. Generated projects belong to their users.
Source: README.md at commit d2c2cd3
Tools
0Version history
1- v0.2.2LatestSep 16, 2026
Score
50% of the applicable checks met
How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.
- Reached in the last 30 days25 pts
Keep the endpoint answering the MCP handshake; SourceWeft probes it every 30 days.
- Auth declared10 pts
Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.
- Tools listed15 pts
Answer tools/list without a credential, or ship a package that starts in a sandbox without one.
- DescriptionRequired15 pts
- Logo10 pts
- Documentation15 pts
- License10 pts