FoodRepo: An Open Food Repository of Barcoded Food Products
Gianrocco Lazzari Yannis Jaquet Djilani Kebaili Laura Symul Marcel Salathé
q-bio.QM










FoodRepo: An Open Food Repository of Barcoded Food Products
    Gianrocco Lazzari1, Yannis Jaquet1,
	Djilani Kebaili1, Laura Symul1, Marcel Salathé1*
    Received: date / Revised version: date
=========================================================================================



1. Global Health Institute, School of Life Sciences, Ecole Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland.
*  corresponding author: Marcel Salathé (marcel.salathe@epfl.ch).



	









In the past decade, digital technologies have started to profoundly influence healthcare systems. Digital self-tracking has facilitated more precise epidemiological studies, and in the field of nutritional epidemiology, mobile apps have the potential to alleviate a significant part of the journaling burden by, for example, allowing users to record their food intake via a simple scan of packaged products' barcodes.

Such studies thus rely on databases of commercialized products, their barcodes, ingredients, and nutritional values, which are not yet openly available with sufficient geographical and product coverage.
In this paper, we present FoodRepo (https://www.foodrepo.orghttps://www.foodrepo.org), an open food repository of barcoded food items, whose database is programmatically accessible through an application programming interface (API).



Furthermore, an open source license gives the appropriate rights to anyone to share and reuse FoodRepo data, including for commercial purposes.

With currently more than 21,000 items available on the Swiss market,
 our database represents a solid starting point for large-scale studies in the field of digital
 
 nutrition, with the aim to lead to a better understanding of the intricate connections between diets and health in general, and metabolic disorders in particular.





§ BACKGROUND & SUMMARY

	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	




























Metabolic disorders, such as diabetes or obesity, have become a major public health concern, with increasingly large parts of the global population affected <cit.>.
Nutritional epidemiologists hope to better understand the underlying causes, the potential treatments and prevention strategies by analyzing population and individual patterns through studies that generally rely on surveying dietary habits. Traditional food-intake survey methods are based on questionnaires filled by participants at a given frequency. This frequency is crucial to determine the accuracy of the records and the scope of the research <cit.>. Multiple-day diet records provide high accuracy, but require a strong motivation and time commitment by the participants. Approaches like multiple / single 24-h recalls - involving a specialized interviewer performing surveys in person or at the phone with the participants - 
	require less engagement, but pose some issues with missing data, as they rely on short-term memory. Finally, so-called Food Frequency Questionnaires (FFQ), where participants are asked to indicate the frequency of intake of certain foods over long periods of time (typically 1 year), demand minimal participants' commitment, therefore allowing for large cohort studies on long-term dietary habits. The likelihood of missing or incorrect data, however, increases as they count on participants' long-term memory. 
    
    Recent technological advances, and in particular the emergence and almost complete market penetration of smartphones, have offered interesting surveying alternatives. In particular, mobile phones have been successfully deployed in several food-related studies <cit.>, for example using food photography <cit.>. 
	Other research has also explored the possibility of recording dietary habits by asking participants to scan the barcodes of their consumed food  <cit.>. Although further investigations are required to assess self-reporting biases, these advances in nutritional research have triggered the release of  mobile apps oriented mainly towards diabetes and weight-loss self-management <cit.>, showing the willingness and interest of users to  monitor their food intake if it provides potential health benefits. 
    
The further expansion of self-monitoring for research and medical purposes relies on comprehensive and continusouly updated food databases. A few databases of barcoded products already exist, for example Open  Food Facts <cit.> or the USDA Food Composition Databases <cit.>. While they each have their strength, not all of them are openly accessible or, and they often have a limited product coverage, and are often not regularly updated. For Swizterland, we did not find any database whose product coverage was sufficiently high, where the data was completely open, and easily accessible through an API (Application Programming Interface). The last point was particuarly important to us, as APIs are necessary for third parties to dynamically use the data in their products and services. Our approach was therefore to build an openly accessible database of barcoded food products with sufficiently high coverage, acccessible through a stable API. Rather than focusing on a wide geographic range, we focused on a small country (Switzerland) in order to obtain the necessary coverage. The focus on the Swiss market further benefits from the need to support multiple languages from the beginning, thus making the system readily expandable to other countries, which we are now planning to do.

Here, we present this system, which we call FoodRepo (https://www.foodrepo.orghttps://www.foodrepo.org), a database of barcoded food products, and we describe the data-acquisition framework, its quality control and maintenance. The growing community around FoodRepo and the validation of new products make our database robust, scalable and self-sustainable in the long run. Currently, the FoodRepo database mostly holds products sold in Switzerland, from the main grocery stores in the country. Its international expansion is under development.

Any item in the database is accessible through the FoodRepo website (fig. <ref>-a )

 or via our API, described in section [usage_notes]. 
The CC-BY-4 license under which our database is released will allow its exploitation by different type of users, from academic researchers to commercial partners.
	For instance, a Swiss consumers association is using FoodRepo data in their NutriScan <cit.>

to make the food package information more accessible, and to provide their users with an overall nutritional score.
    
   
 Beyond this specific example, the FoodRepo database opens the way for promising research opportunities in the field of digital epidemiology and personalised nutrition.
Notably, we foresee that, through dietary live-tracking, this database can support studies which combine other recent technological developments and new findings in our understanding of the human metabolism. For example, phone-connected devices for continuous monitoring of blood glucose levels have recently been made available to diabetic patients <cit.>, as well as numerous direct-to-consumer devices to estimate glucose levels have appeared on the market. A plethora of other wireless sensors are now also available to record various physiological parameters, marking a new era of `high-throughput human  phenotyping' <cit.>. Studies that would simultaneously track participants' parameters, food intake, glycemic response and physical activity might provide detailed insights on the variability of individual metabolic responses. Interestingly, one of the factor which has recently been found to account for a large part of this variability is the microbiota <cit.>. Large-scale testing of these hypotheses through self-tracking could contribute to assess the complex metabolic response of the human body to different energy sources. 
This requires detailed records of food intake that includes nutritional information as well as eating times <cit.> and food portion sizes <cit.>, challenges that FoodRepo contributes to overcome. 
   
FoodRepo will also allow researchers to compare packaged food offers across time and geographical areas. Analyses of the database evolution will give interesting indication on the dietary trends and on the overall modification of the nutritive quality of packaged food. Although the database itself does not inform on the buying frequency, the continuous introduction of specific products in the market, and thus in the database, can potentially indicate how retailers react to customer demands and changing dietary habits.
























	














	
	




    

        





	










§ METHODS

















	
	
	
    The database building and maintenance process relies on the following steps: i) collection of products pictures from local 
    
    retailers, ii) data extraction from the pictures, iii) validation of the extracted data,  and iv) permanent storage in the database (Fig. <ref>). For the initial build of the database, we designed a specific pipeline (bootstrap workflow, Fig. <ref>-a,

    which allowed us to validate the first  20,000 food products in a few months. 
    Given the dynamic nature of our data and the cost of the bootstrap workflow, we designed a second pipeline (currently under development) which relies on the growing FoodRepo community. This workflow (community-based, Fig. <ref>-b) 

    allows us to keep up with the new and seasonal products introduced on the market by the retail shops, as well as to ensure the scalability and self-sustainability of FoodRepo in the long run. 

The bootstrap workflow (Fig.<ref>-a)

consists of 3 main steps. 

The first step entailed a massive manual data collection from three large groceries stores in Switzerland upon approval from the shops (such as Migros, Coop, and Lidl). We hired students 
to take pictures of all barcoded food items in retail shops located in the Lausanne area. To facilitate the data collection, we specifically designed a simple phone app with which  students could scan the products' barcode and take pictures of the front and back side of the package, the product's name, ingredients list, and nutrition facts. These pictures were then automatically uploaded to the database.  At the end of this step, students had collected on average 5 pictures per item.


	The second step focused on the extraction of information contained in the pictures. 
	Due to the presence of multi-languages ingredients and the often wrinkled surfaces of items packages, Optical Character Recognition
	(OCR) systems could not achieve a reliable accuracy. 
	We therefore opted for a crowd-sourced solution and set up an Amazon Mechanical Turk<cit.> (AMT) instance. AMT is a platform connecting requesters to workers, the latter being financially compensated to achieve tasks requiring human intelligence. Here, we designed a graphical user interface (GUI) allowing workers to transcribe the text they could read from products pictures. Specifically, the GUI presented text boxes where AMT workers provided the product name, nutritional values (in a table format) and ingredients, in every language present on the label (German and/or French for almost all items; Italian and/or English in addition for some products). Three different HITs (Human Intelligence Tasks) were set up: for nutrients, product name and ingredients. For the last two, we set up qualification rounds for AMT workers as their transcription involved some language skills.
	AMT workers could choose to either enter from scratch the information they saw on the pictures, or to approve / modify the suggestions given by an OCR<cit.> system. 

    At the end of the second step, all annotated products were uploaded into the database, flagged as ready for validation.

	The third step was thus dedicated to data validation, which was based on extensive manual check by the FoodRepo team, and was additionally informed with
    
    manual reports by visitors to the FoodRepo website and with error-detection analyses of nutritional values. Such online reports are encouraged by the presence of a  button on each product web-page, 

    which prompts a visitor to file an issue when spotting a potential error. Details about the error-detection analyses are given in the [technical_validation] section. Before the final validation of the data, the FoodRepo team as well as students manually checked all products thoroughly. 
    
   

	The community-based workflow (fig. <ref>-b) 
	is similar to the bootstrap workflow, but instead of counting on AMT workers, it relies on the growing FoodRepo community. As new products become available in retail shops, FoodRepo users can submit them by uploading the corresponding package pictures, using the FoodRepo smartphone app. Currently, the information extraction is still performed by the FoodRepo team, but additional features are being implemented in the app, which will allow users to directly type the product details contained on the package.
    
	
    
    Before user-provided information is permanently stored in the FoodRepo database, consistent entries will need to be submitted by at least three different FoodRepo users. If such consensus will not be reached after seven independent submissions (i.e. there are still less than three consistent entries), the item will be manually analyzed by the FoodRepo team for definitive validation and inclusion into the database.

	This procedure  will ensure  minimal intervention from our team, while still guaranteeing the reliability of the data. 
	

	The FoodRepo team is currently fostering the development of an active community through which the continuity of FoodRepo is assured, and which will likely accelerate the birth of independent exploitations of the database, from both public and private partners.

	
	
	
	

	







	
	

	










	
	
	
	
	
	
	

	
	
    
	
    



§ DATA RECORDS

















	
    
	All FoodRepo data are stored in a  https://www.postgresql.orgPostgreSQL<cit.> database, physically hosted on a server in Ireland. 
    For a quick overview of the dataset, a database dump can be downloaded from the dedicated folder in our API repository <cit.>. However, these dumps are not generated regularly, and we strongly encourage the use of the API which delivers up-to-date information. 
    For each product, which comes with a unique numerical identifier, the database contains pictures of the item as found in the shop (usually between three to seven  files), together with the main information presented on the package, i.e. the product name, nutritional values, ingredients list, barcode, and country of origin. The database holds as well the dates of product creation and last modification in the database (see Table <ref> ).
    The programmatic access to the database is allowed by an API, described in the section [usage_notes]Usage Notes 
    
    
    
	




	




































	

















































		
		





























		
	





§ TECHNICAL VALIDATION










	As described in the [methods] section, in the bootstrap stage (Fig. <ref>-a) 

	the final validation was performed manually by the FoodRepo team, while in the community workflow (Fig. <ref>-b),  

	the accuracy of the data is ensured by the consensus test (the FoodRepo team intervenes only if less than three matches are achieved after the uploads of the same product by seven different users). We highlight here that FoodRepo strictly reflects the information printed on products packages, even when suspicious values are present on the labels. All validation processes have thus been set-up to detect transcription errors. 

	Within this rationale, computational analyses were  implemented for the detection of outliers, in particular regarding the nutritional values. 
	These tests reflect basic constraints, such as the mass upper-limit:
	
	
    p + f + c ≤ 100

	
	where p,f, c are the product's protein, fat and carbohydrates concentrations expressed in grams, per 100 grams of product, respectively.
	From equation <ref>, one can also derive other linear inequalities for single nutrient or couples of nutrients, namely p + f ≤ 100, p + c ≤ 100, and c + f ≤ 100.
	These simple tests allowed us to detect transcription errors in earlier versions of the database, as illustrated by the outliers in fig. <ref>-a

	which shows the distribution of products in the fat-carbohydrates space with the joint mass boundary. 

	Similarly, other typos could be spotted by checking that the concentration of a subclass of nutrient is smaller than the one of the parent-class. This is the case for instance of sugars VS carbohydrates, or saturated-fat VS fat, shown in fig. <ref>-b. 


	Another simple relation that helps check products' nutrition facts can be derived from the standard approximation of energy density based on nutrients composition <cit.>:
	
	
    E ∼ 4p + 9f + 4c,

	
	where the product's energy content E is expressed in kCal/ 100   g.

	Combining expressions <ref> and <ref> provides upper and lower boundaries for the energy content (for example fig. <ref>-c).

	In this case however, not all dots that fall outside the boundaries were due to typos in transcription. 
	Indeed, the approximation in equation <ref> does not take into account the different contribution to energy of complex carbohydrates such as polyols, which account for less than 4 kCal/g. This is why products such as candies and chewing gums would fall below the energy boundaries.
			

	
				        
		



§ USAGE NOTES






















	
	
	
	

In order to facilitate the access to the database, we built an openly accessible application programming interface (API). Any terminal user, including third party apps or services, can send API requests to retrieve specific data. The API pipeline is described in fig. <ref>-b. User's requests are hosted on a Heroku server, where the https://bonsai.ioBonsai Elastic Search (ES)<cit.> application handles the queries on an https://aws.amazon.com/about-aws/global-infrastructure/AWS server<cit.> (based in Ireland). The ES response is then returned to the user after json formatting and compression (on demand). We checked that handling the request between the two servers does not critically compromise the total user-response time. We run series of single-page API calls, every 6 hours, over a week, in order to measure the full response-time and the Heroku server response-time. We observed that the latter was consistently fast across all experiments (in the range of 20-50 ms) and that the bottleneck was rather the transmission between the terminal user and the Heroku server (the average full response time was about 250 ms - see Fig. <ref>-c).

For a quick introduction to the API endpoints, users are welcome to try them out on the https://www.openfood.ch/api-docs/swaggers/v3API front page <cit.>. Furthermore, on the project's GitHub repository, one can also find usage cases <cit.> in Python, Ruby, Curl and JavaScript, as well as examples of complex queries <cit.> in https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.htmlElasticSearch query DSL <cit.>, which include  fuzzy searches. In case of large data fetching, we suggest to use the option of compressed data[This can be done by simply setting in the request header: ] and the possibility to include/exclude specific fields of each product (see again the API documentation <cit.>). In this way, one could reduce the response payload size by up to a factor of 10. 

We remind readers that all contents (other than computer software) made available by FoodRepo on the websites, apps or services are licensed under the https://creativecommons.org/licenses/by/4.0/Creative Commons Attribution 4.0 International License. We however would like to highlight the fact that product images may contain copyrighted data such as brand logos.




§ ACKNOWLEDGEMENTS








	This project was supported by a grant from the  http://www.stiftkgj.no/?lang=enJebsen foundation<cit.>.

	We are grateful to Migros, Coop, and Lidl
	for access to their retail shops.



§ AUTHOR CONTRIBUTIONS


	G.L. performed the descriptive and validation analysis of the dataset.
	Y.J. built the FoodRepo database, website, API and AMT HITs.

	J.D.K. maintained the API, coordinated the manual data validation and built the framework for the FoodRepo community. 
	G.L., L.S. and M.S. wrote the manuscript.
	M.S. initiated and supervised the project.
	



§ COMPETING FINANCIAL INTERESTS


The authors declare no competing financial interests.
































































ieeetr

