Also known as OFF-Graph, the Comparator uses the products' database delivered by the OpenFoodFacts community. It makes it possible to type in (or scan) the barcode of a product in order to get almost instantly within a user-friendly graph one of its scores (Nutrition score, Nova Classification score), or even your own score if you wish to build it!
Language of the application is English.
Refer to the following links for more details:
Note: some pieces of code or even some files may be unused and were not cleaned up. Sorry about this inconvenience guys! In case of doubt, feel free to ask me ;)
This project uses data from the OPENFOODFACTS database.
It is developped using Python 2.7 WSGI (backend) and html/css/ajax/js/d3js (frontend).
It is browser-based and hence intended to be used on any kind of devices (smartphones, tablets, desktops).
At startup, the country field may be automatically filled or choose it in the list. Then the registered stores for your country are loaded: you may then choose one in the "store" field to restrict the search (optional) Enter the product code and click on the blue Go button. After a few seconds, the server returns a list of similar products to yours (shown as an ellipse in the graph) which are classified by similarity (brands_categories) and nutrition score.
<img src="https://github.com/oricdev/off_product_comparator/blob/master/_documentation/images/scr_search_results.png" title="search results" height="350px" />
A box with thin borders surrounds a subset as suggestions. Suggested products are shown along with their image in a ribbon below the graph. You can browse horizontally (with the finger on smartphones) to fetch a product, or using the left and right arrows below the ribbon. Tap on a product to select it: a red spot will highlight in the graph and its product code is filled in the appropriate search field. Click on the magnifying glass to see some description of the product.
<img src="https://github.com/oricdev/off_product_comparator/blob/master/_documentation/images/scr_details_suggested_product.png" title="details of a similar product chosen in the ribbon" height="350px" />
Set your application path so that it points to
/off_product_comparator/wsgi.py
Refer to OpenFoodFacts Data, section Dump MongoDB.
Connection details are presently hard-coded in the application.
Simply update in module/Querier/`__init__`.py::connect() the 2 following lines with the connection data to your OpenFoodFacts MongoDb:
self.pongo = MongoClient("mongodb://<user>:<password>@<mongodb_url>/<mongodb_path>")
self.db = self.pongo["<mongodb_path>"]
Deploy the whole thing on your Python environment and start the instance.
The instance will use the entry point
wsgi.pyand listen to incoming requests (REST) defined in
app.py.
On the client side, open a browser and enter the http-address of your server, for instance:
https://tuttifrutti.alwaysdata.net
The server will respond to the route /
by executing the function helloAjax
defined in app.py
.
The server delivers the
templates/index.htmlfile based on resources' template defined in
templates/layout.html
All the server-side engine is located under the /module
directory.
Feel free to contact the author in case of questions or remarks :).