MERN CRUD is a full-stack web application built using the MERN (MongoDB, Express.js, React.js, Node.js) stack, following the MVC (Model-View-Controller) architectural pattern. It provides a comprehensive solution for performing CRUD (Create, Read, Update, Delete) operations on users.
- Create: Users can create new user having a "name", "email", & "age".
- Read: Users can retrieve all users from the database.
- Update: Users can update existing "name", "email", & "age" information of any specific _id.
- Delete: Users can delete the entire data of any specific _id from the database.
-
Clone the repository:
$ git clone [repository URL] $ cd [project directory]
-
Install backend dependencies:
$ cd backend $ npm install
-
Install frontend dependencies:
$ cd ../frontend $ npm install
-
Set up environment variables:
- Create a
.env
file in thebackend
directory. - Specify the following variables in the
.env
file:MONGO_URI
: MongoDB connection stringPORT
: Port number for the server (e.g., 5000)
- Create a
-
Start the backend server:
$ cd ../backend $ npm run dev
-
Start the frontend development server:
$ cd ../frontend $ npm start
-
Open your browser and navigate to
http://localhost:3000
to access the application.
-
Create: To create a new user, navigate to the user creation form. Enter the following details:
- Name: [User's name]
- Email: [User's email]
- Age: [User's age]
- Submit the form.
- A new user will be created with the provided information.
-
Read:
- To retrieve all users, navigate to the user list page.
- All users will be displayed with their respective information.
-
Update:
- To update user information, navigate to the user list page.
- Click on the edit button for the user whose information you want to update.
- Modify the user's details (name, email, age) as required.
- Save the changes.
- The user's information will be updated with the new values.
-
Delete:
- To delete a user, navigate to the user list page.
- Click on the delete button for the user you want to delete.
- The user will be permanently removed from the system.
The project source code is divided into two main parts: the frontend and the backend.
The frontend, located in the frontend
directory, consists of the view components responsible for the user interface and interactions. It is built using React.js and utilizes the Bootstrap framework for responsive and visually appealing UI components. The frontend communicates with the backend API to perform CRUD operations and display data to the user.
The backend, located in the backend
directory, consists of the server, models, and controllers. It handles incoming requests from the frontend, interacts with the database, and performs the necessary operations. The backend is built using Node.js, Express.js, and MongoDB. The models define the structure and behavior of the [data type] entities, while the controllers handle the business logic and process the requests.
GET /api/user/userlist
: To retrieve all usersPOST /api/user/createuser
: To create new userPATCH /api/user/updateuser/:id
: To update userDELETE /api/user/deleteuser/:id
: To delete user