- Description
- Releases
- User journey
- Data wrangling
- Technical requirements
- Test coverage
- Status
- Contributing
- Authors
- License
- Appendix
dansMonPanier is a web application based on Open Food Facts data, aimed at leveraging its value regarding nutritional but also ethical and ecological concerns.
In line with nowadays growing willing to consume in a healthy and responsible way, this app allows the user to identify the products that best meet her requirements.
Intended for French users, the language communication of dansMonPanier is French.
The first release provided a list of products ordered by nutrition grade or by NOVA group, depending on the chosen ranking and the targeted category of food.
Since then, have been added multi-criteria classification and filtering of search results in the database and a feature to allow the user to remove products from her favorites.
Also the top navigation bar was replaced by a side navigation bar so to improve user experience and avoid conflicts with the virtual keyboard on mobiles.
The user enters a food name in the search field (from the home page or from the navbar) and chooses ranking (by nutrition grade or NOVA group) and filtering criteria (e.g. "bio", "fair trade", ...), according to her interest. If there is no corresponding category in the database, a message informs the user. Otherwise, a results page displays 18 products belonging to the targeted category, each being presented with a set of 12 features (e.g. the presence of allergens or palm oil, the origin of the ingredients, whether it is “bio” or not, etc. - see appendix) appearing when they are true or available. A button allows the user to save a product as a favorite. If she is not logged, a message prompts her to do so or to create an account.
The user can learn more about a product by clicking on the image of the product (which is directly loaded from Open Food Facts database) or on the title of the card. The product page contains 12 criteria accompanied by information such as its nutritional formula per 100 g., composition, packaging, quantity, places of sale … Again, the user can add a product to her favorites if she is already connected. Each time a product is registered, a message confirms the operation.
When a product has already been selected by the user, the button “save” is not anymore active in any page but replaced by the mention “remove from my favorites”, which prevents duplicates. The user can retrieve all its favorites by clicking on the carrot icon in the top navbar (which appears only if the user is logged). If she has not saved any product yet, a message invites her to do so. The favorites page follows the same template as the results page.
The user accesses the login page by clicking on the user icon in the navbar to register or login, as appropriate. Whether or not she is a new user, she is greeted with a welcome message if all has gone well. Otherwise, an error message is displayed ("Incorrect credentials", "You must provide valid information to register"). When the user logs out, a good bye message appears.
Open Food Facts is a food products database made "by everyone, for everyone", which ensures its various and ever growing content. The drawback of this openness is the mixed quality of data. Any project aiming to use them should first carry out a detailed analysis of their overabundant and sometimes redundant facets, with the risk of delivering inaccurate or misleading results.
For this reason, a large part of the effort in building the application has been cleaning and reshaping the data, in order to make them correctly loadable in a postgres database but also readable by a user and actionable.
Two specific modules were built to achieve data wrangling and collection automation:
cat_builder.py gets and stores in a csv file the food categories currently available in OFF database. It includes cleaning tasks such as dropping NaN, duplicated field labels and poor categories (i.e. containing less than 100 products). It also ensures the writing of the banner image paths for every category ;
food_builder.py performs various operations on data to manage their collection and refinement:
- automate URI generation based on the components of Open Food Facts Read/Search API and the data collected by the cat_loader module. The latter provides the total of products per food category and so enables to determine the number of pages (1000 items per page) to be loaded.
- automate sending http requests and filter the data to be collected. Only some specific fields are taken into account (see appendix and details on the API/Read/Product page).
- clean and refine data:
- drop products of which completeness is less than 90%
- remove undesired tags that cause the creation of supernumerary lines in the csv file and/or hamper readability
- remove duplicate words in textual columns
- extract indicators from the fields 'labels', 'ingredients_analysis_tags' and 'nutriments'
Finally, it is built a food database that contains 32 variables including 25 criteria (see appendix) relevant regarding healthy, ethical and ecological concerns. Most of the Boolean variables were not given as such but extracted from text in the field 'labels', ‘ingredients_analysis_tags’ and ‘origins’ and then reshaped.
The app is built with Django framework 2.2.9 and written in Python 3.7.
One can use the package manager pip to install the whole required libraries.
pip install -r requirements.txt
Module | statements | missing | excluded | coverage |
---|---|---|---|---|
Total | 424 | 26 | 0 | 94% |
explore/__init__.py | 0 | 0 | 0 | 100% |
explore/apps.py | 3 | 0 | 0 | 100% |
explore/forms.py | 10 | 0 | 0 | 100% |
explore/migrations/0001_initial.py | 7 | 0 | 0 | 100% |
explore/migrations/0002_auto_20200202_1454.py | 5 | 0 | 0 | 100% |
explore/migrations/0003_favorite_meal.py | 4 | 0 | 0 | 100% |
explore/migrations/__init__.py | 0 | 0 | 0 | 100% |
explore/models.py | 55 | 0 | 0 | 100% |
explore/process.py | 13 | 2 | 0 | 85% |
explore/tests.py | 186 | 0 | 0 | 100% |
explore/urls.py | 3 | 0 | 0 | 100% |
explore/views.py | 138 | 24 | 0 | 83% |
coverage.py v5.0.3, created at 2020-02-05 10:16
This project is in progress.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
- Initial work: Stephanie BLANCHET, Data and Application Pythonist.
- Contact: stephanie.blanchet.it@gmail.com
This project is licensed under the MIT License - see MIT for details.
- category
- code
- name
- brands
- stores
- completeness
- origins
- ingredients_text
- additives
- allergens_from_ingredients
- quantity
- image_url
- packaging
- labels
- ingredients_analysis_tags
- nova_group
- nutrition_grades
- energy_100g (from 'nutriments')
- energy_unit (from 'nutriments')
- fat (from 'nutriments')
- saturated-fat (from 'nutriments')
- sugars (from 'nutriments')
- salt (from 'nutriments')
- proteins (from 'nutriments')
- fiber (from 'nutriments')
- Agriculture biologique
- Point Vert / Eco-emballages
- Certifié FSC
- Certifié UTZ (Chocolat)
- Sans huile de palme
- Fabriqué en France
- Ingrédients d'origine française
- Commerce équitable
- Végétalien
- Végétarien
- Sans gluten
- Garantie IPLC (lait)