![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
mern-project-cli
Advanced tools
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 applicatio
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:
npm install -g mern-project-cli
To check installation version:
devcli --version
devcli 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
cd your-project-name/backend
npm run dev # Start development server with nodemon
cd your-project-name/frontend
npm start # Start React App
devcli mongodb-connect
devcli mongodb-connect --project custom-name
-p, --project <name>
: Specify custom database nameconnection.js
in the db
folderserver.js
# Using project name
devcli mongodb-connect
# Using custom database name
devcli mongodb-connect --project custom_name
// db/connection.js
require('dotenv').config();
const mongoose = require('mongoose');
const dburl = process.env.DB_URL || 'mongodb://localhost:27017/your_db_name';
mongoose
.connect(dburl)
.then(() => console.log('Connected to DB Successfully'))
.catch((err) => console.log(err.message));
devcli devcli mongoose-schema <schema-name> <fieldName:fieldType fieldName:fieldType ...>
devcli mongoose-schema User name:String email:String password:String
This will create a User.js
file with a Mongoose schema inside the models/
directory:
//models/User.js
import mongoose from 'mongoose';
const UserSchema = new mongoose.Schema({
name: { type: String, required: true },
email: { type: String, required: true },
password: { type: String, required: true },
});
const User = mongoose.model('User', UserSchema);
export 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.
devcli add-redux --init
devcli 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)devcli add-redux --slice user --actions="login,logout" --state="username:string,isLoggedIn:boolean"
This creates:
src/store/slices
When you run the command:
devcli add-redux --slice user --actions="login,logout" --state="username:string,isLoggedIn:boolean"
It generates the following slice in src/store/slices/userSlice.js
:
import { createSlice } from '@reduxjs/toolkit';
const initialState = {
username: '',
isLoggedIn: false,
};
const userSlice = createSlice({
name: 'user',
initialState,
reducers: {
login: (state, action) => {
// Implement login logic here
},
logout: (state, action) => {
// Implement logout logic here
},
},
});
export const { login, logout } = userSlice.actions;
export default userSlice.reducer;
Create a new React project with either Shadcn UI + Tailwind CSS or just Vite + Tailwind CSS using a single command.
# Create project with Shadcn UI
devcli create-frontend <project_name> --shadcn
# Create project with Vite + Tailwind CSS
devcli create-frontend <project_name> --vite
--shadcn
: Include Shadcn UI setup with Tailwind CSS--vite
: Create basic Vite project with Tailwind CSS only# Create a new React project with Shadcn UI
devcli create-frontend my-app --shadcn
# Create a new React project with just Vite + Tailwind
devcli create-frontend my-app --vite
# Navigate to project
cd my-app
# Start development server
npm 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
npx 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.
devcli 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
# Navigate to your project root
cd your-project
# Generate Docker files
devcli init-dockerfiles
# Start the containerized application
docker-compose up
This will start your application with:
http://localhost:5000
http://localhost:3000
27017
Let's create a blog application from scratch:
# Step 1: Install CLI globally
npm install -g mern-project-cli
# Step 2: Create new project
devcli create my-blog-app
# Step 3: Set up backend
cd my-blog-app/backend
npm run dev
# Step 4: Set up frontend (new terminal)
cd ../frontend
npm start
# Step 5: Connect MongoDB (optional)
cd ../backend
devcli mongodb-connect
# Step 6: Generate Mongoose Scheama (optional)
devcli mongoose-schema Blog name:String category:String
# Step 7: Set up Redux
cd ../frontend
devcli add-redux --init
# Step 8: Create blog slice for Redux
devcli add-redux --slice blog --actions="addPost,deletePost,updatePost" --state="posts:array,loading:boolean"
🎉 Congratulations! Your blog application structure is ready with:
- Backend running on `http://localhost:5000`
- Frontend running on `http://localhost:3000`
- MongoDB connected and ready to use
# Server Configuration
PORT=5000
# Database Configuration
DB_URI=mongodb://localhost:27017/your_db_name
# API Configuration
REACT_APP_API_URL=http://localhost:5000
npm install -g mern-project-cli # Install CLI globally
devcli --version # Check CLI version
devcli create <project-name> # Create new MERN project
OR [Create frontend with shadcn+tailwind/ vite+tailwind]
devcli create-frontend <project-name> --shadcn # shadcn-frontend
devcli create-frontend <project-name> --vite # vite-frontend
# Database Connection
devcli mongodb-connect # Connect MongoDB using project name
devcli mongodb-connect -p custom-name # Connect with custom database name
# Schema Generation
devcli mongoose-schema <schema-name> <fieldName:fieldType ...> # Generate Mongoose schema
# Example: devcli mongoose-schema User name:String email:String password:String
# Redux Setup
devcli add-redux --init # Initialize Redux in frontend
devcli add-redux --slice <name> --actions="action1,action2" --state="field1:type,field2:type" #Create Slice
# Example: devcli add-redux --slice user --actions="login,logout" --state="username:string,isLoggedIn:boolean"
# Docker Configuration
devcli init-dockerfiles # Generate Dockerfiles and docker-compose.yml
cd backend # Navigate to backend directory
npm install # Install dependencies
npm run dev # Start with auto-reload (development)
npm start # Start without auto-reload (production)
cd frontend # Navigate to frontend directory
npm install # Install dependencies
npm start # Start development server
docker-compose up # Start all services (backend, frontend, mongodb)
docker-compose down # Stop all services
docker-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:
FAQs
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 applicatio
The npm package mern-project-cli receives a total of 4 weekly downloads. As such, mern-project-cli popularity was classified as not popular.
We found that mern-project-cli demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.