gustavovalle23 / food-recipe

API that brings recipes from an ingredient list

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Food System

The Food Recipe system brings the possibility to search for recipes, but in a different way. The usual thing is to search for the name of a recipe and the system tells you what ingredients are needed and how to prepare. Here we do the opposite, you inform which ingredients you have and the system informs you which recipes you are able to make.

Avaiable queries:

query RecipesWithIngredients {
  recipesWithIngredients (ingredientIds: [1, 4, 5]) {
    id
    name
    ingredients {
      id
      name
      quantity
      unitMeasurement
    }
    link
  }
}

query AvaiableIngredients {
  availableIngredients{
    id
    name
    quantity
    unitMeasurement
  }
}


query AvailableRecipes {
  availableRecipes {
    id
    name
    link
	ingredients {
      id
      name
      quantity
      unitMeasurement
    }
  }
}

Avaiable mutations:

mutation CreateIngredient {
  createIngredient(ingredient: {
    name: "Marshmellow",
    quantity: 1,
    unitMeasurement: GRAM
  })
}

mutation CreateRecipe {
  createRecipe(recipe: {
    name: "Orange Pie",
    link: "https://www.recipelink.com/recipecards/889_dinner_with_peaches.html"
  })
}

mutation AddIngredientToRecipe {
  addIngredientToRecipe(recipeId: "1", ingredientIds: ["1", "3"])
}

To export GraphQL schema:

strawberry export-schema main:schema > schema.graphql

recipesWithIngredients used following sql query

SELECT *
FROM recipes r
WHERE r.id NOT IN (
	SELECT recipe_id
	FROM ingredient_recipe
	WHERE ingredient_id NOT IN (10, 2, 4, 5, 1)
)
AND r.id IN (
	SELECT ir.recipe_id
	FROM ingredient_recipe ir
)

To execute tests:

python app/infra/models.py
python -m pytest test -s -vv

About

API that brings recipes from an ingredient list

License:MIT License


Languages

Language:Python 90.1%Language:Shell 6.2%Language:Dockerfile 3.7%