BackendGen

io.github.SiTouhemi由 GitHub 帳號 SiTouhemi 發布v0.2.2更新於 Oct 24, 2026

Validate compact backend specs and generate tested NestJS, Prisma, and PostgreSQL repositories.

已驗證STDIO僅桌面資料庫開發者工具

概覽

AI 產生的概覽

讓助手在本機驗證精簡的後端規格,並產生經過測試的 NestJS、Prisma 與 PostgreSQL 程式碼儲存庫。

可以做什麼
BackendGen 是透過 MCP 暴露的確定性後端編譯器。助手可以探索支援的後端功能、驗證帶版本的 YAML 或 JSON 規格、用 diff 預覽變更、產生獨立的 NestJS 11 + Prisma 6 + PostgreSQL 儲存庫、執行產生的測試,並回傳前端交接契約與自訂指引。只有在明確要求審查時才會回傳遷移 SQL,一般回應中不包含產生的原始碼。
適用情境
當 AI 助手需要在前端背後提供真實後端,而你希望取得結構化、經過測試的程式碼,而不是憑空編造的資料模型、權限、路由與遷移時,可以使用它。它適合由開發者審查、自訂並部署產生儲存庫的本機專案或設計夥伴專案。
執行需求
以 npm 套件形式透過 stdio 在本機執行,不需要 BackendGen 帳號或網路監聽。需要 Node.js 22 或更新版本以及 npm 10 或更新版本。只有在執行產生專案的整合測試時才需要 PostgreSQL。選用環境變數 BACKENDGEN_ALLOWED_ROOTS 可限制其可讀寫的檔案系統根目錄。
安裝前請注意
它會將產生的儲存庫寫入磁碟,因此應把 BACKENDGEN_ALLOWED_ROOTS 設定為僅限你信任的目錄。重新產生會保留自訂檔案,且除非使用 --force,否則不會覆寫被修改過的產生檔案;破壞性或依賴資料的結構變更需要明確審查。此軟體處於 Alpha 階段:在正式使用前請審查產生的應用程式、密鑰、基礎設施與部署設定。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 BackendGen,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

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.

sh
mkdir backendgen-trycd backendgen-try
npx -y @2hemi/backendgen init backend.yaml --name team-apinpx -y @2hemi/backendgen validate backend.yamlnpx -y @2hemi/backendgen generate backend.yaml --output ./team-api
cd team-apinpm installnpm test

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:

sh
npx -y @2hemi/backendgen diff backend.yaml --output ./team-api

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:

sh
git clone https://github.com/SiTouhemi/Backendgen.gitcd Backendgen
npx -y @2hemi/backendgen validate examples/saas-tasks/backend.yamlnpx -y @2hemi/backendgen generate examples/saas-tasks/backend.yaml --output ./generated/saas-tasks
cd generated/saas-tasksnpm installnpm test

Browse every example and what it demonstrates in examples/README.md:

ExampleDemonstrates
notes APICRUD, filtering, pagination, and sorting
auth notesAccounts, roles, ownership, and authentication
SaaS tasksOrganizations and enforced tenant isolation
hotel bookingReservations, overlap prevention, and notifications
all featuresCRUD, auth, organizations, reservations, notifications, webhooks, jobs, and uploads

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:

json
{  "mcpServers": {    "backendgen": {      "command": "npx",      "args": ["-y", "@2hemi/backendgen-mcp"],      "env": {        "BACKENDGEN_ALLOWED_ROOTS": "/absolute/path/to/projects"      }    }  }}

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 and src/custom/ for code you own;
  • a .backendgen/manifest.json that records ownership and hashes;
  • frontend-contract.json and 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

If you need to…Read
Write a specificationSpecification reference
Understand each supported featureFeature packs
Connect an AI agent or MCP clientAI builder integration
Customize a generated projectCustomization guide
Safely regenerate or change a schemaMigrations guide
Run tests locallyLocal testing
Understand security boundariesThreat model
ContributeContributing

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:

  1. what you were trying to build;
  2. your sanitized backend.yaml specification;
  3. the command or MCP client you used;
  4. 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:

sh
npm cinpm testnpm run test:fuzz:cinpm run test:e2enpm run test:distribution

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.

來源:README.md,提交 d2c2cd3

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.2.2最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分