SmartChef is a full-stack web application that provides intelligent recipe matching based on user-provided ingredients.
It combines a lightweight frontend with a FastAPI backend that uses TF-IDF vectors, fuzzy ingredient mapping, and cosine similarity to suggest recipes and generate cooking steps using AI.
The SmartChef system allows users to:
- Enter available ingredients
- Discover matching recipes based on similarity
- See matched and missing ingredients
- Receive AI-generated cooking instructions
The frontend communicates directly with the backend REST API to fetch recipes, ingredient data, similarity scores, and generated cooking steps.
User Input
↓
Frontend (HTML + CSS + JS)
↓ Fetch API
Backend (FastAPI + TF-IDF + Cosine Similarity)
↓
Recipe Matches + AI Cooking Instructions
- Simple and responsive UI
- Ingredient-based recipe search
- Displays similarity scores
- Shows matched and missing ingredients
- Renders AI-generated cooking steps
- Lightweight and fast (no framework overhead)
- Ingredient-based recipe matching using TF-IDF
- Fuzzy ingredient normalization
- Cosine similarity scoring
- AI-powered cooking instruction generation (Google Gemini 2.5 Flash)
- JSON-based dataset support
- Production-ready FastAPI server
| Layer | Technology |
|---|---|
| UI | HTML, CSS |
| Logic | JavaScript |
| API Calls | Fetch API |
| Layer | Technology |
|---|---|
| Framework | FastAPI |
| Vectorization | TF-IDF |
| Similarity | Cosine Similarity |
| AI | Google Gemini 2.5 Flash |
| Server | Uvicorn |
/
├── frontend/
│ ├── index.html
│ ├── styles.css
│ └── script.js
├── backend/
│ ├── main.py
│ ├── requirements.txt
│ └── data/
│ ├── recipes.json
│ └── ingredients.json
├── README.md
https://smartchef-backend-oq3n.onrender.com/
GET /
Returns API status and recipe count.
GET /api/ingredients
GET /api/recipes
POST /api/recipes/match
Request Body
{
"user_ingredients": ["egg", "milk", "flour"]
}Response Includes
- Matched recipes
- Similarity scores
- Matched ingredients
- Missing ingredients
- AI-generated cooking steps
POST /api/recompute-index
- Add dataset files:
backend/data/recipes.json
backend/data/ingredients.json
- Install dependencies:
pip install -r requirements.txt- Start the server:
uvicorn main:app --reload --host 0.0.0.0 --port 8000Backend will be available at:
http://localhost:8000
- Open
frontend/index.htmldirectly OR - Serve via a local server:
python -m http.serverOpen in browser:
http://localhost:8000
(Adjust API base URL in script.js if needed.)
- Backend works on Render, Railway, or any Python hosting platform
- Use the following command for production:
uvicorn main:app --host 0.0.0.0 --port $PORT- Frontend can be hosted on GitHub Pages, Netlify, or Vercel
fastapi>=0.95
uvicorn[standard]>=0.22
pydantic>=1.10