DEV Community

razorbill
razorbill

Posted on

DormChef: Midnight Pantry Rescue for Abhishek (Built with Gemma 2 & Ollama)

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


The Friend & The Problem

Meet my friend and hostel roommate, Abhishek. Like many engineering students, Abhishek hits the gym regularly and tries to stay consistent with his daily protein intake.

Hostel life makes that tricky. By late evening, the dining mess is closed, takeout is either unhealthy or completely out of a student budget, and in-room cooking tools are strictly constrained.

Whenever he searches online for quick recipes, standard cooking apps assume access to a four-burner stove, an oven, and fresh groceries. Worse, general AI models often give dangerous advice. They often suggest cracking raw eggs directly over bare electric kettle heating coils, which burns out the element, sparks a short circuit, and risks hostel fines.

I built DormChef specifically for Abhishek to rescue midnight meals from random pantry items while respecting real hostel appliance limits and safety constraints.


What I Built

DormChef is an offline-first, local AI culinary assistant built for minimal dorm setups.

  • Adaptive Appliance Support: While Abhishek's daily room defaults are an electric kettle and a sandwich toaster, DormChef also supports induction plates or no-cook (assembly only) situations.
  • Flexible Dietary Priorities: Abhishek can pivot between goals depending on the night: High protein, Ready in 5 minutes, Comfort food, or Cheap (budget survival), alongside an adjustable spice dial.
  • Hardware-Safe Generation: The system prompt enforces strict safety boundaries: it forbids dropping solid food or eggs directly into electric kettle elements (suggesting hot-water bath poaching or mug steeping instead) and advises greaseproof wrapping inside sandwich toasters to avoid messy spills.
  • Editorial Slip Interface: The generated recipe streams token-by-token directly onto a clean, distraction-free receipt slip, complete with macro estimates and a practical "Heads-up" safety tip.

Demo

DormChef interface setup

DormChef recipe output with safety heads-up

DormChef in action: translating 3 eggs, brown bread, and an electric kettle into a realistic, high-protein meal without endangering the kettle coil.


Why Open Innovation Matters

The prompt asks why an open-based approach works better than a closed one, and for dorm life, the answer is practical:

  1. Hostel Wi-Fi Independence: College Wi-Fi in our dorms frequently drops or throttles past midnight. A closed cloud API is useless without an active internet connection. Because DormChef runs locally via Ollama, it functions 100% offline.
  2. Zero Cost for Students: College students cannot afford $20/month AI subscriptions or recurring per-token API charges just to figure out how to cook eggs and bread. Open-weight models ensure reliable, free access.
  3. Hardware-Safe Behavioral Alignment: By leveraging Google's Gemma 2 (2B) open weights, we can align the system instructions specifically around dorm appliance safety without running into cloud rate limits or latency bottlenecks.

The Two-Stage Allergen & Safety Filter

Small language models (like 2B parameter weights) often struggle to strictly follow negative constraints. Asking the model "don't use dairy" will often still result in a recipe with butter.

To prevent this, DormChef uses a two-stage filter built into the Python application layer:

  1. Pre-filter (Input sanitization): Before the prompt reaches the model, Python scans the pantry items against common allergen groups (dairy, eggs, peanuts, tree nuts, gluten, soy, fish, shellfish). Any matching ingredient is stripped out automatically, and the UI notifies the user.
  2. Post-filter (Verification): When Gemma 2 streams the finished recipe, the text is re-scanned. If a blocked word somehow slipped through, a prominent warning is displayed.

How I Built It & The Tech Stack

  • Model: Google Gemma 2 (2B) running locally via Ollama. It operates comfortably on a laptop GPU (taking ~1.6 GB VRAM) and streams responses almost instantaneously.
  • Frontend: Streamlit with custom ivory-slip styling and real-time token streaming.
  • Safety Logic: Python regex filters that catch and remove allergens before the prompt reaches Gemma, with a secondary check on the output.

Handing It Over: What Abhishek Said

I had Abhishek test it using the basic pantry items in our room. When he entered dairy as an allergy, the app removed butter and instructed him to poach the egg mixture inside a heatproof bowl set into the boiling kettle water instead of cooking raw egg directly against the coil:

"The bowl in boiling water idea is clever; our kettle doesn't get messed up, and it runs without needing hostel Wi-Fi."


Prize Categories

  • Best Use of Gemma (Google's open-weight model running locally)

Code Repository

GitHub: https://github.com/Razorbillworks/dormchef

Top comments (0)