Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules/
.idea/
.idea/
.vercel
285 changes: 180 additions & 105 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,172 +1,247 @@
### Installation:
# Getting Started with MERN-X

To create a new project using MERN-X, simply run the following command:
```
**MERN-X** is a framework designed to simplify building full-stack applications using the MERN stack, which includes **MongoDB**, **Express.js**, **React.js**, and **Node.js**. Follow the steps below to install, run, and manage your MERN-X project easily.

## Installation

To create a new MERN-X project, open your terminal and run the following command:

```bash
npx mern-x@latest
// For yarn
```

If you prefer using **Yarn**, you can use:

```bash
yarn exec mern-x
```

How to run project
## Running Your Project

### For the Backend (Node.js)

To start the backend server, use the command:

```bash
npm run mern # This will run the backend on port 3000
```
npm run mern // Project Back End Will Run @3000
npm run dev // Complete Project Will Run @3001

// For yarn
If you're using **Yarn**, run:

```bash
yarn run mern
yarn run dev
```

How create Model
### For the Complete Project (Frontend + Backend)

To run both the frontend and backend together, use:

```bash
npm run dev # This will run the complete project on port 3001
```

For **Yarn**, use:

```bash
yarn run dev
```

## Creating Components

You can easily create various parts of your application using simple commands:

### Model: Represents your data structure.

```bash
npm run create:model YourModelName
// For yarn
yarn run create:model YourModelName
```

How create Controller
For Yarn:

```bash
yarn run create:model YourModelName
```

### Controller: Handles business logic.

```bash
npm run create:controller YourControllerName
// For yarn
yarn run create:controller YourControllerName
```

How create Middleware
For Yarn:

```bash
yarn run create:controller YourControllerName
```

### Middleware: Functions that process requests.

```bash
npm run create:middleware YourMiddlewareName
// For yarn
yarn run create:middleware YourMiddlewareName
```

How create Page
For Yarn:

```bash
yarn run create:middleware YourMiddlewareName
```

### Page: Represents a complete page in your application.

```bash
npm run create:page YourPageName
// For yarn
yarn run create:page YourPageName
```

How create Component
For Yarn:

```bash
yarn run create:page YourPageName
```

### Component: Reusable parts of your UI.

```bash
npm run create:component YourComponentName
// For yarn
yarn run create:component YourComponentName
```

How create Loader
For Yarn:

```bash
yarn run create:component YourComponentName
```

### Loader: Displays loading states in your app.

```bash
npm run create:loader YourLoaderName
// For yarn
yarn run create:loader YourLoaderName
```

How create Layout
For Yarn:

```bash
yarn run create:loader YourLoaderName
```

### Layout: Structure for your pages.

```bash
npm run create:layout YourLayoutName
// For yarn
yarn run create:layout YourLayoutName
```

For Yarn:

```bash
yarn run create:layout YourLayoutName
```

## Project Structure

Project Structure
The MERN-X project has a clear and organized folder structure that makes it easy to navigate:

```php
```
mern-x/
├── app/
│ ├── config/
│ │ ├── cli.js
│ │ ├── config.js
├── app/
│ ├── config/
│ │ ├── cli.js # Command-line interface configuration
│ │ ├── config.js # Main configuration file
│ │
│ ├── controllers
│ ├── controllers/ # Business logic for handling requests
│ │ ├── todoController.js
│ │
│ ├── middlewares
│ ├── middlewares/ # Middleware functions for processing requests
│ │ ├── authMiddleware.js
│ │
│ ├── models
│ ├── models/ # Database models for data structure
│ │ ├── todosModel.js
│ │
│ ├── storage/
│ ├── storage/ # Directory for storing files (if needed)
│ │
│ ├── utility/
│ ├── utility/ # Helper functions for various tasks
│ │ ├── emailUtility.js
│ │ ├── tokenUtility.js
│ │ ├── validationUtility.js
│ │
│ ├── dist/
│ ├── dist/ # Compiled code for distribution
│ │
│ ├── node_modules/
│ ├── node_modules/ # Installed Node.js modules
│ │
│ ├── public/
│ ├── public/ # Public assets like images and fonts
│ │
│ ├── routes/
│ ├── routes/ # API and web route definitions
│ │ ├── api.js
│ │ ├── web.jsx
│ │
│ ├── views/
│ │ ├── assets/
│ ├── views/ # React components and views
│ │ ├── assets/ # Static assets like CSS files
│ │ │ ├── css/
│ │ │ │ ├── style.js
│ │
│ │ ├── components/
│ │ │ │ ├── style.js
│ │
│ │ ├── components/ # Reusable React components
│ │ │ ├── CreateForm.jsx
│ │ │ ├── List.jsx
│ │
│ │ ├── layout/
│ │ │ ├── List.jsx
│ │
│ │ ├── layout/ # Layout components for organizing pages
│ │ │ ├── AppLayout.jsx
│ │ │
│ │
│ │ ├── loader/
│ │
│ │ ├── loader/ # Loading components for better user experience
│ │ │ ├── ListLoader.jsx
│ │
│ │ ├── pages/
│ │
│ │ ├── pages/ # Individual pages/components
│ │ │ ├── CreatePage.jsx
│ │ │ ├── ListPage.jsx
│ │
│ │ ├── main.jsx
│ │
│ │
│ ├── .gitattributes
│ ├── .gitignore
│ ├── app.js
│ ├── index.html
│ ├── LICENSE
│ ├── package.json
│ ├── package-lock.json
│ ├── postcss.config.js
│ ├── README.md
│ ├── tailwind.config.js
│ ├── vite.config.js
```


- app: This directory contains the main application code.
- config: Configuration files for the application.
- controllers: Controllers for handling business logic.
- Middleware functions for handling requests.
- models: Database models.
- storage: Directory for storing files (if applicable).
- utility: Utility functions.
- dist: Distribution files (compiled code).
- node_modules: Node.js modules installed via npm.
- public: Public assets.
- routes: Route definitions.
- views: React components and views.
- assets: Static assets like CSS files.
- components: Reusable React components.
- layout: Layout components.
- loader: Loading components.
- pages: Individual pages/components.
- .gitattributes: Git attributes file.
- .gitignore: Git ignore file.
- app.js: Entry point of the Node.js application.
- index.html: Main HTML file.
- LICENSE: License file.
- package.json: Project metadata and dependencies.
- package-lock.json: Dependency lock file.
- postcss.config.js: PostCSS configuration file.
- README.md: Project documentation.
-tailwind.config.js: Tailwind CSS configuration file.
-vite.config.js: Vite configuration file.
│ │ │ ├── ListPage.jsx
│ │
│ │ ├── main.jsx # Main entry point for React
│ │
│ ├── .gitattributes # Git attributes file
│ ├── .gitignore # Files and directories to ignore in Git
│ ├── app.js # Entry point of the Node.js application
│ ├── index.html # Main HTML file
│ ├── LICENSE # License information
│ ├── package.json # Project metadata and dependencies
│ ├── package-lock.json # Locks the versions of dependencies
│ ├── postcss.config.js # Configuration for PostCSS
│ ├── README.md # Documentation for the project
│ ├── tailwind.config.js # Configuration for Tailwind CSS
│ ├── vite.config.js # Configuration for Vite
```

## Understanding the Project Structure

- **app/**: Contains the main code for your application.
- **config/**: Holds configuration files for your project.
- **controllers/**: Contains logic for handling requests and responses.
- **middlewares/**: Functions that process incoming requests before reaching the controller.
- **models/**: Represents your data structure and database models.
- **storage/**: For storing files if needed.
- **utility/**: Helper functions for tasks like sending emails or validating data.
- **dist/**: Contains the compiled files for distribution.
- **node_modules/**: Includes all Node.js modules installed through npm.
- **public/**: Contains public assets like images and fonts.
- **routes/**: Defines the routes for your application.
- **views/**: Contains the React components and views for your application, including:
- **assets/**: Static assets like CSS files.
- **components/**: Reusable components that can be used throughout your application.
- **layout/**: Components that define the layout for your pages.
- **loader/**: Components that show loading states in your app.
- **pages/**: Individual page components for your application.
- **.gitattributes**: A file to define attributes for Git.
- **.gitignore**: Lists files and directories that Git should ignore.
- **app.js**: The entry point of your Node.js application.
- **index.html**: The main HTML file for your application.
- **LICENSE**: Contains licensing information.
- **package.json**: Metadata and dependencies for your project.
- **package-lock.json**: Locks the versions of the dependencies in your project.
- **postcss.config.js**: Configuration for PostCSS, a tool for transforming CSS.
- **README.md**: Documentation for your project.
- **tailwind.config.js**: Configuration file for Tailwind CSS.
- **vite.config.js**: Configuration file for Vite, a build tool for modern web projects.

## Additional Resources

For more information on deploying this project on a VPS server, please refer to the following README files:

- [Deployment Guide for Ubuntu VPS](/docs/deploy_mern_x_project.md)
- [Deployment Guide for Vercel](/docs/deploying-mern-x-vercel.md)
- [Deployment Guide for Railway](https://alphasec.io/how-to-deploy-a-nodejs-app-on-railway)
- [Deployment Guide for Render](https://docs.render.com/deploy-node-express-app)
Loading