DEV Community

duchu.nft
duchu.nft

Posted on AI-assisted

SafePlate: an Offline Allergy Meal Planner Running Local Gemma 3 (Built for My Roommate)

Hacktoberfest Weekend Challenge: Build for a Friend Submission 🤝

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

What I Built

SafePlate — an allergy-aware meal planner for my roommate, who is allergic
to peanuts and shrimp. He told me weeknight cooking is the worst part of his
day: after work, standing in a noisy dorm kitchen trying to invent dinner that
won't send him to the clinic.

SafePlate takes his allergies, household size, and who he's cooking for
(student / gym-goer / senior), then generates a 7-day Vietnamese dinner plan
with ingredients, steps, a per-day nutrition note, and a consolidated shopping
list. The UI is bilingual (Vietnamese / English).

The whole thing runs on his laptop, offline: open-weight Gemma 3 4B
served locally by llama.cpp. No accounts, no cloud, no tracking, no per-token
bill.

I handed it to him on day one. His words (translated from Vietnamese):

"Pretty useful — normally I have to come up with meals myself, total headache."

His feedback shaped v2 the same evening: "menus need more variety — different
kinds of people, still nutritionally balanced."
So I added the audience
selector and the nutrition note. That loop — real person, real complaint, shipped
the same night — is the whole point of this challenge.

Demo

UI (Vietnamese mode, his actual allergies checked):

SafePlate form

Result generated 100% locally by Gemma 3 4B:

SafePlate result

Quick walkthrough:

SafePlate demo

No deployed link — and that's deliberate: the app is designed to work with the
wifi off. The demo above ran on a laptop in airplane mode.

Code

https://github.com/duchuAz/safeplate

Stack: one Python file serving the UI + a /plan endpoint, one static HTML
page, one prompt builder. The model backend is stock llama-server with a
local GGUF (ggml-org/gemma-3-4b-it-Q4_K_M).

How I Built It

Open-source AI is not a garnish here — it is the product:

  • Open weights (Gemma 3 4B, Apache-style Gemma license): downloaded once, runs forever. I started on the 1B quant for speed, then swapped to 4B by changing one file path. Try doing that with a closed API.
  • Open runtime (llama.cpp): CPU inference on an ordinary Windows laptop (~5–10 tok/s for 4B) — no GPU, no vendor lock-in, fully inspectable.
  • Deterministic guardrails around a small model: a 4B model sometimes "helpfully" suggests shrimp to a shrimp-allergic user, or returns malformed JSON. So generation runs under a JSON grammar, with retries, plus a rule-based allergen filter (including common misspellings) that drops unsafe dishes before they ever reach the screen. Small open models are honest about their limits — you can see exactly where they end and your code begins.

Everything was built Oct 2–4, 2026, in this repo. Nothing predates the window.

Why Does Open Innovation Matter?

Three reasons, all concrete:

  1. Privacy. Allergy and health data never leaves the laptop. There is no server to breach, subpoena, or acqui-hire. For health-adjacent software, "trust us" is not an architecture — no data is.
  2. Offline reality. His dorm wifi dies regularly. A closed API turns this app into a loading spinner; a local model turns dead wifi into a non-event. I verified with airplane mode on.
  3. Cost and control. $0 to run, forever — this matters for a student. And when a better open Vietnamese-capable model drops, it's a file swap, not a migration.

A closed model would have written prettier Vietnamese on day one. It would also
have uploaded my friend's health profile to someone else's computer, billed per
dinner plan, and stopped working the moment the wifi did. That's a bad trade,
and it's exactly the trade open weights let you refuse.

Prize Categories

  • Best Use of Gemma

Top comments (0)