
Backgen
io.github.IbrahimKhaled19由 GitHub 帳號 IbrahimKhaled19 發布v1.14.0更新於 Oct 24, 2026
Generate Express.js backend projects with ORMs, auth, payments, and DevOps
概覽
BackGen 的本機 MCP 伺服器讓 AI 助理依所選 ORM、外掛與 CRUD 資源來建立和修改 Express.js 後端專案。
- 可以做什麼
- 依所選 ORM、預設集與外掛建立新的後端專案,並列出可用預設集、外掛或讀取清單中的專案中繼資料(init_project、list_presets、list_plugins、project_info)。新增或移除 JWT、Clerk、Stripe、S3、限流及 DevOps 等外掛(add_plugin、remove_plugin)。產生含欄位、關聯、驗證與 Swagger 文件的 CRUD 資源模組,以及種子檔與測試工廠(generate_resource、generate_seed、generate_factory)。檢查現有 BackGen 專案的設定問題(doctor)。
- 適用情境
- 適合讓助理快速初始化 Express.js 與 TypeScript 後端、加入驗證、付款、儲存或 CI 外掛,或在既有 BackGen 專案中產生 CRUD 模組與種子資料,而不必自行輸入 CLI 指令。
- 執行需求
- 以本機 stdio 程序在桌面執行,可透過 npx 加上套件名稱與 mcp 參數啟動,或使用 backgen mcp 指令。需要 Node.js(doctor 會檢查版本至少 18)與 npm。未宣告驗證、環境變數或標頭。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Backgen,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
BackGen
[CI] [npm version] [License: MIT]
[npm downloads] [GitHub stars]
🤖 AI-Ready
[BackGen MCP server] [BackGen MCP server]
BackGen ships a built-in MCP (Model Context Protocol) server that AI assistants (Claude, Cursor, GitHub Copilot, VS Code) can use to scaffold projects on your behalf.
Run via CLI:
Or configure your AI tool's MCP client:
Available MCP tools:
Then just ask: "Scaffold a SaaS backend with Prisma, JWT auth, and Stripe payments"
[BackGen CLI generating Express.js backend with Prisma, Drizzle, and Mongoose — Swagger docs, Docker, auth, and multi-tenant SaaS preset] > Generate production-ready backend foundations so developers can focus on business logic, not boilerplate.
BackGen is a CLI tool that generates complete Express.js backend projects on Prisma, Drizzle, or Mongoose — with authentication, multi-tenant infrastructure, production hardening, Docker, and testing — all working out of the box.
Swagger docs at http://localhost:3000/docs in under 60 seconds. Pick your ORM, keep everything else.
Features
- Express + TypeScript — strict mode, ESLint 9 (flat config), Vitest
- Multi-ORM — Prisma, Drizzle, or Mongoose. Pick at
inittime, switch later via the manifest - SaaS-ready —
saas-corepreset ships Organizations, Memberships, Invitations, RBAC, tenant-scoped queries - Hardened by default — helmet, strict CORS, request ID, request timeout, xss + mongo-sanitize, graceful shutdown,
/health+/ready, error envelope - Plugin System — JWT, Clerk, Stripe, S3, ratelimit via
backgen add - Resource Generator — CRUD modules with relations, validation, Swagger
- Domain Presets — saas-core, healthcare, SaaS, ecommerce, CRM, LMS — full domain in one command
- Seed & Factory Generators — development data and test factories
- Docker — multi-stage Dockerfile + docker-compose
- Swagger/OpenAPI — auto-generated API documentation
- Manifest —
.backgenrc.jsontracks ORM, plugins, versions, and ownership for upgrade/rollback
Quick Start
Commands
backgen init [name]
Generate a new backend project.
Output:
- Express app with TypeScript strict mode
- ORM-specific data layer (Prisma / Drizzle / Mongoose)
- Environment validation (Zod)
- Swagger/OpenAPI documentation
- Docker + docker-compose
- Hardened by default: helmet, CORS, request ID, timeout, xss + mongo-sanitize, graceful shutdown, health checks
- ESLint 9 + Vitest
.backgenrc.jsonmanifest (recordsproject.orm+ plugins)
No auth by default — choose your auth provider with backgen add.
backgen add [plugin]
Install a plugin. Interactive multi-select if no argument.
Available Plugins:
Conflict detection: jwt and clerk cannot be installed together.
Domain Presets
Generate a complete domain in one command. Each preset creates multiple resources with relations, auto-installs JWT auth, and wires everything together.
healthcare
Patient, Doctor, Appointment, Prescription, MedicalRecord — appointments between patients and doctors, prescriptions linked to patients, medical records per patient.
saas
Organization, Team, Membership, Subscription, Invoice — organizations with teams and memberships, subscriptions with invoices.
ecommerce
Category, Product, Cart, Order, OrderItem, Payment — products in categories, carts with items, orders with line items and payments.
crm
Contact, Company, Deal, Activity — companies with contacts, deals tracked through pipeline, activity logging.
lms
Course, Lesson, Enrollment, Progress, Certificate — courses with lessons, student enrollments, progress tracking, certificates.
backgen remove [plugin]
Remove a plugin. Interactive multi-select if no argument. Supports devops shorthand to remove all devops plugins.
backgen generate resource <name> [fields...]
Generate a CRUD resource module.
Generated files:
Field types: string, number, boolean, date, datetime
Relations: doctor:Doctor (belongsTo), patients:Patient (hasMany)
backgen generate seed <resource>
Generate seed data for development.
Output: prisma/seeds/product.ts (Prisma), db/seeds/product.ts (Drizzle), or seeds/product.ts (Mongoose)
backgen generate factory <resource>
Generate a test factory.
Output: src/factories/product.factory.ts
Usage:
backgen generate route [name]
Generate a custom route module with a complete controller, service, validation, types, and route file -- including Swagger annotations. Routes are automatically registered in app.ts with the REGISTER_ROUTES marker.
Use this when you need a custom endpoint that doesn't fit the CRUD pattern (e.g., dashboards, reports, webhooks, custom actions). For standard CRUD, use generate resource instead.
Generated files:
Key differences from generate resource:
- No database model, repository, or test file
- No field specification required
- Pure controller/service pattern for custom endpoints
- Mounted at
/api/<name>with full Swagger docs
backgen generate migration [name]
Generate a database migration (ORM-aware).
backgen sync
Reconcile .backgenrc.json with the project. Regenerates missing plugin files.
backgen mcp
Start BackGen as an MCP server over stdio. Used by AI assistants (Claude, Cursor, VS Code) to scaffold projects programmatically.
This is the same server exposed via the npx @ibrahimkhaled19/backgen backgen-mcp binary. It registers all 10 MCP tools listed in the AI-Ready section.
backgen health
Show system health information.
Displays:
- Node.js version
- Platform and architecture
- BackGen version
backgen doctor
Check project health with ownership integrity diagnostics.
Checks:
- Node.js version (>= 18)
- npm availability
- .env file
- DATABASE_URL
- Prisma schema / Drizzle config / Mongoose connection
- Dependencies
- Package manager version
- File integrity — all manifest-tracked files exist on disk
- Ownership integrity — framework vs user file classification
backgen upgrade
Upgrade a generated project to the latest template version. Creates a backup, then applies pending migrations sequentially.
What happens:
- Reads current
generatedVersionfrom.backgenrc.json - Loads pending core + plugin migrations
- Creates backup in
.backgen/backups/pre-<version>/ - Applies migrations in order (semver-sorted)
- Updates ownership register +
generatedVersionin manifest
backgen rollback
Restore a project to its pre-upgrade state from the most recent backup.
What happens:
- Lists available backups in
.backgen/backups/ - Restores the most recent backup (all tracked files + manifest)
- Project returns to exact pre-upgrade state
backgen rotate-secrets
Rotate JWT secrets in the project's .env file. Generates cryptographically secure 256-bit random hex values for JWT_SECRET and JWT_REFRESH_SECRET, backs up the current .env to .env.backup, and writes new values.
All existing tokens are immediately invalidated on next server restart -- users must re-login.
What happens:
- Generates two 256-bit random hex secrets via
crypto.randomBytes - Old
.envsaved to.env.backup - Previous values preserved as comments in the new
.env - Print summary of changes
Plugin System
Every plugin implements the BackGenPlugin interface:
Plugins can:
- Install npm dependencies
- Inject environment variables
- Register routes in app.ts
- Replace existing middleware
- Add database models (Prisma / Drizzle / Mongoose)
- Carry versioned migrations for own upgrades
Project Manifest
.backgenrc.json tracks plugins, versions, generated version, and file ownership:
Ownership levels:
Generated Project Structure
Development
Test Suite
277+ tests covering:
- CLI help and version
- Init: project structure, configs, manifest (all 3 ORMs)
- Init with domain presets: preset-specific resources and relations
- Init with saas-core preset: multi-tenant organizations, memberships, RBAC
- Add plugin: files, routes, env vars, manifest (V4.6 plugin suite)
- Generate resource: module files, ORM model, routes, validation
- Generate with relations: foreign keys, ORM includes
- Seed and factory generators (all 3 ORMs)
- Drizzle: schema generation, client setup, codegen
- Mongoose: model generation, schema definition, connection
- Remove plugin: file + dependency + manifest cleanup
- Sync: file restoration
- Doctor: health checks, ownership integrity
- Upgrade: migration engine, pending detection, backup creation
- Rollback: backup listing, file restoration, manifest recovery
- Error handling: unknown plugin, non-empty directory
Tech Stack
Generated Projects
BackGen vs Alternatives
Key differentiators:
- ◈ ORM-switchable — change Prisma ↔ Drizzle ↔ Mongoose via manifest, not rewrite
- ◈ Domain presets — healthcare, SaaS, ecommerce, CRM, LMS in one command
- ◈ Upgrade engine — versioned migrations + backup + rollback for generated projects
- ◈ Multi-ORM from day one — not locked into one data layer
Roadmap
See docs/ROADMAP.md for details.
License
MIT
來源:README.md,提交 51227a8
工具
0版本歷史
1- v1.14.0最新Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分