This project is a full-stack web application built with React, Node.js, Express, and MongoDB. It allows you to register users and displays a list of registered users.
Before you can run this project, make sure you have the following software installed on your machine:
- Node.js
- Clone the repository to your local machine:
- Change into
backend
directory and install the dependencies for the server:
- cd backend
- npm install
- Change into the
frontend
directory and install the dependencies for the client:
- cd ..
- cd frontend
- npm install
-
Create a
.env
file in the root directory of the project. -
In the
.env
file, add the following environment variables:
mongoURL=mongodb+srv://ashish:ashishpal@cluster0.2ahhjtl.mongodb.net/merndb?retryWrites=true&w=majority port=4000
- Start the backend server by changing into
backend
directory:
- npm run server
The server will run on http://localhost:4000.
- In a new terminal, change into the
frontend
directory and start the client server:
- npm start
The client will run on http://localhost:3000 and open automatically in your browser.
- Access the application by visiting http://localhost:3000 in your browser.
- The server API endpoints are accessible at http://localhost:4000/api.
- POST /users/register: Register a new user. Requires the following JSON payload:
{
"name": "Ashish Pal",
"email": "ashish@example.com",
"password": "password"
}
- GET /users: Get all users
[
{
"_id": "1"
"name": "John Doe",
"email": "john@example.com",
"password": "password"
}
]