Skip to content

dcmalk/ai-food-recipes

Repository files navigation

AI Food Recipes

Delicious food recipes generated by robots (AI).

Artificial intelligence is used to generate food recipes based on a random selection of ingredients. Each recipe includes instructions, photo, tags and various meta data. A clean UI is provided for easy navigation. New recipes can be added and a cached version of the site will automatically deploy.

This project started as an exercise in Gatsby and evolved into an exploration of AI and serverless development. It uses a tech stack that was chosen more for experimentation than performance.

How It Works

GraphQL queries Contentful for recipe data and then Gatsby serves everything neatly as a cached, static site.

To generate a recipe, an AI trained on cooking recipes is used. It's seeded using random ingredients and after generation, a Pixabay image is chosen. Everything is then saved to Contentful at which point Netlify redeploys the cached site.

The AI model is hosted on Hugging Face and TPU provided by Google.

Running Locally

$ git clone https://github.com/dcmalk/ai-food-recipes.git
$ cd ai-food-recipes
$ npm install
$ npm start

Environment Variables

Create a .env.development and a .env.production file with the constants below. Add the required credentials to each file:

CONTENTFUL_AUTH_TOKEN=your-contentful-account-auth-token
CONTENTFUL_API_KEY=your-contentful-space-api-key
CONTENTFUL_SPACE_ID=your-contentful-space-id
HUGGING_FACE_API_KEY=your-hugging-face-api-key
PIXABAY_API_KEY=your-pixabay-api-key

When deploying to Netlify, add these as build environment variables. Serverless functions (proxy) will hide your underlying credentials from Gatsby cache. See here for more details.

Contentful Model

Add a content type called recipe with the following fields:

title: Short text
cookTime: Integer
description: Long text
servings: Integer
image: Media
featured: Boolean
prepTime: Integer
content: JSON object

Built Using

Acknowledgements

Special thanks to John Smilga for creating his excellent Udemy course, Gatsby.js Tutorial and Projects Course, from which this code originated. This repository contains my updated version of the project which extends its functionality using AI generated recipes and automatic image selection from Pixabay.

About

Delicious food recipes generated by robots (AI)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published