Skip to content

๐Ÿฅ— AI-powered Thai food nutrition analyzer with 8-dimension health scoring, 1000+ recipes, and bilingual support. Snap photos for instant nutrition insights, chat with AI nutrition coach, and get personalized meal plans. Next.js + FastAPI + Google Gemini AI.

License

Notifications You must be signed in to change notification settings

bejranonda/Nutri-Vision-AI

Repository files navigation

๐Ÿฅ— NutriVision AI - Smart Recipe Assistant for Modern Nutrition

npm version Thai Language License Status

AI-powered nutrition analysis and recipe assistant specialized in Thai cuisine. Helping Thai people make informed food choices through evidence-based nutrition science.

เธญเนˆเธฒเธ™เธ เธฒเธฉเธฒเน„เธ—เธข: README-TH.md


๐ŸŒŸ Features

Core Capabilities

  • ๐Ÿ” AI Food Recognition: Snap a photo and instantly identify ingredients using Google Gemini Vision API

  • ๐Ÿ“Š 8-Dimension Nutrition Scoring: Comprehensive health analysis including:

    • Blood Sugar Impact (crucial for Thai diet)
    • Gut Health Score
    • Inflammation Score
    • Nutrient Density
    • Processing Level
    • Protein Quality
    • Micronutrient Coverage
    • Overall Health Score
  • ๐Ÿœ Thai Food Specialization:

    • 1000+ Thai recipes with nutrition data
    • Common Thai ingredients database
    • Cultural context and traditional wisdom
    • Thai measurement conversions
  • ๐Ÿ’ฌ AI Nutrition Coach:

    • Chat with AI nutritionist in Thai or English
    • Evidence-based recommendations
    • Personalized advice based on your goals
  • ๐Ÿ“ฑ Mobile-First PWA:

    • Works like a native app
    • Offline mode for saved recipes
    • Quick camera access

Unique Thai Market Features

  • Blood Sugar Management: Specialized for Thai rice-heavy diet
  • Eating Sequence Education: Vegetables โ†’ Protein โ†’ Fat โ†’ Carbs โ†’ Sweets (70% blood sugar reduction)
  • Thai Payment Integration: PromptPay, TrueMoney, Rabbit Line Pay
  • Line Login: Popular Thai messaging app integration
  • Thai Language AI: Natural Thai conversation with nutrition AI

๐Ÿ—๏ธ Architecture

Tech Stack

Backend (Python)

  • FastAPI - Modern async API framework
  • PostgreSQL - Primary database
  • Redis - Caching and sessions
  • Google Gemini AI - Image recognition and chat
  • SQLAlchemy - ORM
  • Alembic - Database migrations

Frontend (TypeScript)

  • Next.js 14 - React framework with App Router
  • Tailwind CSS - Utility-first styling
  • next-intl - Internationalization (Thai + English)
  • TanStack Query - Server state management
  • Zustand - Client state management
  • Recharts - Data visualization

Infrastructure

  • Docker & Docker Compose - Containerization
  • Nginx - Reverse proxy
  • GitHub Actions - CI/CD

๐Ÿš€ Quick Start

Prerequisites

  • Docker and Docker Compose
  • Node.js 18+ and npm 9+
  • Git
  • Google Gemini API key (Get one here)

Installation

Option 1: Clone from GitHub (Recommended for Development)

  1. Clone the repository
git clone https://github.com/bejranonda/Nutri-Vision-AI.git
cd Nutri-Vision-AI

Option 2: Install via npm (For Quick Setup)

npx degit bejranonda/Nutri-Vision-AI my-nutrivision-app
cd my-nutrivision-app
npm install
  1. Set up environment variables
cp .env.example .env

Edit .env and add your credentials:

GEMINI_API_KEY=your_gemini_api_key_here
SECRET_KEY=your_secret_key_here  # Generate with: openssl rand -hex 32
JWT_SECRET_KEY=your_jwt_secret_here
  1. Start the application
docker-compose up -d
  1. Initialize database
# Run migrations
docker-compose exec backend alembic upgrade head

# Seed Thai food data
docker-compose exec backend python app/db/seed_data.py
  1. Access the application

๐Ÿ“– Usage

For Users

Scan Food

  1. Navigate to "เธชเนเธเธ™เธญเธฒเธซเธฒเธฃ" (Scan Food)
  2. Take a photo or upload an image
  3. Get instant nutrition analysis with 8-dimension scores
  4. View detailed ingredient breakdown

Ask AI Nutritionist

  1. Go to "เธ›เธฃเธถเธเธฉเธฒเธœเธนเน‰เน€เธŠเธตเนˆเธขเธงเธŠเธฒเธ" (Ask Expert)
  2. Type your question in Thai or English
  3. Get evidence-based answers
  4. Chat history is saved

Browse Recipes

  1. Visit "เธชเธนเธ•เธฃเธญเธฒเธซเธฒเธฃ" (Recipes)
  2. Filter by dietary needs
  3. View detailed nutrition scores
  4. Save favorites

Track Progress

  1. Access "เนเธ”เธŠเธšเธญเธฃเนŒเธ”" (Dashboard)
  2. View scan history
  3. Track nutrition trends
  4. Set health goals

For Developers

Run Backend Only

cd backend
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -r requirements.txt
uvicorn app.main:app --reload

Run Frontend Only

cd frontend
npm install
npm run dev

Run Tests

# Backend tests
docker-compose exec backend pytest

# Frontend tests
docker-compose exec frontend npm test

๐ŸŽฏ Nutrition Scoring System

Our proprietary 8-dimension scoring system evaluates food across multiple health aspects:

1. Blood Sugar Impact (0-100)

  • Calculates Glycemic Load
  • Accounts for fiber content
  • Critical for Thai high-carb diet
  • Higher score = Lower blood sugar spike

2. Gut Health (0-100)

  • Fiber content (soluble/insoluble)
  • Prebiotic and probiotic presence
  • Fermented foods bonus
  • Higher score = Better gut health

3. Inflammation (0-100)

  • Omega-3 to Omega-6 ratio
  • Antioxidant ORAC values
  • Anti-inflammatory ingredients
  • Higher score = Anti-inflammatory

4. Nutrient Density (0-100)

  • Nutrients per calorie (ANDI score)
  • Protein and fiber density
  • Vitamin/mineral richness
  • Higher score = More nutrients per calorie

5. Processing Level (0-100)

  • NOVA classification (1-4)
  • Additive detection
  • Whole food percentage
  • Higher score = Less processed

6. Protein Quality (0-100)

  • Complete amino acid profile
  • Protein quantity
  • Source quality (PDCAAS)
  • Higher score = Better protein

7. Micronutrient Coverage (0-100)

  • % RDI for 12 key vitamins/minerals
  • Breadth of nutrient variety
  • Bioavailability factors
  • Higher score = More complete nutrition

8. Overall Health Score (0-100)

  • Weighted average of all dimensions
  • Personalized to user goals
  • Thai dietary context adjustments
  • Higher score = Healthier overall

๐ŸŒ API Documentation

Authentication Endpoints

POST /api/auth/register      # Register new user
POST /api/auth/login         # Login with email/password
GET  /api/auth/me            # Get current user
POST /api/auth/refresh       # Refresh access token

Food Scanning Endpoints

POST /api/scan/analyze       # Analyze food image
GET  /api/scan/history       # Get scan history
GET  /api/scan/{id}          # Get specific scan

Recipe Endpoints

GET  /api/recipes/           # List recipes with filters
GET  /api/recipes/{id}       # Get recipe details
GET  /api/recipes/featured   # Get featured recipes
POST /api/recipes/suggest    # Generate recipe suggestions

Chat Endpoints

POST /api/chat/ask           # Ask AI nutritionist
GET  /api/chat/history       # Get chat history

User Profile Endpoints

GET  /api/user/profile       # Get user profile
PUT  /api/user/profile       # Update profile
GET  /api/user/stats         # Get usage statistics

See full API documentation at: http://localhost:8000/docs


๐Ÿ“Š Database Schema

users
โ”œโ”€โ”€ id (PK)
โ”œโ”€โ”€ email (unique)
โ”œโ”€โ”€ hashed_password
โ”œโ”€โ”€ subscription_tier (free/premium/family)
โ”œโ”€โ”€ language (th/en)
โ”œโ”€โ”€ health_info (age, weight, height, goals)
โ””โ”€โ”€ usage_tracking

food_scans
โ”œโ”€โ”€ id (PK)
โ”œโ”€โ”€ user_id (FK)
โ”œโ”€โ”€ image_url
โ”œโ”€โ”€ detected_items (JSON)
โ”œโ”€โ”€ nutrition_summary (JSON)
โ””โ”€โ”€ 8 dimension scores

recipes
โ”œโ”€โ”€ id (PK)
โ”œโ”€โ”€ name_th, name_en
โ”œโ”€โ”€ ingredients (JSON)
โ”œโ”€โ”€ instructions_th, instructions_en
โ”œโ”€โ”€ nutrition_per_serving
โ”œโ”€โ”€ dietary_flags (vegetarian, halal, etc.)
โ””โ”€โ”€ 8 dimension scores

ingredients
โ”œโ”€โ”€ id (PK)
โ”œโ”€โ”€ name_th, name_en
โ”œโ”€โ”€ category
โ”œโ”€โ”€ nutrition_per_100g
โ”œโ”€โ”€ glycemic_index
โ””โ”€โ”€ special_properties

chat_messages
โ”œโ”€โ”€ id (PK)
โ”œโ”€โ”€ user_id (FK)
โ”œโ”€โ”€ role (user/assistant)
โ”œโ”€โ”€ content
โ””โ”€โ”€ language

meal_plans
โ”œโ”€โ”€ id (PK)
โ”œโ”€โ”€ user_id (FK)
โ”œโ”€โ”€ plan_date
โ”œโ”€โ”€ breakfast, lunch, dinner (JSON)
โ””โ”€โ”€ daily_totals

๐Ÿ”’ Security Features

  • โœ… No API keys in code (environment variables only)
  • โœ… Password hashing with bcrypt
  • โœ… JWT token authentication
  • โœ… CORS protection
  • โœ… Rate limiting on all endpoints
  • โœ… SQL injection prevention (parameterized queries)
  • โœ… XSS protection
  • โœ… CSRF tokens
  • โœ… GDPR compliant from day 1
    • Data export functionality
    • Right to be forgotten
    • Consent management
    • Data minimization

๐ŸŒ Internationalization

Supports Thai (default) and English:

// Access translations
const t = useTranslations('namespace');

// Thai
<h1>{t('title')}</h1>  // "NutriVision AI"

// Language switch
<Link href="/en/dashboard">English</Link>
<Link href="/th/dashboard">เน„เธ—เธข</Link>

Translation files:

  • frontend/src/messages/th.json
  • frontend/src/messages/en.json

๐Ÿค Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

Development Setup

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Write tests
  5. Commit with descriptive messages
  6. Push to your fork
  7. Open a Pull Request

Code Style

  • Python: PEP 8 (use black formatter)
  • TypeScript: ESLint + Prettier
  • Commits: Conventional Commits format

๐Ÿ“„ License

This project is licensed under the MIT License - see LICENSE file for details.


๐Ÿ“ž Contact & Support

Thai Support

  • Line Official: @nutrivisionai
  • Facebook: facebook.com/nutrivisionai
  • Email (Thai): [email protected]

๐Ÿ™ Acknowledgments

  • Thalay Community - For nutrition education insights and content inspiration
  • Google Gemini - For powerful AI capabilities
  • Thai Food Community - For recipe contributions and cultural context
  • Early Beta Testers - For valuable feedback

๐Ÿ“ˆ Roadmap

Phase 1 (Current) โœ…

  • Core food scanning
  • 8-dimension scoring
  • Thai/English support
  • Basic recipe database
  • AI chat

Phase 2 (Q2 2024) ๐Ÿšง

  • Restaurant menu scanning
  • Barcode scanner
  • Fitness tracker integration
  • Voice input
  • Meal comparison

Phase 3 (Q3 2024) ๐Ÿ“‹

  • AI meal coach
  • Recipe creator
  • Marketplace
  • Nutritionist consultation
  • Corporate wellness

Phase 4 (Q4 2024) ๐Ÿ”ฎ

  • Smartwatch app
  • AR food scanning
  • Blood glucose integration
  • DNA-based nutrition
  • International expansion

โญ Star History

If you find this project helpful, please consider giving it a star!

Star History Chart


Made with โค๏ธ for the Thai community

"เธญเธขเธนเนˆเน„เธ”เน‰เธ™เธฒเธ™เธžเธฃเน‰เธญเธกเธเธฑเธšเธเธดเธ™เธญเธฒเธซเธฒเธฃเธญเธฃเนˆเธญเธข" - Live long while eating well

About

๐Ÿฅ— AI-powered Thai food nutrition analyzer with 8-dimension health scoring, 1000+ recipes, and bilingual support. Snap photos for instant nutrition insights, chat with AI nutrition coach, and get personalized meal plans. Next.js + FastAPI + Google Gemini AI.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •