DEV Community

Jerrie Adah
Jerrie Adah

Posted on

SafeBite AI: Allergy-Aware Meal Planner Agent Powered by Mastra & Gemini

Hacktoberfest: Contribution Chronicles

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


Check it out

SafeBite AI โ€” Allergy-Aware Agentic Meal Planner


Inspiration

Planning daily meals while managing food allergies or strict dietary restrictions is a constant source of stress for my friend who is very selective because of allergies. Standard recipe generators often output unsafe suggestions or fail to spot hidden allergen risks (such as dairy derivatives in pre-packaged items or peanut cross-contamination).

I created SafeBite AI to solve this problem with true agentic reliability. Powered by Mastra AI and Google Gemini, SafeBite doesn't simply prompt a static LLMโ€”it runs an autonomous agent that screens pantry ingredients through real-time tool checks before generating a verified recipe.


๐Ÿ“ธ Proof of Functionality & Screenshots

1. Interactive Dashboard & Restrictions Selector

Users select active dietary restrictions (e.g., Peanuts, Dairy) and specify available pantry ingredients along with a maximum prep time limit.

Interactive dashboard

Check out the demo: https://safebite-agent.onrender.com/

2. Autonomous Agentic Output & Recipe Verification

The Mastra agent validates ingredients against all listed restrictions and generates a structured, step-by-step recipe ("Quick Garlic Chicken & Wilted Spinach Rice Bowl").

detailed recipe


What It Does

  • Dynamic Restriction & Pantry Inputs: Allows users to toggle active allergens (Peanuts, Tree Nuts, Dairy, Eggs, Soy, Gluten, Shellfish, Fish) and input exact pantry items.
  • Autonomous Ingredient Screening: The safeBiteAgent leverages Mastra's tool-calling engine to execute allergenCheckerTool, inspecting every ingredient before finalizing the recipe.
  • Execution Telemetry: Displays live agent status badges and execution telemetry on the interface so users can confirm active safety validation.
  • Clear Markdown Recipes: Outputs comprehensive cooking instructions complete with prep time breakdowns, safe ingredient lists, and safety disclaimers.

How I Built It

  • Agent Framework: Mastra AI (@mastra/core) for agent instructions, tool binding, and runtime execution.
  • LLM Model Provider: Google Gemini (gemini-3.8-flash) via @ai-sdk/google.
  • Frontend & Design: Next.js 15 (App Router) with Tailwind CSS v4 dark mode and react-markdown.
  • Deployment Platform: Deployed directly as a Node.js web service on Render.

Challenges I Ran Into

  • Module Resolution & Build Errors: Configured PostCSS and Tailwind v4 to use .cjs extensions to handle Next.js ESM module constraints ("type": "module").
  • AI SDK Compatibility: Resolved version specification mismatches between @mastra/core and @ai-sdk/google to enable seamless tool calling with agent.generate().
  • Production Build Dependencies: Adjusted dependency configurations to ensure Render's automated build pipeline cleanly installs @tailwindcss/postcss.

Accomplishments

  • True Tool-Driven Workflow: Built an AI agent that actively invokes validation tools instead of relying solely on raw text generation.
  • Seamless Render Deployment: Successfully hosted the application at safebite-agent.onrender.com with automated builds and fast response times.

Prize Category Submissions

  • Best Use of Mastra: Architected using Mastra's core Agent framework, custom tool orchestration (allergenCheckerTool), and execution telemetry.
  • Best Use of Render: Deployed and actively running in production as a Render Web Service.

Top comments (0)