DEV Community

Punya Arora
Punya Arora

Posted on AI-assisted

SafeBite: An Allergen-Safe AI Recipe Generator (Hacktoberfest Submission)

Hacktoberfest: Contribution Chronicles

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

What I Built

I built SafeBite, an allergen-safe recipe generator. I made this for a close friend with severe Celiac disease. A hallucinated ingredient like standard soy sauce is a severe health hazard for them. SafeBite generates tailored recipes based on exactly what they have in their pantry. It enforces zero cross-contamination constraints at the system level.

Demo

You can try it live here: SafeBite on Render

Code

SafeBite

A strict, zero-hallucination allergen-safe recipe generator.

Hacktoberfest 2026

This project was built for the DevRelay Hacktoberfest challenge. We used four sponsor technologies to build the final production MVP:

  • Microsoft Azure: We provisioned a custom Standard_D2as_v4 Virtual Machine to host our own independent AI backend.
  • Gemma: We deployed gemma2:2b via Ollama on the Azure server. It handles the strict zero-shot recipe generation without the rate limits of 3rd-party APIs.
  • ElevenLabs: We wired up the text-to-speech API so users can click a button and listen to the recipes out loud.
  • MongoDB Atlas: Powers the database to securely store user allergen profiles and their personal Cookbook of saved recipes.
  • Render: We deployed the Next.js frontend to the live web.

The Architecture

Off-the-shelf APIs failed us. When dealing with severe food allergies like Celiac disease, hallucinating an ingredient is a critical failure. Early tests with 3rd-party hosted endpoints returned constant 500 errors and…

How I Built It

We initially routed our backend through a hosted LLM API. That led to constant 500 errors and unpredictable formatting. We needed reliability and low latency instead.

We pivoted to an independent infrastructure using Microsoft Azure and Gemma. We provisioned an Azure Virtual Machine (Standard_D2as_v4 with 8GB RAM) and installed Ollama. We selected gemma2:2b because we were running on a CPU-only instance to save costs. Its small footprint allowed for fast local inference while following our recipe constraints.

We deployed our Next.js frontend to Render and pointed the Ollama SDK directly to our Azure IP. We integrated MongoDB Atlas to persist user allergen profiles and their personal Cookbook of saved recipes. Finally, we wired up the ElevenLabs TTS API so my friend can listen to the recipes while cooking.

The 2B model occasionally drops markdown headers. We wrote a resilient UI parser in Next.js to ensure the frontend never breaks:

const parseResponse = (text: string) => {
  // Clean up indentations and check for safety audits
  const cleanText = text.split('\n').map(line => line.trimStart()).join('\n');
  const hasSafetyAudit = cleanText.toLowerCase().includes("safety");

  let chunks = cleanText.split(/(?=^##?\s+)/m);

  if (chunks.length <= 1) {
    const parts = cleanText.split(/(?=\n\*\*Recipe|\nIngredients:)/im);
    if (parts.length > 1) chunks = [parts[0], parts.slice(1).join('\n')];
  }

  if (chunks.length <= 1 || !hasSafetyAudit) {
    return { safetyCheck: "", recipes: [{ title: "Generated Recipe", content: cleanText }] };
  }
};
Enter fullscreen mode Exit fullscreen mode

Why Does Open Innovation Matter?

Open innovation made this project work. Dealing with severe food allergies requires complete trust in the system. Running an open-weight model like Gemma 2 locally via Ollama on our own Azure server gave us total control over the inference parameters. We avoided API rate limits and kept my friend's dietary data completely private. A closed API would not allow us to deploy an isolated backend on a student budget.

My Agent Session

Pivoting SafeBite to Azure and writing a bulletproof Gemma UI parser
You

I am building a zero-hallucination allergen-safe recipe app for Hacktoberfest. But the 3rd-party hosted LLM API is returning constant 500 errors and hallucinates standard markdown formatting. What should we do?

Agent

We should pivot our architecture. Instead of relying on a flaky closed API, let's provision our own cloud infrastructure and host the model ourselves using an Azure Virtual Machine and Ollama. Because we want a fast CPU instance, gemma2:2b is perfect for this.

You

The output formatting is completely breaking down—Gemma 2 missed the headers and dumped the whole recipe into the Safety Audit box.

Agent

Because the 2B model is incredibly small, it sometimes hallucinates the markdown instructions. I will write a bulletproof UI parser in Next.js that gracefully falls back. If it doesn't contain the word 'Safety', we assume there is no safety check and treat the whole thing as a Recipe card.

Prize Categories

I am submitting this project for the following partner categories:

  • Best Use of Gemma (Powered by gemma2:2b via Ollama)
  • Best Use of MongoDB (Atlas used for user profiles and recipe persistence)
  • Best Use of Render (Next.js frontend deployed on Render)
  • Best Use of ElevenLabs (Text-to-Speech audio integration)

Top comments (0)