Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
204 changes: 164 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,61 +1,185 @@
# CookBook: Your Virtual Kitchen Assistant (Frontend Only)
# CookBook Your Virtual Kitchen Assistant (Frontend Only)

CookBook is a full-featured frontend recipe app built with React + Vite. It simulates a real app without a backend using LocalStorage and a lightweight fake API layer. It includes authentication, recipes CRUD, favorites ("My Cookbook"), filtering/search, routing, and a responsive Tailwind UI.
**CookBook** is a fully-featured frontend recipe application built with **React + Vite**.
It simulates a real full-stack app using **LocalStorage** and a custom **Fake API layer**, allowing full **CRUD operations** on recipes, **user authentication**, **favorites**, **advanced filtering**, and a beautiful responsive UI — **all without a real backend**.

## Tech Stack
![React](https://img.shields.io/badge/React-20232A?style=for-the-badge&logo=react&logoColor=61DAFB)
![Vite](https://img.shields.io/badge/Vite-B73BFE?style=for-the-badge&logo=vite&logoColor=FFD62E)
![TailwindCSS](https://img.shields.io/badge/Tailwind_CSS-38B2AC?style=for-the-badge&logo=tailwind-css&logoColor=white)

- React (Vite)
- React Router
- Tailwind CSS
- Context API for state
- LocalStorage + custom `fakeApi`
- `react-hot-toast` for toasts
**Live Demo**: [https://cookbook-demo.netlify.app](https://cookbook-demo.netlify.app) *

## Getting Started
---

1) Install dependencies
### Demo Login (Instant Access)

```bash
npm install
```text
Email: demo@cookbook.app
Password: demo123
```

2) Run dev server
You can also register a new account, everything is saved in LocalStorage.

## Features

### Authentication
- Login & Register forms
- Protected routes
- Persistent session (LocalStorage)
- Logout

### Recipe Management
- Add, Edit Delete recipes
- View detailed recipe page
- Track user-created recipes

### My Cookbook (Favorites)
- Save/unsave recipes per user
- Dedicated "My Cookbook" page

### Smart Filtering & Search
- Search by title
- Filter by category (Breakfast, Lunch, Dessert…)
- Filter by difficulty (Easy, Medium, Hard)
- Combine filters

### UI/UX
- Modern Tailwind CSS design
- Fully responsive (mobile-first)
- Toast notifications (React Hot Toast)

## Tech Stack

| Technology | Purpose |
|------------------|-------------------------------|
| React + Vite | Fast frontend & fast dev server |
| React Router v6 | Routing |
| Context API | Global state (Auth & Recipes) |
| Tailwind CSS | Styling |
| React Hot Toast | Notifications |
| LocalStorage | "Database" |
| Custom Fake API | Backend simulation |

### Project Structure

```bash
src/
├── components/
│ ├── layout/ # Navbar, Footer, Layout components
│ └── recipes/ # RecipeCard, RecipeGrid, RecipeForm, Filters, etc.
├── pages/ # All page components
│ ├── Home.jsx
│ ├── Recipes.jsx
│ ├── RecipeDetail.jsx
│ ├── AddRecipe.jsx
│ ├── EditRecipe.jsx
│ ├── Login.jsx
│ ├── Register.jsx
│ ├── MyCookbook.jsx
│ ├── MyRecipes.jsx
│ └── Profile.jsx
├── context/ # Global state management
│ ├── AuthContext.jsx
│ └── RecipesContext.jsx
├── data/
│ └── sampleRecipes.json # Initial seeded recipes
├── utils/
│ └── fakeApi.js # Simulated backend with LocalStorage
├── App.jsx # All routes + ProtectedRoute wrapper
├── main.jsx # Root providers (AuthProvider, RecipesProvider) + Toaster
└── index.css # Global styles + Tailwind base, components, utilities
```
## Installation & Run

```bash
git clone https://github.com/yourusername/cookbook.git
cd cook
npm install
npm run dev
```
- Open http://localhost:5173
### Protected Routes (Require Authentication)

These pages are only accessible when logged in.
Unauthenticated users will be redirected to `/login`.

| Route | Description |
|---------------------|---------------------------------|
| `/add` | Add a new recipe |
| `/edit/:id` | Edit an existing recipe |
| `/my-cookbook` | Your personal favorites |
| `/my-recipes` | Recipes created by you |
| `/profile` | View and edit your profile |

Public routes (no login needed):
- `/` → Home
- `/recipes` → All recipes
- `/recipes/:id` → Recipe detail
- `/login`
- `/register`
### Fake Backend Keys in LocalStorage

All data is persistently stored in the browser's LocalStorage under these keys:
```text
cb_recipes → All recipes (seeded + user-created)
cb_users → Registered users (email + hashed password)
cb_user → Currently logged-in user object
cb_favorites → { "user@email.com": [1, 5, 23, ...] } – user's favorite recipe IDs
cb_seeded → Boolean flag to prevent re-seeding sample data
```
---

3) Open the URL printed in the terminal (usually http://localhost:5173)
### Screenshots

## Fake Auth
| Login & Register | Home Page |
|----------------------------------------------------------------------------------|--------------------------------------------------------------------------------|
| ![Login](https://github.com/user-attachments/assets/6879973d-965d-4357-aa62-768cd9eb15f8)<br>![Register](https://github.com/user-attachments/assets/f3f29732-eb8a-4237-abd2-101925940b27) | ![Home](https://github.com/user-attachments/assets/ab75ebb1-5e31-4774-bb97-a83250f65950)<br> ![Recipe Detail 1](https://github.com/user-attachments/assets/65692d0b-af14-4802-bfe7-5cf311270237) |

- Demo account: email `demo@cookbook.app`, password `demo123`
- Register creates a new user and logs you in (stored in LocalStorage)
| Recipe Details | Add Recipe |
|--------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------|
|<br>![Recipe Detail 2](https://github.com/user-attachments/assets/fa9df22d-1e12-422f-8c0a-d0b70c090399) | ![Add Recipe](https://github.com/user-attachments/assets/fd5913a8-2fa8-45d2-b602-7fe2e38d09f6) |
### Future Enhancements

- Real backend with Node.js/Express + MongoDB (or Firebase)
- Image upload for recipes (Cloudinary / Firebase Storage)
- Recipe ratings & comments system
- User comments and reviews
- Dark mode toggle
- Shopping list generator
- Print recipe feature
- Progressive Web App (PWA) support
- Unit converter in ingredients

---

### Contributing

Contributions are very welcome!
Feel free to:

- Open issues for bugs or feature requests
- Submit pull requests with improvements
- Suggest new recipes for the sample data

---

### License

This project is open-source and licensed under the **MIT License**.
© 2025 https://github.com/y-kanchan

**Happy Cooking!**
Made with passion

---

## Data Seeding

- On first load, `src/data/sampleRecipes.json` is written into LocalStorage
- Users are stored in LocalStorage under `cb_users`
- Logged-in user stored under `cb_user`
- Favorites keyed by user under `cb_favorites`

## Project Structure

```
src/
components/
layout/ (Navbar, Footer)
recipes/ (RecipeCard, RecipeGrid, RecipeFilters)
ui/ (Button, Input, TextArea, Select, Loader)
context/ (AuthContext, RecipesContext)
data/ (sampleRecipes.json)
pages/ (Home, Recipes, RecipeDetails, Login, Register, AddRecipe, EditRecipe, MyCookbook, MyRecipes, Profile)
utils/ (localStorage.js, fakeApi.js)
App.jsx, main.jsx, index.css
```

## Notes

- This is a frontend-only app. No network calls are required.
- Tailwind warnings in editors are normal until PostCSS runs via Vite.
-