Skip to content

8rxn/infinitemeals

Repository files navigation

Infinite Meals

image

Infinite Meals is a recipe search engine that uses OpenAI's GPT-3.5-Turbo-1106 Model through Open AI API to generate recipes for any given Food. It's a simple and easy way to find new recipes and get inspiration for your next meal.

How to Search For Recipes:

You can Visit https://infinitemeals.vercel.app

You can find Recipes in multiple ways:

  • You can search for any recipe by going on your dashboard and searching for a recipe. Try Out
  • You can find recipes by going to the categories page and selecting a category that you want to find recipes for. Try Out
  • You can find recipes by going to the all recipes page and selecting a recipe that you'd like. Try Out

Getting Started Locally

First, Fork and Clone the repository Locally:

git clone https://github.com/your-user/infinitemeals.git

Next, install the required Dependencies:

npm install
# or
yarn install
# or
pnpm install

Lastly, Get the required environment variable from the providers [ Reference: .env.example] :

npm run dev
# or
yarn dev
# or
pnpm dev

Open http://localhost:3000 with your browser to see the result.

How does it Work?

Multiple Things Happen before the searched Recipe is returned to you.

  1. The recipe is Searched for in the Redis Cache against [when recipe is searched for the first time, it is cached]
  2. If unavailable in cache, it's looked for in the database.
  3. If the recipe is still unavailable, Text - Davinci - 003 is used to get the recipe for that item.
  4. The response from Text - Davinci - 003 is displayed to the user at this point of time.
  5. The response from the Database is then added into the Database and Cached for future use.
  6. Meanwhile, When Text - Davinci - 003 is used for fetching the recipe, the image is being looked for using Google Images Search from SERP API. The image fetched from the API is added to Cloudinary.
  7. The image added is displayed while the Image URL is added into the recipe Database and cache for future use.

Tech That was Used:

  • Upstash - Redis Caching & Rate Limiting
  • Open AI API - AI Generated Recipes
  • SERP API - Images
  • Cloudinary - Image Storage
  • Planet Scale - ServerLess MySQL DB
  • Prisma - ORM
  • Next Auth- Auth
  • Next.js 13.4.9 - Project
  • Vercel - Deployment

Routes Reference (v2):

Method Route Description
POST /api/v2/recipes/database Looks for the recipe searched in Redis Cache and Main Database
POST /api/v2/recipes/completion Uses Open AI API to generate recipes based on the search query
POST /api/v2/recipes/uid Fetches Recipe based on the UID
POST /api/v2/recipes/update-recipe-by-ai Adds the recipe generated by AI to the database and cache
POST /api/v2/images/database Searches for the image in the cache and database for a recipe
POST /api/v2/images/search Uses Serp API to search for images based on the search query using Google Images Search
POST /api/v2/images/completion [unused] Uses DALL - E to create images for food Items based on the search query
POST /api/v2/images/update-image-db Uploads Images to Cloudinary and updates the database inserting the imgURL, also caches the imgURL
POST /api/v2/tags/create Creates A new Tag if not already present in the list of Tags in Database
GET /api/v2/tags/get-tags Gets the list of all tags present in the database
POST /api/v2/tags/recipes Gets the list of all recipes present in the database with the tag
POST /api/v2/tags/recipes/completion Uses Open AI API to generate a recipe for the given tag

Contributions:

Contributions are always welcome. Please refer to CONTRIBUTING.md for more info.


Bon Appetit!