Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ₯— NutriAI Discord Bot A calorie tracking bot that lives in your Discord server. Log meals by typing, send food photos for AI calorie estimates, track macros, and monitor your weekly progress β€” all without giving away your phone number.

Features

Smart food search β€” searches Open Food Facts database, auto-rephrases if not found, falls back to Claude AI + web search as last resort Photo logging β€” send a photo of any meal, Claude Vision estimates the calories and macros Profile setup β€” calculates your BMI, TDEE, daily calorie target, and macros based on your stats Weekly rate control β€” choose exactly how many grams per week to lose or gain, not just a hardcoded deficit Goal timeline β€” tells you exactly how many weeks until you reach your target weight Rate limit safe β€” handles Discord 429 errors automatically with retry and backoff

Commands CommandWhat it does!setupProfile wizard β€” gender, weight, goal, weekly rate!summaryToday's meals + calorie total + macro progress bars!weekLast 7 days with calorie bars!profileYour stats, goal, and timeline!undoRemove the last logged meal!clearWipe today's entire log!helpShow command list200g chicken breastLog food by grams β€” smart searchπŸ“· PhotoAI estimates and logs calories from the photo Food entry tags shown in replies:

No tag β€” found in Open Food Facts database directly ~ β€” found after auto-simplifying your search AI β€” found via Claude AI web search πŸ“· β€” logged from a photo

Tech Stack PartWhatLanguagePython 3.11Discord librarydiscord.pyDatabaseSQLite (single file, no server needed)Food dataOpen Food Facts API (free, no key)AIAnthropic Claude API (photo analysis + food search fallback)HostingRender (free tier)

Project Structure nutriai-discord/ β”œβ”€β”€ discord_bot.py ← the entire bot β”œβ”€β”€ requirements.txt ← Python packages β”œβ”€β”€ runtime.txt ← pins Python 3.11 for Render β”œβ”€β”€ .env ← your secret tokens (never commit this) β”œβ”€β”€ .gitignore ← keeps .env and database off GitHub └── nutriai.db ← SQLite database (auto-created on first run)

Setup

  1. Clone and install powershellgit clone https://github.com/prodevmod/nutriai-discord.git cd nutriai-discord python -m venv venv .\venv\Scripts\activate pip install -r requirements.txt
  2. Create your .env file DISCORD_BOT_TOKEN=your_discord_bot_token_here ANTHROPIC_API_KEY=your_anthropic_api_key_here
  3. Get your tokens Discord Bot Token:

Go to discord.com/developers/applications New Application β†’ Bot β†’ Reset Token β†’ copy it Enable Message Content Intent under Privileged Gateway Intents Invite bot to your server via OAuth2 β†’ URL Generator

Anthropic API Key:

Go to console.anthropic.com API Keys β†’ Create Key β†’ copy it Free $5 credit included β€” enough for ~1,600 photo analyses

  1. Run locally powershell.\venv\Scripts\activate python discord_bot.py

Deploy to Render (free 24/7 hosting)

Push code to GitHub Go to render.com β†’ New β†’ Web Service β†’ connect your repo Build command: pip install -r requirements.txt Start command: python discord_bot.py Add environment variables: DISCORD_BOT_TOKEN and ANTHROPIC_API_KEY Set PYTHON_VERSION = 3.11.9 in environment variables Turn Auto-Deploy OFF β€” deploy manually to avoid Discord rate limits Click Deploy

Note: If you see a 429 error on first deploy, wait 10 minutes then redeploy manually. This is Discord temporarily blocking Render's IP after multiple rapid login attempts during setup. It clears on its own.

How Food Search Works When you type 200g grilled skinless chicken breast: Stage 1 β€” Search Open Food Facts as typed ↓ not found Stage 2 β€” Strip cooking words (grilled, skinless...) Try: "chicken breast fillet" β†’ "chicken breast" β†’ "chicken" ↓ still not found Stage 3 β€” Ask Claude AI with web search enabled Claude searches the internet for the macros Returns structured data β†’ logged with AI badge

How the Calorie Target is Calculated BMR = Mifflin-St Jeor formula (based on gender, age, weight, height) TDEE = BMR Γ— activity multiplier Daily change = (weekly_rate_g Γ— 7.7 kcal) Γ· 7 days

Goal = lose β†’ target = TDEE - daily_change Goal = gain β†’ target = TDEE + daily_change Goal = maintain β†’ target = TDEE

Floor: never below 1500 kcal (male) or 1200 kcal (female)

License Personal project β€” free to use and modify.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages