Generate Express.js backend projects with ORMs, auth, payments, and DevOps
BackGen generates Express.js backend projects with ORMs, authentication, payments, and DevOps tooling. It supports code generation, boilerplate scaffolding, and a plugin system to accelerate API development.
๐ ๏ธ Key Features
API-generator and backend-boilerplate for Express.js
ORM integration (e.g., Prisma, Mongoose) and CRUD scaffolding
Built-in authentication, payments, and DevOps tooling
CLI tool with plugin-system for extensibility
TypeScript-first backend scaffolding
SAAS boilerplate and modular architecture
Model-context-protocol compatibility for MCP-server workflows
Supports Drizzle and other modern stacks
๐ Use Cases
Rapid MVP backend creation with authentication and payments
SaaS backends with boilerplate for multi-tenant apps
Generating boilerplate APIs with secure auth and DB integration
Extensible backends via plugins and MCP-server integration
โก Developer Benefits
Consistent project structure and ready-to-run backends
Strong TypeScript typing and modern tooling
Easy extension through plugin system
Clear readme excerpts and CI-ready setup
โ ๏ธ Limitations
Specific runtime environments and dependencies depend on chosen ORM and plugins
May require customization for non-Express runtimes or non-Node.js stacks
Documentation depth inferred from readme excerpt; verify latest features in repo
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.
Generate a CRUD resource with fields, relations, validation, and Swagger
generate_seed
Generate a database seed file for a resource
generate_factory
Generate a test factory for a resource
doctor
Validate an existing BackGen project for configuration issues
list_plugins
List all available plugins with descriptions
list_presets
List all available domain presets
project_info
Show project metadata from the manifest
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.
bash
npx @ibrahimkhaled19/backgen init my-api --orm drizzle
cd my-api
npm run dev
Swagger docs at http://localhost:3000/docs in under 60 seconds. Pick your ORM, keep everything else.
GitHub Actions CI pipeline (lint, typecheck, test, build, optional deploy)
dependabot
devops
Automated dependency updates via Dependabot
codeql
devops
CodeQL security analysis on push and schedule
docker-registry
devops
Docker image build and publish to GHCR
release
devops
Semantic release with npm publish and GitHub releases
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.
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.
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.
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.
bash
backgen upgrade # show pending migrations, prompt before applying
backgen upgrade --yes# skip confirmation, apply all pending
What happens:
Reads current generatedVersion from .backgenrc.json
Loads pending core + plugin migrations
Creates backup in .backgen/backups/pre-<version>/
Applies migrations in order (semver-sorted)
Updates ownership register + generatedVersion in manifest
backgen rollback
Restore a project to its pre-upgrade state from the most recent backup.
bash
backgen rollback # show latest backup, prompt before restoring
backgen rollback --yes# skip confirmation
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.
bash
backgen rotate-secrets
What happens:
Generates two 256-bit random hex secrets via crypto.randomBytes
Old .env saved to .env.backup
Previous values preserved as comments in the new .env
Print summary of changes
Plugin System
Every plugin implements the BackGenPlugin interface:
# Clone
git clone https://github.com/your-username/backgen.git
cd backgen
# Install
npm install
# Build
npm run build
# Test
npm run test# Lint
npm run lint