Skip to content

AI-powered Recipe Maker built with Streamlit and Groq API to generate personalized recipes based on available ingredients

License

Notifications You must be signed in to change notification settings

alok-ahirrao/RecipeMaker-AI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🍽️ Recipe Chatbot (FastAPI + React + Groq API)

This repository contains a Recipe Chatbot that allows users to upload images of ingredients, detect the ingredients, and generate recipes using AI models like YOLO for image detection and Groq API for recipe generation.


πŸŽ₯ Demo

Recipe Chatbot Demo


πŸ“ Project Structure

LLVIS_FRUITS_AND_VEGETABLES
β”œβ”€β”€ backend
β”‚   β”œβ”€β”€ Recipe_Chatbot/              # Virtual environment folder
β”‚   β”œβ”€β”€ uploads/                    # Folder to save uploaded images
β”‚   β”œβ”€β”€ runs/                       # YOLO runs folder
β”‚   β”œβ”€β”€ main.py                     # FastAPI server
β”‚   β”œβ”€β”€ requirements.txt            # Python dependencies
β”‚   β”œβ”€β”€ yolo_fruits_and_vegetables_v8x.pt # YOLO model weights
β”‚   β”œβ”€β”€ .env                        # Environment file (API keys)
β”‚   β”œβ”€β”€ Procfile                    # Deployment file (optional)
β”œβ”€β”€ frontend
β”‚   β”œβ”€β”€ node_modules/               # React dependencies
β”‚   β”œβ”€β”€ public/                     # Static assets
β”‚   β”œβ”€β”€ src/                        # React source code
β”‚   β”‚   β”œβ”€β”€ App.js                  # Main React component
β”‚   β”‚   β”œβ”€β”€ App.css                 # Styles
β”‚   β”‚   β”œβ”€β”€ index.js                # Entry point for React
β”‚   β”‚   β”œβ”€β”€ chef-avatar.png         # Chatbot avatar
β”‚   β”‚   β”œβ”€β”€ user-avatar.png         # User avatar
β”‚   β”‚   β”œβ”€β”€ 2.png, 7.11.png         # Additional assets
β”‚   β”œβ”€β”€ package.json                # React dependencies
β”‚   β”œβ”€β”€ package-lock.json           # Lockfile for dependencies
β”‚   β”œβ”€β”€ .env                        # Environment file (Backend URL)
β”œβ”€β”€ README.md                      # Documentation

πŸš€ Backend (FastAPI + Groq API)

βœ… Features

  • Image Upload: Detects ingredients in images using YOLO.
  • Recipe Generation: Generates recipes based on detected ingredients using Groq API.
  • Chatbot: Interactive chatbot to assist users with culinary questions.

πŸ”§ Setup Instructions

1️⃣ Install Dependencies

cd backend
python -m venv Recipe_Chatbot
source Recipe_Chatbot/bin/activate  # On Windows: backend\Recipe_Chatbot\Scripts\activate
pip install -r requirements.txt

2️⃣ Setup .env File

Create a .env file in the backend folder:

GROQ_API_KEY=your_groq_api_key_here
GROQ_MODEL=llama3-8b-8192

3️⃣ Run FastAPI Server

uvicorn main:app --host 0.0.0.0 --port 8000 --reload

πŸ“Œ Open http://127.0.0.1:8000/docs to explore API documentation.


πŸ”— Connecting to Groq API

Groq API is used to generate recipes and chat responses.
Ensure you have a Groq API key from Groq.com.

Backend Code (main.py)

Modify main.py to load Groq API key from .env:

import os
from dotenv import load_dotenv
import requests

# Load API key from .env file
load_dotenv()
GROQ_API_KEY = os.getenv("GROQ_API_KEY")
GROQ_MODEL = os.getenv("GROQ_MODEL", "llama3-8b-8192")
GROQ_API_URL = "https://api.groq.com/openai/v1/chat/completions"

def query_groq(prompt):
    headers = {
        "Authorization": f"Bearer {GROQ_API_KEY}",
        "Content-Type": "application/json",
    }
    payload = {
        "model": GROQ_MODEL,
        "messages": [{"role": "user", "content": prompt}],
        "temperature": 0.7,
    }

    response = requests.post(GROQ_API_URL, json=payload, headers=headers)
    return response.json()["choices"][0]["message"]["content"]

πŸ’» Frontend (React)

βœ… Features

  • Upload images via drag-and-drop or file upload.
  • Displays detected ingredients and allows manual edits.
  • Real-time chat with a recipe chatbot.
  • Dynamic recipe generation with AI.

πŸ”§ Setup Instructions

1️⃣ Install Dependencies

cd frontend
npm install

2️⃣ Setup .env File

Create a .env file in the frontend folder:

REACT_APP_BACKEND_URL=http://127.0.0.1:8000

3️⃣ Start React Frontend

npm start

πŸ“Œ Open http://localhost:3000 to see your app.


πŸ“‘ API Endpoints (Backend)

/upload

  • Method: POST
  • Description: Uploads an image and detects ingredients using YOLO.
  • Response:
    {
      "file_id": "unique-id",
      "ingredients": ["tomato", "onion"]
    }

/recipe

  • Method: POST
  • Description: Generates a recipe based on detected ingredients.

/chatbot

  • Method: POST
  • Description: Responds to user queries in a culinary context.

πŸ“Œ Summary

βœ… Uses Groq API for AI-powered recipe generation
βœ… Uses .env for secure API key management
βœ… Fully functional FastAPI backend & React frontend

πŸš€ Your app is now ready for deployment! Let me know if you need any help! πŸ”₯😊


License

Copyright

Copyright (c) 2025, Alok Ahirrao

This project is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License.
You may use and modify this project for personal or educational purposes, but commercial use is prohibited without explicit permission.

For more details, see the LICENSE file or contact [email protected] .


Happy Cooking!

About

AI-powered Recipe Maker built with Streamlit and Groq API to generate personalized recipes based on available ingredients

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published