cookbook/
βββ README.md
βββ backend/
β βββ .env β DB URI, JWT secret, port
β βββ package.json
β βββ server.js β Entry point
β βββ config/
β β βββ db.js
β βββ controllers/
β β βββ auth.controller.js β register, login, getMe
β β βββ recipe.controller.js β CRUD + search + pagination
β β βββ favorite.controller.js β save/unsave/list
β β βββ user.controller.js β profile, change password
β βββ middleware/
β β βββ auth.middleware.js β JWT protect middleware
β βββ models/
β β βββ User.js
β β βββ Recipe.js
β β βββ Favorite.js
β βββ routes/
β βββ auth.routes.js
β βββ recipe.routes.js
β βββ favorite.routes.js
β βββ user.routes.js
β
βββ frontend/
βββ index.html
βββ package.json
βββ vite.config.js
βββ tailwind.config.js
βββ postcss.config.js
βββ src/
βββ main.jsx
βββ App.jsx
βββ index.css
βββ context/
β βββ AuthContext.jsx β Global login state
βββ services/
β βββ api.js β Axios instance with JWT
β βββ recipeService.js β All API calls
βββ routes/
β βββ PrivateRoute.jsx β Protects auth-only pages
βββ components/
β βββ Navbar.jsx
β βββ RecipeCard.jsx
β βββ RecipeForm.jsx β Shared by Create + Edit
β βββ SearchBar.jsx
β βββ Spinner.jsx
βββ pages/
βββ Home.jsx β Search, filter, browse
βββ Login.jsx
βββ Register.jsx
βββ RecipeDetail.jsx β Full recipe + ingredient checklist
βββ CreateRecipe.jsx
βββ EditRecipe.jsx
βββ Favorites.jsx
βββ MyRecipes.jsx
βββ Profile.jsx β Edit profile + change password
βββ NotFound.jsx
- Go to https://nodejs.org
- Download the LTS version (green button)
- Install it (click Next through the installer)
- Open a terminal and verify:
node -v
npm -v
You should see version numbers. If you do, move on.
Option A β Local MongoDB (Recommended for development)
- Go to https://www.mongodb.com/try/download/community
- Select: Version = current, Platform = Windows/Mac, Package = MSI
- Download and install (use "Complete" setup)
- During install, check "Install MongoDB as a Service" β this means it starts automatically
- Also install MongoDB Compass when prompted (it's the GUI, very useful)
To verify MongoDB is running, open terminal and type:
mongosh
If you see a > prompt, MongoDB is running. Type exit to quit.
Option B β MongoDB Atlas (Cloud, no install needed)
- Go to https://www.mongodb.com/atlas
- Create a free account
- Create a free cluster (M0 Sandbox β free forever)
- Click "Connect" β "Drivers" β copy the connection string
- It looks like:
mongodb+srv://username:password@cluster0.xxxxx.mongodb.net/ - Replace the MONGO_URI in your .env with this string + add
cookbookat the end:mongodb+srv://username:password@cluster0.xxxxx.mongodb.net/cookbook
- Go to https://code.visualstudio.com
- Download and install
- Recommended extensions to install inside VS Code:
- ES7+ React/Redux/React-Native snippets
- Tailwind CSS IntelliSense
- Prettier - Code formatter
- Thunder Client (for API testing, alternative to Postman)
Take the cookbook folder you downloaded and place it somewhere clean, for example:
C:\Users\YourName\Projects\cookbook (Windows)
/Users/YourName/Projects/cookbook (Mac)
Open VS Code β File β Open Folder β select the cookbook folder.
You should see both backend/ and frontend/ folders in the sidebar.
Open the integrated terminal in VS Code: press Ctrl + ` (backtick) or go to Terminal β New Terminal.
cd backend
npm installThis installs: express, mongoose, jsonwebtoken, bcryptjs, cors, dotenv, nodemon, express-validator.
Wait for it to finish. You'll see a node_modules folder appear inside backend/.
Edit the .env file (open backend/.env):
PORT=5000
MONGO_URI=mongodb://localhost:27017/cookbook
JWT_SECRET=mySuperSecretKey2024CookBook
JWT_EXPIRES_IN=7d
NODE_ENV=development
- If using local MongoDB: keep MONGO_URI as is
- If using Atlas: replace MONGO_URI with your Atlas connection string
- Change JWT_SECRET to any long random string (keep it secret)
Open a second terminal in VS Code (click the + icon in the terminal panel):
cd frontend
npm installThis installs: react, react-dom, react-router-dom, axios, react-icons, react-toastify, tailwindcss, vite, etc.
Wait for it to finish.
You need two terminals running at the same time.
cd backend
npm run devYou should see:
β
MongoDB connected
π Server running on port 5000
If you see an error about MongoDB connection, make sure MongoDB service is running (see Step 2).
cd frontend
npm run devYou should see:
VITE v5.x.x ready in xxx ms
β Local: http://localhost:5173/
Open your browser and go to:
http://localhost:5173
You'll see the CookBook homepage with a search bar and recipe cards.
- Click "Get Started" in the navbar
- Fill in name, email, password (min 6 chars)
- You'll be redirected to the home page, logged in
- Click "+ New Recipe" in the navbar
- Fill in all fields β title, cuisine, cooking time, ingredients, steps
- Click "Publish Recipe"
- You'll be redirected to the recipe detail page
- Browse the home page
- Click the heart icon on any recipe card OR open a recipe and click "Save Recipe"
- Click "Saved" in the navbar
- Go to "My Recipes" in the navbar
- Use the eye/edit/delete icons on each row
- Click your name in the navbar β Profile
- Update your bio or change your password
Install Postman: https://www.postman.com/downloads/
- Method: POST
- URL:
http://localhost:5000/api/auth/register - Body β raw β JSON:
{
"name": "Test User",
"email": "test@example.com",
"password": "123456"
}- Method: POST
- URL:
http://localhost:5000/api/auth/login - Body β raw β JSON:
{
"email": "test@example.com",
"password": "123456"
}Copy the token from the response.
- Go to Headers tab
- Add:
AuthorizationβBearer YOUR_TOKEN_HERE
- Method: POST
- URL:
http://localhost:5000/api/recipes - Header:
Authorization: Bearer YOUR_TOKEN - Body β raw β JSON:
{
"title": "Butter Chicken",
"cuisine": "Indian",
"difficulty": "Medium",
"cookingTime": 45,
"servings": 4,
"description": "Creamy and delicious",
"ingredients": [
{ "name": "Chicken", "quantity": "500g" },
{ "name": "Butter", "quantity": "2 tbsp" }
],
"steps": [
{ "stepNumber": 1, "instruction": "Marinate the chicken" },
{ "stepNumber": 2, "instruction": "Cook in sauce" }
],
"tags": ["chicken", "indian", "creamy"]
}MongoDB is not running. Fix:
- Windows: Press Win+R β type
services.mscβ find "MongoDB" β right click β Start - Mac: Run
brew services start mongodb-communityin terminal - Or use MongoDB Atlas instead (cloud, always on)
You forgot to run npm install. Go into that folder and run it again.
Open browser console (F12) and check the error. Usually it's:
- Backend not running β start
npm run devin backend folder - Wrong API URL β check
vite.config.jsproxy is pointing to port 5000
Another process is using port 5000 or 5173. Either kill it or change the PORT in .env.
Run this inside the frontend folder:
npm install tailwindcss postcss autoprefixer- You're not logged in, or your token expired
- Log out and log in again
- Make sure JWT_SECRET in .env hasn't changed
POST /api/auth/register Register new user
POST /api/auth/login Login, returns JWT token
GET /api/auth/me Get current user (auth required)
GET /api/recipes Get all recipes
Query params:
?search=chicken
?cuisine=Indian
?difficulty=Easy
?maxTime=30
?page=1&limit=9
GET /api/recipes/my-recipes Get logged-in user's recipes (auth)
GET /api/recipes/:id Get single recipe by ID
POST /api/recipes Create recipe (auth)
PUT /api/recipes/:id Update recipe (auth + owner only)
DELETE /api/recipes/:id Delete recipe (auth + owner only)
GET /api/favorites Get saved recipes (auth)
POST /api/favorites/:recipeId Save a recipe (auth)
DELETE /api/favorites/:recipeId Unsave a recipe (auth)
GET /api/users/profile Get profile (auth)
PUT /api/users/profile Update name/bio (auth)
PUT /api/users/change-password Change password (auth)
- Open MongoDB Compass
- Connect to:
mongodb://localhost:27017 - You'll see a
cookbookdatabase appear after you register/create recipes - Click it to see:
users,recipes,favoritescollections - You can view, edit, delete documents directly from here β great for debugging
- Make sure MongoDB is running (local) or Atlas is connected
- Open VS Code in the cookbook folder
- Terminal 1:
cd backend && npm run dev - Terminal 2:
cd frontend && npm run dev - Open browser:
http://localhost:5173
That's it. Both terminals must be running at the same time.