Production level folder structure for a mern stack app in one command

arshan_nawaz

Arshan Nawaz

Posted on August 17, 2024

Production level folder structure for a mern stack app in one command

*1. Client *

# Create folders
mkdir -p src/validations
mkdir -p src/components
mkdir -p src/utils
mkdir -p src/layouts src/routes src/pages/client/home src/pages/client/about src/pages/dashboard/home src/pages/dashboard/settings
mkdir -p src/redux/features/permission
mkdir -p src/redux/features/role
mkdir -p src/redux/features/loading
mkdir -p src/redux/features/auth
mkdir -p src/redux/middlewares
mkdir -p src/redux/actions

# Create files with path comments
echo "// src/validations/user.validation.js" > src/validations/user.validation.js

echo "// src/utils/formatDate.js" > src/utils/formatDate.js
echo "// src/utils/api.js" > src/utils/api.js
echo "// src/utils/EndPoints.js" > src/utils/EndPoints.js

echo "// src/layouts/ClientLayout.jsx" > src/layouts/ClientLayout.jsx
echo "// src/layouts/DashboardLayout.jsx" > src/layouts/DashboardLayout.jsx
echo "// src/routes/ClientRoutes.jsx" > src/routes/ClientRoutes.jsx
echo "// src/routes/DashboardRoutes.jsx" > src/routes/DashboardRoutes.jsx
echo "// src/routes/AppRouter.jsx" > src/routes/AppRouter.jsx

echo "// src/components/Button/Button.jsx" > src/components/Button/Button.jsx
echo "// src/pages/client/home/Home.jsx" > src/pages/client/home/Home.jsx
echo "// src/pages/client/about/About.jsx" > src/pages/client/about/About.jsx
echo "// src/pages/dashboard/home/DashboardHome.jsx" > src/pages/dashboard/home/DashboardHome.jsx
echo "// src/pages/dashboard/settings/Settings.jsx" > src/pages/dashboard/settings/Settings.jsx


echo "// src/redux/features/permission/permission.slice.js" > src/redux/features/permission/permission.slice.js
echo "// src/redux/features/role/role.slice.js" > src/redux/features/role/role.slice.js
echo "// src/redux/features/loading/loading.slice.js" > src/redux/features/loading/loading.slice.js
echo "// src/redux/features/permission/permission.service.js" > src/redux/features/permission/permission.service.js
echo "// src/redux/features/role/role.service.js" > src/redux/features/role/role.service.js
echo "// src/redux/features/auth/auth.slice.js" > src/redux/features/auth/auth.slice.js
echo "// src/redux/features/auth/auth.service.js" > src/redux/features/auth/auth.service.js
echo "// src/redux/store.js" > src/redux/store.js
echo "// src/redux/rootReducer.js" > src/redux/rootReducer.js
echo "// src/redux/actions/actionTypes.js" > src/redux/actions/actionTypes.js
echo "// src/redux/middlewares/loading.middleware.js" > src/redux/middlewares/loading.middleware.js

Enter fullscreen mode Exit fullscreen mode

2. Server

# Create the main source folders
mkdir -p src/controllers
mkdir -p src/middlewares
mkdir -p src/models
mkdir -p src/routes
mkdir -p src/utils
mkdir -p src/config
mkdir -p src/validations
mkdir -p src/constants


# Create the public folder and profile folder
mkdir -p public/profile

# Create files with path comments in src/controllers
echo "// src/controllers/auth.controller.js: Controller for authentication-related routes" > src/controllers/auth.controller.js

# Create files with path comments in src/middlewares
echo "// src/middlewares/auth.middleware.js: Middleware for authentication" > src/middlewares/auth.middleware.js

# Create files with path comments in src/models
echo "// src/models/auth.model.js: Mongoose schema for authentication" > src/models/auth.model.js

# Create files with path comments in src/routes
echo "// src/routes/auth.route.js: Routes for authentication-related endpoints" > src/routes/auth.route.js

# Create files with path comments in src/utils
echo "// src/utils/example.util.js: Example utility function" > src/utils/example.util.js

# Create files with path comments in src/config
echo "// src/config/db.config.js: Configuration for database connection" > src/config/db.config.js
echo "// src/config/env.config.js: Configuration for environment variables" > src/config/env.config.js

# Create files with path comments in src/validations
echo "// src/validations/user.validation.js: Schema for user model" > src/validations/user.validation.js


# Create an example file in src/constants
echo "// src/constants/example.constants.js: Example constants file" > src/constants/example.constants.js

Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
arshan_nawaz
Arshan Nawaz

Posted on August 17, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related