Skip to content

abhi-jithb/NutriDecide

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

52 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ₯— NutriDecide β€” Personalized Food Intelligence App

Beyond calories. Beyond macros. Built for YOU.

Flutter Firebase Dart Node.js MongoDB Status


A Flutter-based health intelligence app that scans packaged food products and delivers a personalized suitability verdict based on your unique health profile, goals, and medical conditions. Features Offline-First Hive DB, Cloud Firestore profile sync, Admin-Approved Global Product Registry, and Manual Product Submission.



πŸ“„ Technical Documentation

For an in-depth deep dive into the system architecture, data flow, performance optimizations, and admin workflow, see LEARN.md.


πŸš€ Project Vision

Most nutrition apps just show you numbers. NutriDecide reasons about them.

  • πŸ“Έ 1-Tap Scan: Instant food analysis via barcode
  • 🧠 Inference Engine: Cross-references nutrients with your personal health DNA
  • 🎯 Offline-First: 20,000 foods indexed locally via Hive (O(1) lookup)
  • ☁️ Cloud Sync: Profile persistence via Firebase Firestore
  • πŸ”„ Community-Driven Database: Users submit unknown products β†’ Admins approve β†’ Available globally
  • πŸ›‘οΈ Admin System: Role-based admin panel for product review and user management

πŸ” Core Product Flow

 Scan Barcode
      β”‚
      β–Ό
 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
 β”‚  1. Check user's custom_products/{barcode}   β”‚
 β”‚  2. Check global_products/{barcode}          β”‚
 β”‚  3. Check local Hive DB (20k foods)          β”‚
 β”‚  4. Check Open Food Facts API               β”‚
 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
      β”‚                        β”‚
   Found                   Not Found
      β”‚                        β”‚
      β–Ό                        β–Ό
  Analyze &             β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  Show Verdict          β”‚ Try Again   β”‚
                        β”‚ Add Manuallyβ”‚
                        β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
                               β”‚
                               β–Ό
                    Save to pending_products/{barcode}
                    Save to user custom_products/{barcode}
                               β”‚
                               β–Ό
                     Admin Reviews & Approves
                               β”‚
                               β–Ό
                    Moved to global_products/{barcode}
                               β”‚
                               β–Ό
                    βœ… Available to ALL users forever

✨ Key Features

πŸ” Smart Barcode Scanning

  • Camera-based barcode detection with mobile_scanner
  • 4-phase fallback data acquisition (Custom β†’ Global β†’ Hive β†’ API)
  • Automatic caching of API results for future offline use

🧠 Personalized Health Verdicts

  • Weighted Risk Algorithm that factors in diabetes, hypertension, PCOS, allergies
  • Specialized Gym/Fitness Mode with protein density scoring
  • Vegan/Vegetarian dietary compliance checks
  • Instant allergen detection with fail-safe blocking

✍️ Manual Product Entry (Barcode-Linked)

  • When a scan finds no data, users can contribute product information
  • Barcode is the primary key β€” no random UUIDs
  • Saves to both pending_products (for admin review) and custom_products (for immediate user access)
  • Duplicate barcode detection prevents duplicates
  • Validation: Sugar (0–100g), required fields enforced

πŸ›‘οΈ Admin Panel

  • Role-based access β€” visible only when users/{uid}.role == "admin"
  • Pending Products tab β€” real-time stream with live count badge
  • Approve β†’ copies full document from pending_products to global_products (batch write)
  • Reject β†’ deletes from pending_products
  • Users tab β€” list all users with health profiles and conditions
  • Fresh Firestore read on approve to prevent data loss from stale snapshots

πŸ‘€ User Profiles (Health DNA)

  • Complete health profile: age, weight, height, conditions, allergies, diet type
  • Synced to Cloud Firestore for multi-device access
  • Role field (user | admin) for access control

πŸ“Š Scan History & Daily Logs

  • Scan history persisted in users/{uid}/history
  • Recent scans displayed on home screen
  • Full history view with streak tracking

πŸ“¦ Tech Stack

Technology Purpose
πŸ’™ Flutter Cross-platform UI framework
🐝 Hive High-performance offline food database (O(1) barcode lookup)
πŸ”₯ Firebase Auth User authentication
☁️ Cloud Firestore User profiles, pending/global products, scan history
🟒 Node.js Optional regional food API server
πŸƒ MongoDB Optional backend data store
πŸ›‘οΈ DotEnv Secure credentials management

πŸ—οΈ Getting Started

1️⃣ Clone the Repository

git clone git@github.com:abhi-jithb/NutriDecide.git
cd NutriDecide

2️⃣ Install Dependencies

flutter pub get

3️⃣ Configure Firebase

  • Ensure android/app/google-services.json is present
  • Create a .env file in root:
BACKEND_URL=https://your-api.onrender.com/api

4️⃣ Run the App

flutter run

5️⃣ Make Yourself Admin

In Firebase Console β†’ Firestore β†’ users/{your-uid} β†’ set field:

{ "role": "admin" }

πŸ—οΈ Project Architecture

lib/
β”œβ”€β”€ app.dart                          # MaterialApp with theme management
β”œβ”€β”€ main.dart                         # Entry point
β”œβ”€β”€ core/
β”‚   β”œβ”€β”€ data/
β”‚   β”‚   β”œβ”€β”€ food_database_service.dart   # Hive-based offline food DB
β”‚   β”‚   └── admin_repository.dart        # Admin Firestore operations
β”‚   β”œβ”€β”€ theme/app_theme.dart             # Material 3 design system
β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”œβ”€β”€ app_initializer.dart         # Parallel boot sequence
β”‚   β”‚   └── global_error_handler.dart    # Production crash protection
β”‚   └── presentation/splash_screen.dart
β”œβ”€β”€ features/
β”‚   β”œβ”€β”€ admin/
β”‚   β”‚   └── admin_panel_screen.dart      # Admin review panel (approve/reject)
β”‚   β”œβ”€β”€ auth/
β”‚   β”‚   β”œβ”€β”€ services/auth_service.dart
β”‚   β”‚   └── presentation/               # Login, Signup, Profile Setup
β”‚   β”œβ”€β”€ scan/
β”‚   β”‚   β”œβ”€β”€ scan_screen.dart             # Camera scanner
β”‚   β”‚   β”œβ”€β”€ models/
β”‚   β”‚   β”‚   β”œβ”€β”€ nutrition_data.dart      # Product data model
β”‚   β”‚   β”‚   └── scan_history_item.dart
β”‚   β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”‚   β”œβ”€β”€ nutrition_service.dart   # 4-phase data lookup
β”‚   β”‚   β”‚   β”œβ”€β”€ scoring_engine.dart      # Risk score calculator
β”‚   β”‚   β”‚   └── ingredient_analyzer.dart # Additive detection
β”‚   β”‚   β”œβ”€β”€ data/scan_repository.dart    # Scan history persistence
β”‚   β”‚   └── presentation/
β”‚   β”‚       β”œβ”€β”€ verdict_screen.dart      # Results display
β”‚   β”‚       β”œβ”€β”€ manual_entry_screen.dart # Manual product form
β”‚   β”‚       └── history_screen.dart      # Scan history
β”‚   β”œβ”€β”€ home/home_screen.dart            # Dashboard
β”‚   β”œβ”€β”€ profile/                         # Health DNA profile
β”‚   β”œβ”€β”€ settings/settings_screen.dart    # Preferences + admin access
β”‚   └── navigation/bottom_nav_screen.dart

πŸ” Firestore Collections

Collection Purpose Access
users/{uid} User profile + role Owner only (admin can read all)
users/{uid}/history/{id} Scan history Owner only
users/{uid}/custom_products/{barcode} User's pending submissions Owner only
pending_products/{barcode} Products awaiting admin review Auth create, Admin read/delete
global_products/{barcode} Admin-approved products Auth read, Admin write

πŸ“œ Changelog

πŸ“… 2026-03-29: V3.0 β€” Admin System & Community Products

  • Manual Product Entry: Barcode-linked form with validation and duplicate detection
  • Admin Panel: Two-tab admin interface with real-time pending count badges
  • Global Product Registry: Admin approve/reject workflow with batch Firestore writes
  • Role Management: user/admin roles via Firestore with conditional UI rendering
  • 4-Phase Lookup: custom_products β†’ global_products β†’ Hive β†’ Open Food Facts API
  • Firestore Security Rules: Full coverage for all new collections with admin guard functions
  • Safety Fixes: Fresh Firestore read on approve, duplicate barcode guard on submit

πŸ“… 2026-03-24: V2.0 β€” Production Hardening

  • Hive Migration: Replaced JSON loading with binary-indexed Hive boxes for O(1) lookup
  • Cloud Architecture: Firebase Auth + Cloud Firestore for multi-device profile sync
  • UX Optimization: 1-Tap Scan logic with auto scanner restarts
  • Crash Protection: GlobalErrorHandler and error boundaries
  • Legal Compliance: Medical Disclaimer and Privacy Policy screens

πŸ“… 2026-03-11: V1.5 β€” Offline Architecture

  • Offline Data System: Native scan against local dataset
  • Ingredient Analyzer: Advanced regex for red-line additives (MSG, E-numbers)
  • Gym Mode: Specialized auditing for sweeteners and protein density

πŸ₯— NutriDecide Β· Community-Driven Health Intelligence Β· Built with Flutter & Firebase

Preventive health, reimagined.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors