Open Source CLI Tool

Production APIs
in seconds

Generate a fully scaffolded, production-ready Node.js backend. Choose your language, architecture, and features. Ship immediately.

View on GitHub

Downloads (30d)

Loading...

Total Downloads

Loading...

View on npm

Why Backend Template?

Everything you need to ship faster, built the right way from the start.

⚑

Save Hours

Start with production code, not boilerplate. Focus on business logic.

βœ“

Best Practices

Built by experienced developers. Error handling, logging, security included.

πŸ“ˆ

Scalable

Monolith or microservices. Grow from MVP to production without rebuilding.

Built for Developers

Every feature is designed to remove friction and let you focus on what matters.

Language Choice

TypeScript (default) or JavaScript templates

Authentication

JWT + MongoDB when enabled; off means zero DB wiring

Zero Config CLI

Args support mono/micro; prompts only what is needed

Microservices Ready

Gateway + health service; Docker or PM2 deployment

Request Validation

Optional Zod schemas to validate and secure input payloads

Add Services Later

Re-run CLI; gateway and routes update automatically

Interactive API Docs

Auto-generated interactive Swagger UI (/api-docs) out of the box

Team Workflows

Auto-generates GitHub actions, PR templates, and CONTRIBUTING.md

How it Works

Guided, production-ready scaffolding

The CLI asks only what it needs, generates just what you chose, and keeps docs in sync with your options. No bloat, no unused dependencies.

1) Start the CLI

Zero-config

Run the initializer without installing it globally. Optionally pass architecture overrides.

# Run interactive setup

npx @ifecodes/backend-template@latest my-project

# Or pre-select architecture

npx @ifecodes/backend-template@latest my-project mono

npx @ifecodes/backend-template@latest my-project micro

2) Interactive Setup

Project name

From command args or dynamic prompt; skipped when adding a service inside /services.

Language

TypeScript (default) or JavaScript code templates.

Metadata (optional)

Description, author, keywords β†’ auto-configured in package.json & README.

Project Scope

Team or Individual. Team projects generate CI/CD workflows, PR templates, and CONTRIBUTING.md. Individual keeps it minimal.

Architecture

Monolith or Microservice (can be pre-selected via mono/micro args).

Mode (micro only)

Docker (compose + Dockerfiles) or PM2 (process-managed deployments).

Features

CORS, Rate Limiting, Helmet, Morgan (multiselect with zero dependencies if skipped).

Authentication

Toggle JWT + MongoDB; secure password hashing setup follows.

Request validation

Toggle request validation with Zod schemas to validate input payloads dynamically.

Adding a service?

If a /services folder exists, automatically runs in add-service mode to extend the gateway config.

3) Architecture Specifics

Monolith Layout

  • β€’ Single Express instance with modular versioning
  • β€’ Clean controllers, middlewares, routes structure
  • β€’ Zero dependency overhead for skipped features

Microservices Layout

  • β€’ API Gateway + Health service included automatically
  • β€’ Docker containers or PM2 process definitions
  • β€’ Shared configuration and common utils modules

4) Smart Outputs

  • β€’README.md is updated on-the-fly to document the specific selections you made.
  • β€’Workspace configs detect existing monorepos and dynamically wire routes.
  • β€’Environment variables are verified at launch to prevent server startups without keys.
  • β€’Swagger UI /api-docs is automatically configured and served with auto-generated OpenAPI documentation.

Summary Matrix

All features map to optimized, isolated code paths without global pollution.

JavaScript

Pure JS output, no TS compilation layer

TypeScript

Full type safety, types, and compiler configs

Monolith

Standard single Express application

Microservice

API Gateway + distributed services

Auth OFF

No database wiring, clean scaffolding

Auth ON

JWT validation, MongoDB connection setup

bcrypt

Windows-friendly password hashing

argon2

High-performance hashing for Unix/macOS

Docker

Container orchestration via docker-compose

PM2

Multi-process PM2 config setups

Zod ON

Automatic request schemas & validate middlewares

Zod OFF

Traditional manual route handler validation

Docs

Everything you need to know to install, configure, and scale your backend workspace.

Quick Anchors

Install

Initialize your codebase directly with npx. No global installation required.

npx @ifecodes/backend-template@latest my-project

CLI Shortcuts

Skip prompts by predefining your architecture in the arguments:

# Predefine as monolith project

npx @ifecodes/backend-template@latest my-project mono

# Predefine as microservice project

npx @ifecodes/backend-template@latest my-project micro

Full Documentation

Read the comprehensive documentation containing detailed descriptions of interactive prompts, generated project structure, database wiring guides, and environment setups.

Requirements

  • β€’Supports all major environments: macOS, Linux, and Windows.
  • β€’MongoDB is only required if you choose to enable the optional JWT Authentication layer.
  • β€’Docker is only required for local service orchestration in Microservice Docker mode.

Examples

Compare generated workspace structures. Only the configurations you select are generated.

Microservices (No Auth)

Workspace
my-workspace/
β”œβ”€β”€ services/
β”‚   β”œβ”€β”€ gateway/         # Reverse proxy / Router (Port 4000)
β”‚   └── health-service/  # Endpoint status checks (Port 4001)
β”œβ”€β”€ shared/
β”‚   β”œβ”€β”€ config/          # Common env variable mappings
β”‚   └── utils/           # Shared logger & error middleware
β”œβ”€β”€ package.json         # Workspace scripts
β”œβ”€β”€ README.md
└── .env.example

Architecture Notes:

  • Docker mode appends docker-compose.yml and service Dockerfiles.
  • PM2 mode configures a top-level pm2.config.js file instead of containers.
  • If Auth is enabled, a dedicated auth-service/ (Port 4002) is scaffolded.

Microservice Docker Mode

Containers
my-workspace/
β”œβ”€β”€ services/
β”‚   β”œβ”€β”€ gateway/
β”‚   β”‚   └── Dockerfile
β”‚   └── health-service/
β”‚       └── Dockerfile
β”œβ”€β”€ docker-compose.yml   # Multi-service run config
β”œβ”€β”€ package.json
└── README.md

Microservice PM2 Mode

Process Managed
my-workspace/
β”œβ”€β”€ services/
β”‚   β”œβ”€β”€ gateway/
β”‚   └── health-service/
β”œβ”€β”€ pm2.config.js        # Core PM2 run configurations
β”œβ”€β”€ package.json
└── README.md

Monolith Layout (No Auth)

Single Repo
my-monolith-app/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ config/          # Configurations and key validation
β”‚   β”œβ”€β”€ middlewares/    # Custom Express filters (CORS, Rate Limiting, etc.)
β”‚   β”œβ”€β”€ modules/
β”‚   β”‚   └── v1/
β”‚   β”‚       └── health/  # API endpoints for health status checking
β”‚   β”œβ”€β”€ utils/           # Global logger wrapper
β”‚   β”œβ”€β”€ app.ts           # Central Express app declarations
β”‚   β”œβ”€β”€ routes.ts        # Central Routing mapping file
β”‚   └── server.ts        # Listening port initialization
β”œβ”€β”€ package.json
└── README.md

Architecture Notes:

  • Enabling authentication adds src/models/ and src/modules/v1/auth/ folder structures.
  • Development dependencies like Prettier, ESLint, and Husky are loaded in the repository root.
  • Zod request schemas are integrated directly next to the module endpoints under modules/v1/[feature]/schemas/.

FAQ

Answers to common questions regarding CLI options, setups, and architecture choices.

How does this generator differ from other Express generators?
Unlike minimal CLI generators that copy static boilerplates, Backend Template runs an interactive, parameter-aware compilation flow. It customizes the codebase on-the-fly, installing only selected dependencies, generating language-appropriate structures, configuring specific hashes, and dynamically documenting everything in the generated project README.
What Node.js version do I need?
We recommend using a modern LTS Node.js version (e.g. Node 18 or 20+). Upgrading Node first resolves almost all package-installation or runtime compiler compatibility issues.
Do I need MongoDB installed?
Only if you opt to enable JWT Authentication during CLI setup. If authentication is toggled off, no database scripts, database configuration, or dependency packages are added to keep the template lean.
Does the generator support request payload validation?
Yes. You can opt to include request validation via Zod schemas. If enabled, Zod schema definitions and request-validation middlewares are generated next to feature modules and automatically mapped into Express route handlers.
Docker vs PM2 β€” when should I choose each?
Choose Docker mode if your deployment environment is containerized. It scaffolds a root docker-compose configuration alongside service Dockerfiles for multi-service coordination. Choose PM2 mode for standard process managers (e.g., bare VM) to set up PM2 ecosystems without containers.
How does β€œadd service” work in microservices mode?
When you run the template command within an existing microservice directory (which contains a /services directory), the CLI skips metadata configuration. Instead, it enters 'add-service' mode, prompts for service-specific options, creates the service directory, and automatically rewires the API Gateway proxy routing mapping.
Does the generator set up API documentation?
Yes. Every generated project automatically integrates Swagger UI to document your API endpoints. Once you start the server, you can view and test your endpoints interactively by visiting /api-docs in your browser.
Can I generate JavaScript code instead of TypeScript?
Yes. Although TypeScript is selected by default, you can toggle language choices to generate clean JavaScript templates. The output will exclude all TS compiler files and typings.
What middleware/features can I configure during setup?
You can multiselect common middleware libraries: CORS (Cross-Origin Resource Sharing), Helmet (HTTP security headers), Rate Limiter (API rate limits), and Morgan (request logging). Skipped options are fully omitted from code and configuration.

Need help?

Have questions, issues, or want to contribute? Connect with us below.

Choose Your Path

Modern Stack

Node.js
Express.js
TypeScript
JavaScript
MongoDB
JWT
Zod
Docker
PM2
Helmet
CORS
Rate Limiting
Morgan
Swagger UI

Ready to Build?

Open source, free, and made for developers by developers.

Star on GitHub