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.
- 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
- 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
backend/— Express API server and MongoDB integrationfrontend/— React client app built with Vite
- Node.js 18+ and npm
- MongoDB running locally or accessible remotely
- Install backend dependencies
cd backend
npm install- Install frontend dependencies
cd ../frontend
npm installCreate a .env file in the backend/ folder with the following variables:
PORT=5000
MONGO_URI=mongodb:
JWT_SECRET=your_jwt_secret
JWT_EXPIRES_IN=7dUpdate
MONGO_URIif you are using a hosted MongoDB instance or custom connection settings.
cd backend
npm run devcd frontend
npm run devThe React app will typically run at http://localhost:5173, and the backend API will run at http://localhost:5000.
POST /api/auth/signup— create a new userPOST /api/auth/login— authenticate user and receive JWT
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)
POST /api/contact— submit contact form details
- The backend uses
bcryptjsfor password hashing andjsonwebtokenfor 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
/dashboardpage. - The contact endpoint currently logs messages and returns a confirmation response.
- 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