mvc-faststart-express
v1.0.2
Published
A zero-dependency CLI for scaffolding production-ready MERN MVC architecture
Downloads
290
Maintainers
Readme
mern-mvc-generator
A lightweight, zero-dependency CLI tool for scaffolding professional MERN (MongoDB, Express, React, Node.js) backend APIs with a clean MVC structure.
This generator creates a ready-to-use Express.js backend featuring:
- MVC pattern (Models, Views not included — API-focused, Controllers, Services)
- Best practices: error handling, async wrappers, CORS, Helmet, etc.
- Example User model, controller, service, and route
- MongoDB connection via Mongoose
- Development mode with Nodemon
All with no external dependencies for the generator itself — pure Node.js!
Installation
Install globally to use the CLI anywhere:
npm install -g mern-mvc-generator
Or use directly with npx (no global install needed):
Bashnpx mern-mvc-generator my-api-project
Usage
Global Install
Bashmern-mvc-generator [project-name]
With npx
Bashnpx mern-mvc-generator [project-name]
If no project-name is provided, defaults to mern-api-service.
The tool will create a new directory with the project name and scaffold the backend inside it.
It automatically runs npm install for the required dependencies.
Example:
Bashmern-mvc-generator my-awesome-api
cd my-awesome-api
npm run dev
Generated Project Structure
textmy-awesome-api/
├── .env
├── package.json
└── src/
├── app.js
├── server.js
├── config/
│ └── db.js
├── controllers/
│ ├── index.js
│ └── user.controller.js
├── middlewares/
│ └── error.js
├── models/
│ ├── index.js
│ └── user.model.js
├── routes/
│ ├── index.js
│ └── user.route.js
├── services/
│ ├── index.js
│ └── user.service.js
└── utils/
├── ApiError.js
└── catchAsync.js
Key Features in the Scaffold
Centralized error handling (ApiError, converter, handler)
Async wrapper (catchAsync)
Modular routes under /v1
Example CRUD-ready User resource (currently implements GET /v1/users)
Environment-based config (.env with PORT and MONGODB_URL)
Running the Generated API
Bashcd your-project-name
npm run dev # Starts with nodemon (hot-reload)
# or
npm start # Production mode
The server will run on http://localhost:5000 (or your configured PORT).
Test the example endpoint:
textGET http://localhost:5000/v1/users
Customization
The generated project is fully yours — extend models, add more routes/controllers/services, integrate authentication (e.g., JWT), pagination, validation, etc.
Why This Generator?
Zero dependencies for the CLI itself → fast, portable, no bloat.
Uses native Node.js modules and ANSI colors.
Focuses on clean, maintainable backend structure inspired by real-world production APIs.
Perfect starting point for MERN stack backends.
Contributing
Contributions are welcome! Feel free to open issues or PRs on the repository.
License
MIT
