Skip to content

kalkidevs/AI_Halal_Product_Detector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔍 AI Halal Product Detector

Instantly determine if any packaged food product is HALAL or NOT HALAL from a single photo using AI logo detection, OCR text analysis, and product databases.

Stack Stack Stack Stack Stack

Full App Walkthrough


📸 Photo-Only Recognition

The AI Halal Product Detector is designed to operate without barcodes. Users just snap a photo of the product's front packaging, and the system extracts exactly what it needs:

  1. Brand & Product Name Detection: Tesseract OCR extracts the text, normalizes it, and matches it against Indian brand dictionaries.
  2. AI Logo Detection: YOLOv8 scans for halal certification logos.
  3. Database Lookups: The extracted brand/product name is queried against a local Supabase database and the OpenFoodFacts Search API.

Home Page Hero


🤖 Decision Engine Logic

The decision engine combines multiple AI signals to produce a reliable certainty score, ranging from 40% (Unknown) to 95% (Highly Confident).

Evidence Confidence Score Result
Local Database Match 90–95% DB Result (HALAL/NOT HALAL)
Halal Certification Logo detected via YOLOv8 90% HALAL
"Halal" text detected via Tesseract OCR 80% HALAL
AI API Match (OpenFoodFacts fallback) 70–85% API Result
No definitive signals found 40% UNKNOWN (Conservative)

(Note: The system defaults to UNKNOWN rather than "NOT HALAL" if there isn't enough evidence, ensuring users aren't misled by poor photo quality).

Features & Brands


📦 Project Structure

AHPD/
├── frontend/          # Next.js 14 app (Deployed to Vercel)
├── backend/           # FastAPI service (Deployed to Render)
├── supabase/          # PostgreSQL database schema + seed SQL
└── docs/              # GitHub media and documentation

🚀 Quick Start (Local Development)

1. Backend Setup

cd backend

# Install system dependencies (ex. Tesseract)
# macOS:
brew install tesseract tesseract-lang

# Ubuntu/Debian:
# sudo apt install tesseract-ocr tesseract-ocr-eng tesseract-ocr-ara

# Python environment
python -m venv venv && source venv/bin/activate
pip install -r requirements.txt

# Configure environment variables
cp .env.example .env
# Edit .env → add SUPABASE_URL and SUPABASE_ANON_KEY (Provided via Supabase Project)

# Start server
uvicorn main:app --reload --port 8000

2. Frontend Setup

cd frontend

# Set up environment variables
cp .env.local.example .env.local
# .env.local is pre-configured for localhost:8000

# Install & Run
npm install
npm run dev

# Open http://localhost:3000

🗃️ Database Setup (Supabase)

  1. Create a free project at supabase.com.
  2. Go to SQL Editor → New Query.
  3. Run supabase/schema.sql to create tables and RLS policies.
  4. Run supabase/seed.sql to seed the database with 40+ Indian brand records.
  5. Copy the Project URL and Publishable (anon) API Key from the Supabase dashboard.
  6. Paste them into backend/.env.

☁️ Deployment (Free Tier Guides)

Backend → Render API

  1. Push the AHPD repository to GitHub.
  2. Go to render.comNew Web Service.
  3. Connect your GitHub repo and set the Root Directory to backend/.
  4. Render automatically detects the provided Dockerfile.
  5. Add environment variables: SUPABASE_URL and SUPABASE_ANON_KEY.
  6. Deploy (Docker build takes ~5 mins).
  7. Copy the deployed service URL (e.g. https://ahpd-backend.onrender.com).

Frontend → Vercel

  1. Go to vercel.comAdd New Project.
  2. Import the AHPD repository and set the Root Directory to frontend/.
  3. Add the environment variable: NEXT_PUBLIC_API_URL=https://ahpd-backend.onrender.com (Your Render URL).
  4. Deploy! ✅

🇮🇳 Supported Indian Brands

Balaji · Haldirams · Bikaji · Lays · Kurkure · Bingo · Parle · Britannia · Amul · Nestle · MTR · Patanjali · Tata · Sunfeast · Act II · Too Yumm · Prataap · Gopal · and more (via OpenFoodFacts expanding lookup).


⚠️ Disclaimer

This tool provides AI-assisted guidance only. For definitive halal certification, always consult the product manufacturer or a recognized halal certifying authority.

About

AI-powered halal food detector that analyzes product photos using OCR, logo detection, and databases to determine halal status with confidence scoring.

Topics

Resources

Stars

Watchers

Forks

Contributors