I’m developing a simple food diary app and using this amazing data source and also McCance and Widdowson’s Composition of Foods Integrated Set (for non-brand averaged foodstuffs).
Also reasonably actively adding new items to Open Food Facts and correcting entries where I notice errors.
Hi John. This looks very interesting / valuable and is something I would want to support in my PWA should my user base ever extend beyond just me
The data model I have developed is based on my needs as a user. As such it is similar to the model you have outlined, but my model also allows for shared and non-shared user amendments to food metadata, categories and photos.
Some points of note:
ingredients of individual food items are not recorded in a separate table with a one-to-many relationship. ingredients are available for review (if supplied by Open Food Facts in the “ingredients_text_with_allergens” field) as human readable text (allergens highlighted). Ingredients for McCance and Widdowson entries are not available.
Depending on the data available from Open Food Facts, users can specify a quantity of a food item (e.g. ml or grams) or can specify a number of servings. For example, they can say they had 2 large Asda Free Range Eggs and this will be recorded as 2 servings in the Servings field and 136g in the quantity field of the diary table. This is not supported for McCance and Widdowson where the data available is just per 100g or ml. I may allow users to specify serving sizes to augment the M&W dataset.
Meal Types. I have opted for Breakfast, Morning Snack, Lunch, Afternoon Snack, Dinner, Evening Snack and “Daily Allowances”. For example, users can allocate a certain amount of (say) milk to consume (e.g. in tea) throughout the day without having to record every usage of a spash of milk. Users can label these meals as they prefer (e.g. many folk in the North would have breakfast, dinner, tea rather than breakfast, lunch, dinner). I may allow further meal types to be added. Time of consumption is not recorded.
Users can change meal names, brands and photos to their own preferences. For example, McCance and Widdowson uses quite an technical sounding convention for naming foods (e.g. Pepper, Capsicum, Red, Raw). The user may just want to specify “Red Bell Pepper”. Open Food Facts, as a user-contributed data source, is prone to spelling, stylistic, other typographical or omission issues (e.g. item 0037600209571 is listed as Chopped Pork and Ham but the name doesn’t include the word SPAM ). User changes are user specific and do not affect the data seen by other users (though I may allow other users to accept “suggested changes” from other users).
Open Food Facts and McCance and Widdowson’s categories are ignored and if the user doesn’t specify a category their food diary remains uncategorised (except for meal selected). Users can categorise by a limited but (I hope) sufficiently differentiated category list: “Breads, Grains, Seeds and Starchy Veg”,“Condiments and Add Ons”,“Dairy and Dairy Alternatives”,“Drinks/Beverages”,“Fats and Oils”,“Fruit”,“Prepared and Ready Meals”,“Proteins (Meat, Fish, Eggs)”,“Proteins (Plant Based)”,“Savoury Snacks”,“Sweets and Desserts”,“Vegetables (Non-Starchy)”. I suspect this will develop/be refined over time.
Users can maintain a list of favourite items which allows for rapid re-use of frequently used products without having to scan the barcode or perform a search each time.
I suppose my question, in light of the above, is do you envisage the “name” of the food item being that from the original data source or the user preferred value (or both)? Similarly, the URL of the image. Images are generated dynamically (then cached) and there are different URLs for user provided images and those from the Open Food Facts. If the URL provided cannot find an image, a placeholder image is returned. With a user provided image, the URL will show an image to all users if the uploader has allowed sharing. If they haven’t only they see the image - others will see a placeholder.
I guess developers may have concerns about other apps continuing to retrieve images from their servers if the user has migrated away?
Sorry I’ve waffled on a bit. Hope this all makes sense and offers a useful perspective.
I take the points about some functions are value-added features specific to apps that may be implemented in different ways.
Although my app allows users to explicitly add food items to favourites (and optionally categorise them) I like the idea of having the top diary items available too so have implemented that in my app. Thanks!
The issue of names of food items is an interesting one. For example with my app, if the user doesn’t customise the product name or brand then the one provided by the latest version of the data source is used. The product name isn’t stored in the diary. Only the the unique ID for the food item is saved to the diary (in addition to date, meal, quantity and servings).
My app retrieves the Open Food Facts JSONL file and refreshes my app’s database every evening. This means that if the source (e.g. Open Food Facts ) for a particular food item is changed by someone in the OFF community and they have updated the Name or Brand, then the name/brand displayed in the app would change wherever/whenever it was used. The same applies to images. And,indeed, nutritional info (I want the user to benefit from corrections even retrospectively). If the user customises the name, brand for a particular food item then changes to the original data source for these items are ignored for that user.
The thing I forgot to mention is in addition to showing a traffic light graphic based on the established recommended UK ranges PER PRODUCT (Food labels - NHS) users can also specify their own colour coded DAILY thresholds. For example, users following the late Dr Mosely’s Fast 800 Keto diet could have Carbs show as red if they eat more than 50g in a day. Protein show in Green if they eat more than 50g…etc. The user can set traffic light thresholds for any of the main nutrients (e.g. fat, sat fat, sugar, carbs, protein, salt, fibre). Again this is probably not for the model.
If you’re interested in seeing it in action, the app is at https://nutrit.app/. It is a PWA that can be installed on Android and Windows and “added to home” on iPhone (I haven’t tested it in iPhone thought). It is completely free and I have no plans to add to app stores at the moment.
Hi @stevepburgess thanks for sharing all this !
If you can think how your user could contribute back data to Open Food Facts, it would be a real benefit to our project (or maybe it’s already the case ?).
I am happy to look into this - though the images users might take are low res (i.e. sufficient for mobile). The original image taken by the user is cropped so it is square and scaled so it is 500x500px.
Hi John I’ll have a proper look later - but the example you have given of “white coffee powder” raises another question about using volume instead of mass particularly for products whose nutritional info is probably given in grams.
In the JSON example the user has said they had 15ml of coffee (1tsp) but apps would need to know the mass unless the data source provided a conversion formula.
McCance and Widdowson provides the specific gravity of liquids and some semi-fluids (e.g. yoghurt) but not “flowing” solids like granulated sugar.