davesag / open-recipe

A facebook app that allows people to share their favourite home recipes
0 stars 0 forks source link

Document our approach to Ingredients in the Wiki #16

Closed davesag closed 12 years ago

davesag commented 12 years ago

Handling ingredients properly, both with short-term "do the simplest thing that works" in mind, and "what's the simplest thing for the user" in mind. In addition a key contributor to the value of Open Recipe is going to be the structure of its ingredients database, acting as a central lookup for ingredient names, with links to their equivalents in consumer bar-code databases, and user's own variants on core ingredients.

The proposal is we keep track of four kinds of Ingredient types.

A recipe contains a list of ActiveIngredients that carry an optional Quantity and a Unit, as well as being linked to an Ingredient which is a User generated name for an ingredient, with some sort of optional qualifying text such as 'chopped', or 'sliced' etc.

We will pre-seed and maintain a database of 'Core Ingredients' containing standardised, and internationalised names for recipes.

When the user starts typing in an ingredient name, the system will autocomplete, matching against other User entered Ingredients. This will help keep the number of ingredient names to a minimum, while allowing infinite expansion. When the user saves their recipe, any incoming Ingredient names that are unknown to the list of all User generated Ingredients will be analysed and assigned one or more a matching CoreIngredients

Recipe: has_many ActiveIngredients
ActiveIngredient: belongs_to Recipe

ActiveIngredient: belongs_to Ingredient
Ingredient: has_many ActiveIngredients

Ingredient has_and_belongs_to_many CoreIngredients
CoreIngredient has_and_belongs_to_many Ingredients

In addition we will add, in Phase 2, a corresponding ConsumerIngredients ingredient where:

ConsumerIngredient has_and_belongs_to_many CoreIngredients
CoreIngredient has_and_belongs_to_many ConsumerIngredient

and which holds references to actual consumer products.

So if you know an ActiveIngredient, ai you can determine ai.ingredient.core_ingredients.

Document this all in the wiki so we all understand how it works.

davesag commented 12 years ago

Documented in wiki/Ingredients.