Skip to content

rida-irfan/SmartdietPlanner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Smart Diet Planner

Smart Diet Planner is a full-stack nutrition application that helps users create personalized meal plans based on profile data, dietary goals, and food preferences.

Project Overview

  • Frontend: React, Vite, Tailwind CSS, React Router, Framer Motion
  • Backend: Node.js, Express, MongoDB, Mongoose, JWT authentication
  • Features: user signup/login, profile management, diet plan generation, saved plan history, responsive UI, contact form

Key Features

  • Authentication with signup and login using JWT
  • Protected dashboard with user-specific diet recommendations
  • Profile editing for metrics like age, gender, weight, height, activity level, goal, and preference
  • Dynamic diet plan generation and plan persistence
  • Contact form endpoint for user messages
  • Modular React pages: Home, About, Contact, Guide, Login, Signup, Dashboard

Repository Structure

  • backend/ — Express API server and MongoDB integration
  • frontend/ — React client app built with Vite

Prerequisites

  • Node.js 18+ and npm
  • MongoDB running locally or accessible remotely

Installation

  1. Install backend dependencies
cd backend
npm install
  1. Install frontend dependencies
cd ../frontend
npm install

Backend Configuration

Create a .env file in the backend/ folder with the following variables:

PORT=5000
MONGO_URI=mongodb:
JWT_SECRET=your_jwt_secret
JWT_EXPIRES_IN=7d

Update MONGO_URI if you are using a hosted MongoDB instance or custom connection settings.

Running the App

Start the backend server

cd backend
npm run dev

Start the frontend app

cd frontend
npm run dev

The React app will typically run at http://localhost:5173, and the backend API will run at http://localhost:5000.

API Endpoints

Authentication

  • POST /api/auth/signup — create a new user
  • POST /api/auth/login — authenticate user and receive JWT

Dashboard

  • GET /api/dashboard/profile — fetch current user profile (authenticated)
  • PUT /api/dashboard/profile — update profile details (authenticated)
  • POST /api/dashboard/plan — generate and save a diet plan (authenticated)
  • GET /api/dashboard/plans — retrieve saved diet plans (authenticated)

Contact

  • POST /api/contact — submit contact form details

Notes for Developers

  • The backend uses bcryptjs for password hashing and jsonwebtoken for authentication.
  • User data is stored in MongoDB using a Mongoose model with nested plan records.
  • The frontend uses a protected route wrapper to guard the /dashboard page.
  • The contact endpoint currently logs messages and returns a confirmation response.

Suggested Improvements

  • Add production-ready email handling for contact submissions
  • Implement validation on both backend and frontend forms
  • Add test coverage for API routes and React components
  • Support plan editing and removal in the dashboard

About

Smart Diet Planner is an AI-powered website that generates personalized diet plans based on user preferences, health goals, age, weight and dietary requirements.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors