This repository contains the source code for the Fit & Fun web application, a fitness and diet planner built with the MERN stack. The app features user authentication, a workout planner, a diet planner, and email functionality for password reset.
Before you begin, make sure you have the following software installed on your machine:
- Node.js (v14 or above)
- npm (comes with Node.js)
- MongoDB (either locally or using a cloud service like MongoDB Atlas)
-
Navigate to the
client
directory:cd client
-
Install the required dependencies:
npm install
-
Create a
.env
file in theclient
directory with the necessary environment variables (if any). -
Build the client application:
npm run build
-
Start the client development server:
npm start
-
Navigate to the
server
directory:cd server
-
Install the required dependencies:
npm install
-
Set up the environment variables as described in the next section.
-
Start the server:
npm start
-
In the
server
directory, create a.env
file if it doesn't already exist. -
Add your MongoDB connection string to the
.env
file:MONGODB_URL=mongodb://<username>:<password>@<host>:<port>/<database>
Replace
<username>
,<password>
,<host>
,<port>
, and<database>
with your MongoDB credentials and details.
-
Open the
server/routes/email.js
file. -
Update the Nodemailer configuration with your email credentials:
const transporter = nodemailer.createTransport({ service: 'gmail', auth: { user: process.env.EMAIL, // your email address pass: process.env.PASSWORD, // your app password if using 2FA, otherwise your email password }, });
-
Add the email credentials to your
.env
file in theserver
directory:EMAIL=your-email@example.com PASSWORD=your-email-password
If you are using Two-Factor Authentication (2FA), make sure to generate an app-specific password from your Google account settings and use it here.
Here is a sample mail, how this works
-
Ensure that both the client and server are set up and running.
-
Open your browser and navigate to
http://localhost:3000
to access the application. -
Use the application features including user authentication, workout planning, diet planning, and password reset functionality.
-
The server will run on
http://localhost:4000
by default.