This project uses the MERN (MongoDB, Express.js, React.js, Node.js) stack. Follow the steps below to set up and run the project on your local machine.
Ensure you have the following installed on your machine:
- Node.js (v14.x or later)
- npm (v6.x or later)
- MongoDB (local installation or a MongoDB Atlas account)
-
Clone the repository
git clone https://github.com/therajusah/ToDo-MERN.git cd ToDo-MERN -
Set up environment variables
Create a
.envfile in the root directory of the project and add the following environment variables. Replace<your_mongodb_connection_string>with your actual MongoDB connection string.# .env MONGO_URI=<your_mongodb_connection_string> PORT=1000
-
Install backend dependencies
npm install
-
Run the backend server
npm start
This will start the backend server on
http://localhost:1000. -
Set up the frontend
Open another terminal and navigate to the frontend directory.
cd backend/frontend npm install -
Run the frontend development server
npm start
This will start the frontend development server on
http://localhost:3000.
ToDo-MERN/
βββ backend/ # Backend code (Node.js, Express)
β βββ connection/ # MongoDB connection handling
β βββ frontend/ # Frontend code (React.js)
β β βββ public/ # Public files
β β βββ src/ # Source files
β β βββ package.json # Frontend dependencies
β β βββ ... # Other frontend files
β βββ models/ # Mongoose models
β βββ routes/ # Express routes
β βββ .env # Environment variables (create this file)
β βββ app.js # Entry point for the backend server
β βββ ... # Other backend files
βββ README.md # Project documentation
βββ ... # Other project files
- Ensure your MongoDB server is running, or you have correctly set up your MongoDB Atlas connection.
- For development purposes, the backend server runs on
http://localhost:1000and the frontend server runs onhttp://localhost:3000.
- If you happen to have issues with CORS, please make sure your backend server is configured to accept requests from your front end.
- Check that all necessary environment variables are correctly set in the
.envfile.