Skip to content

A CLI to scaffold Node.js microservices with MVC or Clean Architecture

Notifications You must be signed in to change notification settings

paudang/nodejs-quickstart-structure

Repository files navigation

Node.js Quickstart Generator

A powerful CLI tool to scaffold production-ready Node.js microservices with built-in best practices, allowing you to choose between MVC or Clean Architecture, JavaScript or TypeScript, and your preferred database.

Medium Article

Demo

Features

  • Interactive CLI: Easy-to-use prompts to configure your project.
  • Multiple Architectures: Supports both MVC (Model-View-Controller) and Clean Architecture.
  • Language Support: Choose between JavaScript and TypeScript.
  • Database Integration: Pre-configured setup for MySQL, PostgreSQL, or MongoDB.
  • Microservices Ready: Optional Kafka integration for event-driven communication.
  • Caching Layer: Optional Redis integration for high-performance data caching.
  • Dockerized: Automatically generates docker-compose.yml for DB, Kafka, Redis, and Zookeeper.
  • Database Migrations/Schemas: Integrated Flyway for SQL migrations or Mongoose schemas for MongoDB.
  • Professional Standards: Generated projects come with highly professional, industry-standard tooling.

🏆 Professional Standards (New)

We don't just generate boilerplate; we generate production-ready foundations. Every project includes:

  • 🔍 Code Quality: Pre-configured Eslint and Prettier for consistent coding standards.
  • 🛡️ Security: Built-in Helmet, HPP, CORS, and Rate-Limiting middleware.
  • 🧪 Testing Strategy: Integrated Jest and Supertest setup for Unit and Integration testing.
  • 🔄 CI/CD Support: Choice between GitHub Actions and Jenkins.
  • ⚓ Git Hooks: Husky and Lint-Staged to ensure no bad code is ever committed.
  • 🐳 DevOps: Highly optimized Multi-Stage Dockerfile for small, secure production images.

🧩 112+ Project Combinations

The CLI supports a massive number of configurations to fit your exact needs:

  • 112 Core Combinations:
    • MVC Architecture: 84 variants (Languages × View Engines × Databases × Communication Patterns × Caching)
    • Clean Architecture: 28 variants (Languages × Databases × Communication Patterns × Caching)
  • 224 Total Scenarios:
    • Every combination can be generated with or without GitHub Actions CI/CD, doubling the possibilities.

For a detailed list of all supported cases, check out docs/generateCase.md.

Installation

You can install the tool globally directly from npm:

npm install -g nodejs-quickstart-structure

Usage

Once installed, simply run the following command in any directory where you want to create a new project:

nodejs-quickstart init

Configuration Options

The CLI will guide you through the following steps:

  1. Project Name: The name of the folder to create.
  2. Language: JavaScript or TypeScript.
  3. Architecture: MVC or Clean Architecture.
  4. Database: MySQL, PostgreSQL, or MongoDB.
  5. Database Name: The name of the initial database.
  6. Communication: REST APIs (default) or Kafka.
  7. Caching: Redis or None.
  8. CI/CD: GitHub Actions, Jenkins, or None.

Generated Project Structure

The generated project will include:

  • src/: Source code (controllers, routes, services/use-cases).
  • flyway/sql/: SQL migration scripts (if SQL database selected).
  • docker-compose.yml: Services configuration for DB, Flyway, and Kafka.
  • package.json: Dependencies and scripts (start, dev, build).
  • tsconfig.json: (If TypeScript is selected) Type checking configuration.

Getting Started with the Generated App

cd <your-project-name>

# Start infrastructure (DB, etc.)
npm install

docker-compose up

License

ISC

About

A CLI to scaffold Node.js microservices with MVC or Clean Architecture

Resources

Stars

Watchers

Forks

Packages

No packages published