FoodSafe Scanner is a Flask-based web application that allows users to scan food product barcodes and receive detailed information about the product, including a list of ingredients and their potential health risks. It uses the Open Food Facts API to fetch product data and compares ingredients against a predefined list of risky ingredients.
- Scan Barcode: Scan a product's barcode to retrieve basic information about the product.
- Analyze Ingredients: Analyze the ingredients of the product against a predefined list of risky ingredients and receive detailed health risk information.
- Risk Assessment: The application identifies ingredients that could pose health risks (e.g., carcinogens, allergens, and other harmful substances).
- Python 3.x
pip
(Python package manager)
-
Clone the repository:
git clone https://github.com/MicheleGiammarini/FoodSafe-Scanner.git cd FoodSafe-Scanner
-
Create a virtual environment (optional but recommended):
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install the required dependencies:
pip install -r requirements.txt
-
Run the Flask application:
python main.py
The server will start and listen on
http://0.0.0.0:5000
.
-
URL:
/scan
-
Method:
POST
-
Request:
barcode
: A string representing the product barcode.
Example request body:
{ "barcode": "1234567890123" }
-
Response: Returns basic product details including product name, ingredients, and nutritional information.
Example response:
{ "product_name": "Example Product", "ingredients": ["ingredient1", "ingredient2"], "nutritional_info": { "energy": "100kcal", "fat": "5g", "sugar": "2g" } }
-
URL:
/analyze
-
Method:
POST
-
Request:
barcode
: A string representing the product barcode.
Example request body:
{ "barcode": "737628064502" }
-
Response: Returns product details along with a list of ingredients and any identified health risks.
Example response:
{ "product_name": "Example Product", "ingredients": ["ingredient1", "ingredient2"], "risks": [ { "ingredient": "ingredient1", "risk": "Potential carcinogen linked to liver and kidney damage." } ] }
This application includes a predefined list of risky ingredients and their associated health risks:
- Aspartame: May cause allergic reactions and has potential brain effects.
- BHA: Potential carcinogen linked to liver and kidney damage.
- BHT: Potential carcinogen that can alter metabolism.
- Acrylamide: Classified as a carcinogen, linked to increased cancer risk.
- Monosodium Glutamate: Can cause headaches and other adverse reactions.
- Salt: Excessive consumption can lead to high blood pressure, heart disease, stroke, and kidney disease.
This project is licensed under the MIT License.