Skip to content

adityaprasad-sudo/FoodDecoder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

89 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Welcome to Food Decoder!

Food Decoder is an open source project designed to help you purchase healthy products to live long and be healthy using AI models to highlight the product's potential benefits and harmful effects. DO NOTE:- AI can Make mistakes.

Features

  • Barcode Scanning :- uses htmlQR code scanner libraries and https://world.openfoodfacts.org/ api to fetch product details. Do Note: - not every product is available in the world.openfoodfacts database for that i designed a visionary model to read the ingredients directly from the package

  • Vision Model :- upload a photo of the package ingredients if the barcode isnt working, (this uses Nvidia nemotron nano 12b v2 vl)

  • Analysis :- After the barcode/image has been uploaded succesfully it uses the models to read and calculate health score based on the ingredients and processes potential benefits, harmful effects and potential allergens.

  • UI:- easy to navigate UI, the scan barcode and image button is available directly at the homepage for easier navigation and faster navigation

  • I hosted the backend on Hugging Faces which ensures 99.9 % uptime and thanks for HackClub for providing the models for free

Tech Stack

What i used in frontend

  • HTML5, CSS3, Vanilla JavaScript

  • HTML5-QRCode (for barcode scanning)

Backend and models

  • Framework:- Fastapi

  • BackendHosting:- Hugging Face Spaces

  • PrimaryLLM:- Google Gemini 2.5 Flash(this is used when we use barcode scanning)

  • FallBackLLM:- Nvidia Nemotron-12b (this is used when we use the image feeding button)

  • Food Database:Open Food Facts API

How It Works

  1. Scan or Upload: If the database contains the product scanning the barcode(usually behind the food package) can give instant insights but if you want deeper analysis or the product is not in the database you can take a photo of the backside of the product which will give a more detailed insight.

  2. Database Lookup: If a barcode is scanned the openfoodfacts api returns an json containing the ingredient list.

  3. AI Processing: After Getting an ingredient either from barcode or vision model there are 2 cases :-

    1. Uses Gemini 2.5 flash if the barcode reading was succesfull.
    1. Uses Nvidia Nemotron if the barcode failed and an image was uploaded
  1. Final Analysis:- The JSON returned by the Models is formatted in the web UI giving a detailed analysis and health score.

Local Installation

Idk why would anyone install it locally but here are the steps to do so:-

  1. Clone the Repo
  1. Setup the api keys
  • make .env file in the cloned repo

    this goes into your .env file and put your gemini api key in the chiggaapi and openrouter api key in the opapikey:-

    chiggaapi=YOUR_GEMINI_API_KEY opapikey=YOUR_OPENROUTER_API_KEY

3.Install dependencies

    pip install fastapi uvicorn google-generativeai pillow requests python-dotenv python-multipart
uvicorn main:app --reload --port 7860

4.Runing the frontend

  • You can serve the HTML/CSS/JS files using any standard live server (like the VS Code Live Server extension)

NOTE: Camera access in browsers requires either a localhost or https:// connection

Disclaimer

DecodeFood is built for educational and informational purposes only. The AI-generated health scores and insights do not constitute professional medical advice. Users with severe food allergies should always verify ingredients on the physical packaging.

Author

Built by Aditya Prasad GitHub: @adityaprasad-sudo

Flowchart

flowchart

Screenshots and Demo

item used in the video - Amazon

Screenshot 2026-04-09 173820 Screenshot 2026-04-09 173918

Which Barcode to Scan?

Screenshot 2026-04-09 174020

About

using ingredient lists and AI models to check if the food is healthy or not

Topics

Resources

License

Stars

Watchers

Forks

Contributors