Gathering detailed insights and metrics for mern-project-cli
Gathering detailed insights and metrics for mern-project-cli
Gathering detailed insights and metrics for mern-project-cli
Gathering detailed insights and metrics for mern-project-cli
mern-forge-cli-tool
cli tool for our project
mern-scaffold
mern-scaffold is a CLI tool that helps you to quickly develop basic boilerplate code for your MERN app. You can generate boilerplate code for your Frontend or Backend. You can also generate them as a full stack project.
mern-init-cli
A CLI tool for creating MERN projects with biolerplate code
mern-quickstart
A CLI tool to quickly set up a MERN project
A developer-friendly CLI tool that streamlines MERN stack development by automating project setup, database configuration, and boilerplate generation by implementing MVC Architecture. Create production-ready MongoDB, Express, React, and Node.js applications with best practices built-in
npm install mern-project-cli
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
25 Stars
106 Commits
10 Forks
1 Watchers
2 Branches
5 Contributors
Updated on Jul 09, 2025
Latest Version
2.1.9
Package Id
mern-project-cli@2.1.9
Unpacked Size
4.07 MB
Size
3.93 MB
File Count
30
NPM Version
10.8.2
Node Version
20.19.1
Published on
Jun 09, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Create production-ready MERN stack projects in seconds!
MERN Project Generator CLI is a powerful tool designed to simplify the process of setting up a complete, production-ready MERN stack project in seconds.
This tool eliminates the need for manual configurations, boilerplate code copying, and repetitive tasks, allowing developers to start building their apps right away with best practices in place. Perfect for both beginners and experienced developers, it saves time and ensures a solid project foundation.
.env.example
files included with sensible defaults.gitignore
filesBefore you begin, ensure your system meets these requirements:
Install the CLI tool globally to use it from anywhere in your system:
1npm install -g mern-project-cli
To check installation version:
1devcli --version
1devcli create <your_project_name>
The generated project follows the MVC (Model-View-Controller) pattern, a battle-tested architecture that separates your application into three main components:
your-project-name/
├── backend/
│ ├── controllers/ # Handle business logicdocumentation
│ ├── db/ # Database configuration
│ ├── middlewares/ # Custom middleware functionsdocumentation
│ ├── models/ # MongoDB Schema model
│ ├── routes/ # API route definitions
│ ├── utils/ # Helper functionsdocumentation
│ ├── .env.example # Environment variables template
│ ├── .gitignore # Git ignore rules
│ ├── constants.js # Application constants
│ ├── package.json # Dependencies and scripts
│ ├── README.md # Backend documentation
│ └── server.js # Server entry point
└── frontend/
├── public/ # Static files
├── src/ # React source code
│ ├── components/ # React components
│ ├── pages/ # Page components
│ ├── utils/ # Helper functions
│ └── App.js # Root component
├── .env.example # Frontend environment template
└── package.json # Frontend dependencies
1cd your-project-name/backend
1npm run dev # Start development server with nodemon
1cd your-project-name/frontend
npm start # Start React App
Option:
To create only backend directory.
1devcli create my_backend --backend
1devcli create my_project --next
1devcli mongodb-connect
devcli mongodb-connect --project custom-name
-p, --project <name>
: Specify custom database nameconnection.js
in the db
folderserver.js
1# Using project name 2devcli mongodb-connect 3 4# Using custom database name 5devcli mongodb-connect --project custom_name
1// db/connection.js 2require('dotenv').config(); 3const mongoose = require('mongoose'); 4 5const dburl = process.env.DB_URL || 'mongodb://localhost:27017/your_db_name'; 6mongoose 7 .connect(dburl) 8 .then(() => console.log('Connected to DB Successfully')) 9 .catch((err) => console.log(err.message));
1devcli devcli mongoose-schema <schema-name> <fieldName:fieldType fieldName:fieldType ...> 2
1devcli mongoose-schema User name:String email:String password:String
This will create a User.js
file with a Mongoose schema inside the models/
directory:
1//models/User.js 2import mongoose from 'mongoose'; 3 4const UserSchema = new mongoose.Schema({ 5 name: { type: String, required: true }, 6 email: { type: String, required: true }, 7 password: { type: String, required: true }, 8}); 9 10const User = mongoose.model('User', UserSchema); 11export default User;
The mongoose-schema
command takes a model name (User) and field definitions (name:String, email:String, password:String), generating a Mongoose model file in the models/
folder.
Set up Redux in your project or add new Redux slices.
1devcli add-redux --init
1devcli add-redux --slice <sliceName> --actions="action1,action2" --state="field1:type,field2:type"
Options:
--slice
: Name of the slice to create--actions
: Comma-separated list of actions for the slice--state
: Initial state fields with types (string, boolean, array)1devcli add-redux --slice user --actions="login,logout" --state="username:string,isLoggedIn:boolean"
This creates:
src/store/slices
When you run the command:
1devcli add-redux --slice user --actions="login,logout" --state="username:string,isLoggedIn:boolean"
It generates the following slice in src/store/slices/userSlice.js
:
1import { createSlice } from '@reduxjs/toolkit'; 2 3const initialState = { 4 username: '', 5 isLoggedIn: false, 6}; 7 8const userSlice = createSlice({ 9 name: 'user', 10 initialState, 11 reducers: { 12 login: (state, action) => { 13 // Implement login logic here 14 }, 15 logout: (state, action) => { 16 // Implement logout logic here 17 }, 18 }, 19}); 20 21export const { login, logout } = userSlice.actions; 22export default userSlice.reducer;
Create a new React project with either Shadcn UI + Tailwind CSS or just Vite + Tailwind CSS using a single command.
1# Create project with Shadcn UI 2devcli create-frontend <project_name> --shadcn 3 4# Create project with Vite + Tailwind CSS 5devcli create-frontend <project_name> --vite
--shadcn
: Include Shadcn UI setup with Tailwind CSS--vite
: Create basic Vite project with Tailwind CSS only1# Create a new React project with Shadcn UI 2devcli create-frontend my-app --shadcn 3 4# Create a new React project with just Vite + Tailwind 5devcli create-frontend my-app --vite 6 7# Navigate to project 8cd my-app 9 10# Start development server 11npm run dev
your-project/
├── src/
│ ├── components/
│ │ └── ui/
│ │ └── button.jsx
│ ├── lib/
│ │ └── utils.js
│ ├── App.jsx
│ └── index.css
├── jsconfig.json
├── tailwind.config.js
├── vite.config.js
└── components.json
1npx shadcn@latest add <component-name>
tailwind.config.js
src/components
Generate Dockerfiles for both backend and frontend, along with a docker-compose.yml file for your MERN stack project.
1devcli init-dockerfiles
Creates Backend Dockerfile:
Creates Frontend Dockerfile:
Generates docker-compose.yml:
backend
and frontend
directories in rootyour-project/
├── backend/
│ ├── Dockerfile
│ └── .dockerignore
├── frontend/
│ ├── Dockerfile
│ └── .dockerignore
└── docker-compose.yml
1# Navigate to your project root 2cd your-project 3 4# Generate Docker files 5devcli init-dockerfiles 6 7# Start the containerized application 8docker-compose up
This will start your application with:
http://localhost:5000
http://localhost:3000
27017
Initialize ESLint in the specified directory (frontend, backend, or the current directory) to ensure consistent code quality with tailored configurations based on the project type.
1devcli add-eslint [directory] # Set up ESLint in the specified directory (defaults to current directory)
.eslintrc.json
file specific to the detected environment (e.g., browser for React, Node.js for backend).To set up ESLint in the backend directory:
1devcli add-eslint backend
To set up ESLint in the frontend directory:
1devcli add-eslint frontend
To set up ESLint in the current directory (default):
1devcli add-eslint
This command generates a basic ESLint configuration file (.eslintrc.json
) that looks like this:
For Backend Directory:
1{ 2 "env": { 3 "browser": false, 4 "node": true, 5 "es2021": true 6 }, 7 "extends": ["eslint:recommended", "plugin:prettier/recommended"], 8 "parserOptions": { 9 "ecmaVersion": 12 10 }, 11 "rules": {} 12}
For Frontend Directory:
1{ 2 "env": { 3 "browser": true, 4 "node": false, 5 "es2021": true 6 }, 7 "extends": [ 8 "eslint:recommended", 9 "plugin:react/recommended", 10 "plugin:prettier/recommended" 11 ], 12 "parserOptions": { 13 "ecmaVersion": 12, 14 "ecmaFeatures": { 15 "jsx": true 16 } 17 }, 18 "rules": {} 19}
For Arbitrary Folders (Defaulting to Node):
1{ 2 "env": { 3 "browser": false, 4 "node": true, 5 "es2021": true 6 }, 7 "extends": ["eslint:recommended", "plugin:prettier/recommended"], 8 "parserOptions": { 9 "ecmaVersion": 12 10 }, 11 "rules": {} 12}
Here is the content for the 8th command, "Add JWT Authentication":
Add JWT authentication boilerplate to your backend project.
1devcli add-jwt-auth
Creates Necessary Directories:
controllers/authController.js
middlewares/authMiddleware.js
models/userModel.js
routes/authRoutes.js
Generates Authentication Logic:
authController.js
- Handles user registration and login with JWT token generation.authMiddleware.js
- Implements middleware to authenticate and authorize requests using JWT tokens.userModel.js
- Defines a Mongoose schema for the User model.authRoutes.js
- Defines API routes for authentication, including register, login, and a protected route.Installs Required Dependencies:
bcryptjs
- For password hashingjsonwebtoken
- For generating and verifying JWT tokensIntegrates Authentication Routes:
server.js
file.Provides Next Steps:
.env
file with a secure JWT_SECRET
.POST /api/auth/register
: Register a new userPOST /api/auth/login
: Log in and get the JWT tokenGET /api/auth/protected
: Access the protected route with the JWT tokenRun the command in your project's backend
directory:
1devcli add-jwt-auth
Update the .env
file in the backend
directory with a secure JWT_SECRET
.
Start the server and test the authentication routes.
backend/
├── controllers/
│ └── authController.js
├── middlewares/
│ └── authMiddleware.js
├── models/
│ └── userModel.js
├── routes/
│ └── authRoutes.js
The generated files implement the following functionality:
After running this command, you can start using the authentication system in your backend application.
Deploy your frontend application to Vercel with a single command. This feature supports production deployments, preview deployments, custom domains, and automatic environment variable handling.
Deploy your frontend application to Vercel with a single command using the devcli
tool. This feature supports production deployments, preview deployments, custom domains, and automatic environment variable handling.
1devcli deploy --vercel [options]
Option | Description |
---|---|
--vercel | Deploy the frontend to Vercel |
--preview | Deploy a preview version (not production) |
--domain <domain> | Specify a custom domain for deployment (e.g., myapp.com ) |
.env
files automatically1devcli deploy --vercel
Expected Output:
🚀 Deploying frontend to Vercel...
📦 Uploading environment variables...
✅ Frontend deployed successfully!
🎉 Your frontend has been deployed to Vercel!
👉 Open the deployed URL: https://myapp.vercel.app
1devcli deploy --vercel --preview
Expected Output:
🚀 Deploying frontend to Vercel (preview)...
📦 Uploading environment variables...
✅ Frontend deployed successfully!
🎉 Your frontend has been deployed to Vercel!
👉 Open the preview URL: https://myapp-git-branch.vercel.app
1devcli deploy --vercel --domain myapp.com
Expected Output:
🚀 Deploying frontend to Vercel with custom domain...
📦 Uploading environment variables...
✅ Frontend deployed successfully!
🎉 Your frontend has been deployed to Vercel!
👉 Open the deployed URL: https://myapp.com
Install the Vercel CLI globally:
1npm install -g vercel
Log in to Vercel:
1vercel login
❌ This does not seem to be a valid frontend app. Make sure you are in the root of your frontend project.
❌ Vercel CLI is not installed. Please install it using `npm install -g vercel`.
🔑 You are not logged in to Vercel. Please log in to continue.
package.json
For additional help, consult the Vercel documentation or contact your development team's support channels.
Let's create a blog application from scratch:
1# Step 1: Install CLI globally 2npm install -g mern-project-cli 3 4# Step 2: Create new project 5devcli create my-blog-app 6 7# Step 3: Set up backend 8cd my-blog-app/backend 9npm run dev 10 11# Step 4: Set up frontend (new terminal) 12cd ../frontend 13npm start 14 15# Step 5: Connect MongoDB (optional) 16cd ../backend 17devcli mongodb-connect 18 19# Step 6: Generate Mongoose Scheama (optional) 20devcli mongoose-schema Blog name:String category:String 21 22 23# Step 7: Set up Redux 24cd ../frontend 25devcli add-redux --init 26 27# Step 8: Set up Es-lint and prettierrc 28cd ../backend 29devcli add-eslint 30 31cd ../frontend 32devcli add-eslint 33# Step 9: Create blog slice for Redux 34devcli add-redux --slice blog --actions="addPost,deletePost,updatePost" --state="posts:array,loading:boolean" 35 36# Step 10: Add jwt authetication 37cd ..backend 38devcli add-jwt-auth 39 40🎉 Congratulations! Your blog application structure is ready with: 41- Backend running on `http://localhost:5000` 42- Frontend running on `http://localhost:3000` 43- MongoDB connected and ready to use
1# Server Configuration 2PORT=5000 3 4# Database Configuration 5DB_URI=mongodb://localhost:27017/your_db_name
1# API Configuration 2REACT_APP_API_URL=http://localhost:5000 3
1npm install -g mern-project-cli # Install CLI globally 2devcli --version # Check CLI version 3devcli create <project-name> # Create new MERN project
1OR [Create frontend with shadcn+tailwind/ vite+tailwind] 2 3devcli create-frontend <project-name> --shadcn # shadcn-frontend 4devcli create-frontend <project-name> --vite # vite-frontend
1# Database Connection 2devcli mongodb-connect # Connect MongoDB using project name 3devcli mongodb-connect -p custom-name # Connect with custom database name 4 5# Schema Generation 6devcli mongoose-schema <schema-name> <fieldName:fieldType ...> # Generate Mongoose schema 7# Example: devcli mongoose-schema User name:String email:String password:String
1# Redux Setup 2devcli add-redux --init # Initialize Redux in frontend 3devcli add-redux --slice <name> --actions="action1,action2" --state="field1:type,field2:type" #Create Slice 4# Example: devcli add-redux --slice user --actions="login,logout" --state="username:string,isLoggedIn:boolean"
1# Docker Configuration 2devcli init-dockerfiles # Generate Dockerfiles and docker-compose.yml
1cd backend # Navigate to backend directory 2npm install # Install dependencies 3npm run dev # Start with auto-reload (development) 4npm start # Start without auto-reload (production)
1cd frontend # Navigate to frontend directory 2npm install # Install dependencies 3npm start # Start development server
1docker-compose up # Start all services (backend, frontend, mongodb) 2docker-compose down # Stop all services 3docker-compose up --build # Rebuild and start all services
We welcome and appreciate contributions to MERN Project Generator CLI! If you’d like to help improve this tool, feel free to do so.
This project is licensed under the MIT License - see the LICENSE file for details.
If you find this tool helpful, please consider:
No vulnerabilities found.
No security vulnerabilities found.