Snap a photo of your meal and let AI instantly log its calories and macros. CalorieAI turns nutrition tracking from a tedious chore into a one-tap habit β with personalized goals, streaks, analytics, and more.
CalorieAI is a modern web app that helps you eat healthier without the friction of manual food logging. Instead of searching databases and guessing portion sizes, you simply take a photo of your food β an AI vision model identifies the meal and estimates its full nutritional breakdown (calories, protein, carbs, fat, fiber, sugar, sodium) plus a health score.
Around that core, the app gives you everything you need to actually stick with your goals: a personalized calorie & macro plan, a daily dashboard, water and weight tracking, a streak-and-badge system to keep you motivated, and rich analytics over time.
In one sentence: Onboard β get a personalized plan β snap your meals β watch your progress.
| Landing Page | Onboarding Flow | Authentication (Clerk) |
|---|---|---|
| Personalized Plan | Meal Logging | Dashboard & Insights |
|---|---|---|
The original AI pipeline was built as an n8n workflow (shown below). It has since been fully reimplemented in application code β see How the AI works.
- πΈ AI meal recognition β photograph your food and get instant calories, macros, a confidence score, and a health rating.
- β¨οΈ Manual entry β type in a meal's nutrition by hand when you prefer.
- π Barcode scanning β scan a packaged product's barcode to auto-fill nutrition from the Open Food Facts database.
- π― Personalized goals β your daily calorie & macro targets are computed from your body stats and goals using the Mifflin-St Jeor equation (not hardcoded guesses).
- π Daily dashboard β calories remaining, macro distribution donut, per-meal breakdown, and day-by-day navigation.
- ποΈ Calendar view β a color-coded month grid showing how each day measured against your goal.
- π Analytics β weekly/monthly calorie trends, macro trends, and a weight-progress chart.
- π₯ Streaks & badges β build a logging habit and unlock milestone badges (3, 7, 10, 14, 21 days).
- π§ Water tracking β log your daily glasses toward a hydration goal.
- βοΈ Weight tracking β log weigh-ins and visualize the trend over time.
- βοΈ Settings β edit goals/weights, recalculate your plan, switch units, and manage your account.
- π Dark mode β light / dark / system theme.
- π Secure auth β sign-up/sign-in via Clerk, with per-user data isolation enforced by Supabase Row-Level Security.
- Sign up with Clerk (email or social login).
- Onboard β a short, guided flow asks for your gender, body stats, weight goal, activity level, and pace. From this, CalorieAI generates a personalized calorie & macro plan.
- Log meals β snap a photo, scan a barcode, or type it in. The AI fills in the nutrition; you review and save.
- Track everything β meals, water, and weight all roll up into your daily dashboard.
- Stay motivated β keep your streak alive, earn badges, and watch your trends in Analytics.
CalorieAI's nutrition analysis is powered by Google Gemini's vision model, called directly from the app.
Note on the architecture change: the meal-analysis pipeline was originally built as a hosted n8n workflow (a webhook that called an LLM vision API and a second LLM to format the result β pictured in the screenshot above). When that hosting was retired, the entire workflow was rebuilt natively in the codebase. There is no external webhook anymore β everything runs in our own code.
The current flow (src/lib/gemini.ts):
- The meal image is converted to base64 in the browser.
- It's sent to Gemini with a detailed "AI Nutrition Analyst" prompt.
- Gemini's structured-output feature (
responseSchema) returns strictly-typed JSON in a single call β collapsing what used to be two separate n8n nodes (vision analysis + JSON formatting) into one. - The validated result (
mealName,calories,protein,carbs,fat,fiber,sugar,sodium,confidenceScore,healthScore,rationale) is shown for review and saved to Supabase.
| Layer | Technology |
|---|---|
| Frontend | React 18, TypeScript, Vite |
| UI | Tailwind CSS, shadcn/ui, Recharts, Motion |
| Authentication | Clerk |
| Database | Supabase (Postgres + Row-Level Security) |
| AI / Vision | Google Gemini |
| Barcode lookup | Open Food Facts + ZXing |
| Deployment | Vercel |
- Node.js >= 18
- A free Supabase project
- A free Clerk application
- A Google AI Studio (Gemini) API key
git clone https://github.com/Nish2005karsh/Calorie-tracker.git
cd Calorie-tracker
npm installIn your Supabase project, open the SQL Editor and run the contents of supabase_setup.sql. This creates all tables (daily_meals, user_profiles, user_streaks, user_badges, weight_logs, water_logs) and their Row-Level-Security policies in one go.
So Supabase trusts Clerk-issued logins:
- In Clerk β enable the Supabase integration and copy your Clerk domain (e.g.
https://your-app.clerk.accounts.dev). - In Supabase β Authentication β Third-Party Auth β Add provider β Clerk, and paste that domain.
Create a .env.local file in the project root:
# Supabase
VITE_SUPABASE_URL=https://your-project.supabase.co
VITE_SUPABASE_ANON_KEY=your_supabase_publishable_key
# Clerk
VITE_CLERK_PUBLISHABLE_KEY=pk_test_your_clerk_key
# Google Gemini
VITE_GEMINI_API_KEY=your_gemini_api_key
# Optional: override the model (default: gemini-2.0-flash)
# VITE_GEMINI_MODEL=gemini-2.0-flashnpm run devOpen the local URL Vite prints (usually http://localhost:8080).
- Push the repo to GitHub and import it into Vercel (it auto-detects Vite β build command
npm run build, outputdist). - Add the same environment variables from
.env.localunder Settings β Environment Variables. - Deploy, then add your
*.vercel.appURL to Clerk's allowed origins.
SPA routing is handled by
vercel.jsonso deep links (e.g./dashboard) work on refresh.
src/
ββ pages/ # Route screens
β ββ Landing.tsx # Marketing page (hero, how-it-works, features, testimonials)
β ββ Dashboard.tsx # Daily overview: calories, macros, meals, water, streaks
β ββ Analytics.tsx # Trend charts
β ββ Calendar.tsx # Month grid of daily intake
β ββ Settings.tsx # Goals, units, theme, account
β ββ onboarding/ # Guided multi-step onboarding flow
β ββ dashboard/AddMeal.tsx # Photo / barcode / manual meal entry
ββ components/ # Reusable UI (Footer, HowItWorks, BarcodeScanner, ui/*)
ββ hooks/ # useOnboarding, etc.
ββ lib/
ββ gemini.ts # AI meal analysis (replaces the old n8n workflow)
ββ openfoodfacts.ts # Barcode β nutrition lookup
ββ goals.ts # Mifflin-St Jeor calorie & macro calculation
ββ supabase.ts # Supabase client + Clerk third-party auth
ββ api.ts # Meals, profile, weight, water data access
ββ streaks.ts # Streaks & badges
ββ analytics.ts # Weekly/monthly aggregation