Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

115 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ₯— SafeBite

Scan Smart. Eat Safe. Live Well.

SafeBite is a mobile-first HealthTech app built with React Native. Scan a barcode, snap an ingredients label with no barcode at all, or photograph a restaurant menu β€” and get an AI-powered safety analysis personalised to your medical profile: allergies, chronic conditions, medications, and your whole family.

What makes SafeBite different: it checks food against your medications and conditions, not just calories β€” and it works even when a product isn't in any barcode database.


πŸ’‘ Problem Statement

Ensuring food safety is hard for both consumers and shopkeepers:

  • People with allergies, diabetes, heart disease or other conditions can't easily verify whether a food is safe for them.
  • People on medication are unaware of dangerous food–drug interactions hiding in everyday products.
  • Most barcode scanners hit a dead end when a product isn't in the database β€” common for local, loose, or small-brand foods.
  • Eating out is the scariest scenario for allergy/medication users, with no easy way to vet a menu.
  • Families have no way to check safety across multiple health profiles in one scan.
  • Shopkeepers overlook stock and expiry management, causing waste and risk.

Per WHO, anaphylaxis-related deaths are rising. SafeBite puts clinical-grade food safety in everyone's hands.


✨ Features

πŸ” Three ways to scan

Feature Description
Barcode / QR Scan EAN13, EAN8, QR, Code128, UPC-A/E and more β†’ full product info + AI safety verdict
πŸ“Έ Snap the Label No barcode (or not in the database)? Photograph the ingredients list β€” a vision model reads it and runs the same safety pipeline. Works for any packaged food
🍽️ Eat-Out Menu Scanner Photograph a restaurant menu β€” every dish is rated Safe / Caution / Avoid for your profile, sorted worst-first

πŸ›‘οΈ Personalised safety

  • 🧠 AI Ingredient Analysis β€” a personalised summary based on your allergies, conditions, diet and medications.
  • πŸ’Š Medication Γ— Food Interaction Alerts β€” detects dangerous combos (Warfarin + leafy greens, Statins + grapefruit, …) with prominent warnings. Re-checked deterministically on-device, not just by the model.
  • ⚠️ Deterministic Allergen Matching β€” a synonym map so a "Nuts" allergy is flagged by "almond"/"peanut", not only the literal word.
  • πŸ‘¨β€πŸ‘©β€πŸ‘§ Family Profiles β€” one account, multiple health profiles; switch the active profile with one tap and every AI flow adapts.

πŸ”” Proactive recall alerts

SafeBite doesn't stop protecting you when you close the app. It remembers every product you've scanned and cross-checks them against the live openFDA food recall feed. If a product you've scanned gets recalled, you get a push notification β€” even with the app closed β€” and a red alert banner on Home.

  • πŸ“‘ Live recall monitoring β€” matches your scanned products against official recall data on every app open.
  • 🎯 Profile-aware severity β€” if the recall reason (e.g. "undeclared peanuts") matches the active profile's allergies, the alert is escalated with a "do not eat" warning tied to that person.
  • πŸ›Œ Works in the background β€” be warned about food already in your kitchen before you eat it.

πŸ€– Sage β€” AI Health Co-pilot

Sage is a conversational assistant (powered by Google Gemini) you can ask anything β€” "Can I eat this with my warfarin?", "What should I avoid today?", "Suggest a safe snack." It's grounded in your active health profile (allergies, conditions, medications, diet) and your recently scanned products, so every answer is personal β€” not generic. Reachable from the Ask Sage button on Home β€” or tap Ask Sage about this on any product to start a chat focused on that exact item.

β™Ώ Accessibility

  • πŸ”Š Read-aloud verdict β€” enable it from Profile β†’ Accessibility, and a Listen button appears on every product to read the whole safety verdict aloud (name β†’ allergens β†’ medication interactions β†’ AI summary), so low-vision, elderly, or hands-busy users can hear whether a food is safe. The co-pilot's answers can be read aloud too.

🍳 Eat better

  • Recipe Suggestions β€” enter the ingredients you have β†’ health-safe recipes that respect your allergies, diet, conditions and medications.
  • 7-Day Meal Planner β€” a profile-safe weekly plan plus an auto shopping list.
  • Healthier Swaps β€” scan a poorly-rated product and get safer, better-rated alternatives from a 5,000-product database.
  • Smart Recommendations β€” AI-filtered products matched to your full health profile.

πŸ“Š Track & stay motivated

  • Daily Health Score β€” a 0–100 score from today's logged food vs. your condition-adjusted limits.
  • Safe-Eating Streak β€” consecutive qualifying days, to build the habit.
  • Nutrition Tracker & Food Diary β€” calories, sugar, fat, salt, protein vs. personalised limits that auto-tighten for your conditions.
  • 7-Day Trends β€” a per-day sugar & salt chart with a plain-language read ("your sodium is trending up"), so the tracker shows movement over time, not just today's snapshot.

🩺 Clinical companion

  • πŸ’Š Food Γ— Medication cross-link at log time β€” when you add a food to your diary that interacts with one of your medications (e.g. grapefruit while on a statin), SafeBite flags it the moment you log it, tags the diary entry, and shows a daily "items that interact with your medication" banner.
  • ⏰ Medication reminders with food-timing warnings β€” schedule a daily dose reminder for each medication; the notification also names the foods to avoid around that dose (e.g. "Time for your statin β€” avoid grapefruit within a few hours"), turning the food–drug interaction map into a proactive nudge. Reminders are profile-aware and stay in sync as you edit your medications.
  • πŸ“„ Export Health Report (PDF) β€” generate a shareable 7-day report β€” health profile, personalised daily limits, food diary grouped by day, and every flagged food–medication interaction β€” and send it straight to your doctor or dietitian from the native share sheet. Positions SafeBite as a clinical companion, not just a scanner.

🏠 Home & convenience

  • Recently Scanned carousel β€” reopen recent products instantly (offline-friendly).
  • Personalised Daily Tip β€” rotates based on your medications/conditions/allergies.
  • Offline Scan Cache β€” last 50 products + AI summaries cached locally; works with no signal.

πŸ‘€ Account & settings

  • Edit Health Profile β€” update allergies, conditions, diet, medications, age & severity anytime.
  • Change Password (Supabase auth), Privacy Policy, Share SafeBite, and β˜• Support us.

πŸͺ For shopkeepers

  • Inventory Management β€” add / edit / delete products (name, price, stock, rating, expiry, image), stored per-shopkeeper in Supabase with row-level security.
  • Insights Dashboard β€” live stats (total / out-of-stock / expiring-soon), search, and colour-coded stock & expiry badges.

🧠 Tech Stack

Layer Technology
Mobile Frontend React Native (Expo 54), TypeScript, expo-router
Styling NativeWind (Tailwind CSS), React Native Reanimated
Camera & Imaging expo-camera, expo-image-picker, expo-image-manipulator
Notifications expo-notifications (local push for recall alerts)
Accessibility expo-speech (read-aloud safety verdict)
Reporting expo-print + expo-sharing (PDF health report export)
Backend Node.js + Express.js (deployed on Render, with keep-alive ping)
AI β€” Text Groq: llama-3.1-8b-instant (summaries), llama-3.3-70b-versatile (recommendations, recipes, meal plans)
AI β€” Vision Groq: meta-llama/llama-4-scout-17b-16e-instruct (label & menu reading)
AI β€” Co-pilot Google Gemini (gemini-2.5-flash) β€” conversational health assistant
Database & Auth Supabase (PostgreSQL + Auth, row-level security)
Local Storage AsyncStorage β€” offline cache, active profile, streak, reco cache
Product Data Open Food Facts API
Recall Data openFDA Food Enforcement API
Build EAS (Expo Application Services)

πŸ—„οΈ Database Schema

Supabase tables that power the app:

Table Purpose
Users Account info, shopkeeper flag
Customerdetails Health profile β€” allergies, conditions, medications, dietary
Shopkeepers Business details for shopkeeper accounts
family_members Additional health profiles per account
nutrition_logs Daily food diary entries per user (incl. med_flags β€” see supabase/nutrition_logs_med_flags.sql)
recommended_products Profile-hash keyed cache for AI recommendations
shop_products Per-shopkeeper inventory (RLS-scoped) β€” see supabase/shop_products.sql

πŸ§ͺ How it works

  1. Three capture modes β€” barcode (Open Food Facts), label photo (vision OCR), menu photo (vision).
  2. Vision pipeline β€” photos are downscaled on-device, then a Groq vision model extracts ingredients (label) or rates dishes (menu); the heavy lifting runs on Groq, so the free-tier backend only proxies.
  3. Rule + LLM safety β€” deterministic allergen/medication matching layered with LLM summaries (defence in depth).
  4. Profile-hash caching β€” avoids re-running AI for the same health profile.
  5. Condition-aware limits β€” daily nutrition thresholds tighten automatically per condition, feeding the tracker and health score.
  6. Family architecture β€” the active profile is persisted in AsyncStorage and drives every AI flow.
  7. Offline-first β€” scans, recommendations and tips fall back to local cache.
  8. Recall monitoring β€” on each app open, scanned products are matched against the openFDA recall feed; a match fires a local push and a Home banner, escalated when the recall reason hits the active profile's allergies.

πŸ“ Project Structure

SafeBite/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ _layout.tsx              # Root stack navigator
β”‚   β”œβ”€β”€ index.tsx                # Splash / auth check
β”‚   β”œβ”€β”€ family.tsx               # Family profiles management
β”‚   β”œβ”€β”€ edit-health.tsx          # Edit health profile
β”‚   β”œβ”€β”€ privacy.tsx              # Privacy policy
β”‚   β”œβ”€β”€ label-scan.tsx           # πŸ“Έ Snap-the-label (vision)
β”‚   β”œβ”€β”€ menu-scan.tsx            # 🍽️ Eat-out menu scanner (vision)
β”‚   β”œβ”€β”€ copilot.tsx             # πŸ€– Sage β€” AI Health Co-pilot chat (Gemini)
β”‚   β”œβ”€β”€ med-reminders.tsx        # ⏰ Medication dose reminders + food-timing warnings
β”‚   β”œβ”€β”€ shop_interface.tsx       # Shopkeeper inventory (CRUD)
β”‚   β”œβ”€β”€ (auth)/                  # login, signup, onboarding
β”‚   β”œβ”€β”€ (tabs)/
β”‚   β”‚   β”œβ”€β”€ home.tsx             # Scan toggle, recommendations, recently scanned, tip
β”‚   β”‚   β”œβ”€β”€ tracker.tsx          # Health score, streak, nutrition tracker, food diary
β”‚   β”‚   β”œβ”€β”€ recipes.tsx          # Recipe suggestions + meal planner
β”‚   β”‚   └── profile.tsx          # Settings: account, support, about, health profile
β”‚   β”œβ”€β”€ product/[id].tsx         # Product detail β€” AI summary, med warnings, swaps, log
β”‚   └── scan/index.tsx           # Barcode / QR scanner
β”œβ”€β”€ services/                    # All client services (profile-aware)
β”‚   β”œβ”€β”€ summary.ts  recommendation.ts  familyProfile.ts  nutritionLog.ts
β”‚   β”œβ”€β”€ scanCache.ts  recipes.ts  alternatives.ts  healthScore.ts
β”‚   β”œβ”€β”€ healthTip.ts  labelScan.ts  menuScan.ts  shopProducts.ts
β”‚   β”œβ”€β”€ healthReport.ts  settings.ts
β”‚   β”œβ”€β”€ recall.ts                # recall matching against openFDA + scanned products
β”‚   β”œβ”€β”€ notifications.ts         # local push + daily-scheduled notifications (expo-notifications)
β”‚   β”œβ”€β”€ medReminder.ts           # medication dose reminders + food-timing warnings
β”‚   β”œβ”€β”€ copilot.ts               # AI co-pilot client (sends profile + scans to Gemini)
β”‚   β”œβ”€β”€ speech.ts                # read-aloud verdict (expo-speech)
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ server.js
β”‚   β”œβ”€β”€ routes/                  # summary, recommendation, recipes,
β”‚   β”‚                            # alternatives, scanLabel, scanMenu, copilot
β”‚   β”œβ”€β”€ controller/copilotController.js  # Gemini chat co-pilot (consultCopilot)
β”‚   β”œβ”€β”€ controller/aiController.js  # Groq text + vision (askAI, consultAi,
β”‚   β”‚                                # generateRecipes, generateMealPlan,
β”‚   β”‚                                # analyzeLabelImage, analyzeMenuImage)
β”‚   └── utils/                   # hashProfile, scraper
β”œβ”€β”€ constants/                   # const, medicationInteractions,
β”‚   β”‚                            # nutritionLimits, allergenKeywords
β”œβ”€β”€ components/                  # recomentation, RecipeCard, NutritionTrends
β”œβ”€β”€ supabase/shop_products.sql   # Shopkeeper inventory table + RLS
└── lib/                         # supabase, auth, actions

πŸ”Œ Backend API

Endpoint Purpose
GET /health Health check / keep-alive
POST /api/summary AI product safety summary
POST /api/recommendation Profile-matched product recommendations
POST /api/recipes Health-safe recipes from ingredients
POST /api/recipes/mealplan 7-day profile-safe meal plan + shopping list
POST /api/alternatives Healthier, profile-safe product swaps
POST /api/scan-label Vision: read an ingredients label into product data
POST /api/scan-menu Vision: rate menu dishes for the profile
POST /api/copilot Conversational health co-pilot (Gemini), grounded in profile + recent scans

πŸ“¦ Run Locally

git clone https://github.com/Ajay-Krishna00/SafeBite
cd SafeBite

Frontend .env:

EXPO_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
EXPO_PUBLIC_SUPABASE_ANON_KEY=your-anon-key

backend/.env:

PORT=3000
EXPO_PUBLIC_PROJECT_URL=https://your-project.supabase.co
EXPO_PUBLIC_PUBLIC_ANON_KEY=your-anon-key
GROQ_API_KEY3=your-groq-key
GEMINI_API_KEY=your-gemini-key

The co-pilot uses GEMINI_API_KEY (Google AI Studio). Optionally override the model with GEMINI_MODEL (defaults to gemini-2.5-flash).

Start the app & backend:

npm install
npx expo start

cd backend && npm install && node server.js

Run supabase/shop_products.sql once in the Supabase SQL editor to enable shopkeeper inventory, and supabase/nutrition_logs_med_flags.sql to enable medication-interaction flags on diary entries. The deployed backend base URL is configured in the client services/.


πŸ”’ Security & Privacy

  • Supabase JWT auth with secure token refresh.
  • Health data stored per-user with auth-scoped access; shopkeeper inventory protected by row-level security.
  • Active family profile and streak stored only in device-local AsyncStorage.
  • Vision requests send only the photo + non-identifying health constraints; nothing is sold. See the in-app Privacy Policy.

πŸ“ˆ Roadmap

  • βœ… Medication Γ— Food Interaction Alerts
  • βœ… Nutrition Tracker, Health Score & Streak
  • βœ… Family Profile Switching
  • βœ… Offline Scan Cache
  • βœ… Recipe Suggestions & 7-Day Meal Planner
  • βœ… Healthier Product Swaps
  • βœ… Snap-the-Label (vision scanning, no barcode needed)
  • βœ… Eat-Out Menu Scanner
  • βœ… Shopkeeper Inventory Management
  • βœ… Allergen Recall & Push Notifications
  • βœ… Sage β€” AI Health Co-pilot (conversational, Gemini-powered)
  • βœ… Read-aloud / accessibility verdict
  • βœ… Food Γ— Medication cross-link at log time
  • βœ… Export Health Report (PDF) for doctors / dietitians
  • βœ… Medication reminders with food-timing warnings
  • βœ… 7-day nutrition trends (sugar & salt)
  • πŸ”œ Customer-facing "safe for me" shop view

β˜• Support

If SafeBite helps you, consider supporting development: buymeacoffee.com/ajaykrishnad


πŸ‘₯ Team β€” Code Blooded

  • Ajay Krishna D
  • Abhay Murali M
  • Thaariq Hassan R

🧾 License

MIT License β€” free for personal and educational use.


"Health isn't just about what you eat β€” it's about knowing what you're about to eat. SafeBite gives you that power: for every product, every menu, every member of your family β€” even without a barcode."

If you like this project, ⭐️ star it and share it with health-conscious friends!

About

Mobile-first HealthTech application built using React Native

Topics

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages