DEV Community

Divyansh Tiwari
Divyansh Tiwari

Posted on AI-assisted

SafePlate

This is a submission for the Hacktoberfest Weekend Challenge: Build for a Friend

What I Built

My friend Aarav is allergic to peanuts, tree nuts and dairy. Every time we eat out or grab a snack, the same thing happens. He flips the packet over, squints at the tiny print, and asks: "Is **lecithin* a soy thing? Is khoya dairy? Does 'may contain' count?"* Restaurants are worse. "Paneer butter masala" sounds harmless until you remember the gravy is usually thickened with cashew paste.

So I built SafePlate. You paste an ingredient label, a menu item or a recipe, and it tells you:

  • VERDICT: SAFE / CAUTION / AVOID for your allergy profile
  • which ingredients are a problem, including hidden and regional names (kaju, ghee, maida, til, mawa…)
  • any "may contain" or shared-facility warnings
  • practical swaps, or what to ask the waiter
  • answers to follow-up questions ("what can I use instead of cream here?")

Everything runs on his phone or laptop. There's no account, no API key and no server.

Demo

🔗 Live: https://divyansh2102t-dev.github.io/safeplate/

Open it in Chrome or Edge (it needs WebGPU). Click Load model once. After that it works offline.

Try the sample button. It loads a biscuit label with "milk solids, soya lecithin, may contain traces of cashew and peanut". The instant scanner flags those ingredients right away, and the local LLM then explains each one and suggests alternatives.

Code

GitHub logo divyansh2102t-dev / safeplate

Allergy checker for a friend, powered by an open-weight LLM running 100% in the browser (WebLLM)

🍽️ SafePlate

An allergy buddy that runs entirely in your browser. Paste an ingredient label, a restaurant menu item or a recipe, and SafePlate tells you whether it's safe for your allergies, what the hidden ingredients are, and what to swap.

Built for my friend Aarav (peanut, tree-nut and dairy allergies) for the Hacktoberfest Weekend Challenge: Build for a Friend.

👉 Live demo: https://divyansh2102t-dev.github.io/safeplate/

Why it's different

  • Open-weight LLM, running locally. Uses WebLLM (MLC) to run Qwen2.5 / Llama 3.2 / Phi-3.5 on your GPU via WebGPU. No API key, no server, no cost.
  • Your health data stays on your device. Allergy profile is saved in localStorage, label text never leaves the tab.
  • Works offline once the model is cached — perfect for basements, flights and dhabas with no signal.
  • Two layers of safety. A deterministic keyword scanner (with Indian label names like kaju, ghee, maida, paneer, til…

How I Built It

  • WebLLM (MLC AI, Apache-2.0) runs open-weight models directly in the browser using WebGPU.
  • Open-weight models: the default is Qwen2.5-1.5B-Instruct. You can also pick Llama 3.2 1B, Qwen2.5 0.5B for older phones, or Phi-3.5-mini for the smartest answers. They're in a dropdown, so changing models takes one line of code.
  • Two layers of safety. Small models explain things well, but I didn't want to rely on one remembering that ghee is dairy. So:
    1. A deterministic scanner (allergens.js) uses a synonym dictionary, including Indian label names and Hinglish, to highlight every match instantly. It works without the model.
    2. The LLM then gives the verdict, explains it, catches anything the dictionary missed, and suggests swaps. The system prompt tells it to answer CAUTION, never SAFE whenever it's unsure, and it runs at temperature 0.2.
  • The allergy profile is saved in localStorage. Answers stream token by token, and follow-up questions keep the chat history.
  • There's no framework and no build step: just index.html, app.js, allergens.js and style.css, hosted on GitHub Pages.

Why Does Open Innovation Matter?

For this project, open weights aren't just a nice extra. The app couldn't work the way it does without them:

  • Health data stays private. Someone's allergies are medical information. With a closed API, every label Aarav checked would be sent to someone else's server. Here, nothing leaves the browser tab.
  • It works where he actually needs it. Restaurant basements, flights, roadside dhabas with one bar of signal. Once the model is downloaded and cached, SafePlate runs fully offline. A cloud API fails exactly when you're hungry and unsure.
  • It's free to run. There's no API key to leak, no bill and no rate limit, so I can give it to every friend who has allergies.
  • I control how it behaves. I can pick a model size that suits his phone, tune the prompt to be cautious, and later fine-tune a small model on allergen data. No vendor can quietly change or retire the model.
  • Anyone can improve it. The repo is tagged hacktoberfest and has good first issues for adding allergen names in more Indian languages and E-number lookups. Every name someone adds makes it safer for everyone.

My Agent Session

I built this quickly with an AI coding agent helping with the scaffolding, the allergen dictionary and the WebLLM integration.

Prize Categories

This is an entry for the main challenge only.


⚠️ SafePlate is a second pair of eyes, not a doctor. Always read the real label and carry your epinephrine.

Top comments (0)