A Discord bot to help you log meals, track your weekly nutrition goals, and get AI-powered insights—all powered by Google Gemini AI and SQLite. Whether you drop an image or type a description, Mealbot breaks down your food groups, stores your data, and gives you personalized tips and recommendations. 🥗🍎
Click here to invite Mealbot to your server!
-
Meal Logging (Server & DM)
• Upload an image or send a description of your meal in the#foodchannel or DM the bot directly.
• Bot responds with a breakdown of how that meal contributes to your weekly nutrition goals (as decimal fractions). -
AI-Powered Classification
• Uses Google Gemini (“gemini-1.5-flash-8b”) to classify each meal into six food groups:- Fruits
- Vegetables
- Grains
- Protein
- Dairy
- Oils
• Returns a JSON-only response indicating the fractional contribution toward each’s weekly target.
-
Personalized Meal Tip
• After logging a meal, Mealbot crafts a short, friendly tip that:- Mentions the specific food you logged (e.g., “Given that you had spaghetti…”).
- Praises healthy aspects (e.g., high vegetable content).
- Suggests a complementary action (e.g., “Consider drinking water…”).
-
Weekly Progress Report
• Use!foodreport(in#foodor via DM) to get a detailed, visual progress report.
• Progress bars indicate what percentage of each weekly goal you’ve achieved—aligned uniformly for readability. -
Food Recommendations
• Use!recommendto receive AI-generated suggestions on how to balance any incomplete food-group targets.
• Recommendations are delivered as a simple JSON array converted to a friendly message. -
SQLite Database
• All meal logs (timestamps, user ID, image URL, description, classification JSON) are stored locally infoodbot.db.
• Data persists across restarts, ensuring you never lose your progress.
.
├── bot.py # Main bot logic (classification, tips, reports, commands)
├── requirements.txt # Python dependencies
├── Dockerfile # Docker configuration
├── docker-compose.yaml # Docker Compose setup
├── .env.bak # Example environment variables
├── .gitignore # Git ignore rules
└── README.md # This documentation
- Build & Run
docker-compose up --build -dThis will:
- Build a Docker image named
mealbot.- Launch the bot container in detached mode.
- Stop the Bot
docker-compose down
Build Image
docker build -t mealbot .Force Rebuild (no cache)
docker build --no-cache -t mealbot .-
Clone Repository
git clone https://github.com/PhysCorp/Mealbot.git cd Mealbot -
Environment Variables Create a
.envfile in the project root:DISCORD_TOKEN=your_discord_bot_token GEMINI_API_KEY=your_google_gemini_api_key
-
Install Dependencies
pip install -r requirements.txt
-
Run Locally
python bot.py
Use these commands either in the #food channel or via a Direct Message (DM) to the bot.
| Command | Description |
|---|---|
!foodreport |
View your weekly progress across all food groups (with uniform progress bars). |
!recommend |
Get AI-powered suggestions on how to balance incomplete food-group targets (JSON → friendly). |
-
Log a Meal
- In
#food: Upload an image or type a description. - Via DM: Send a message with an image attachment or a text description.
- In
-
AI Classification & Tip
-
Bot sends typing indicator, then:
- Breaks down “fractions of weekly goals” for each food group.
- Crafts a personalized tip that explicitly mentions your food (e.g., “Your kale salad is an excellent vegetable choice…”).
- Stores data in
foodbot.db.
-
-
Weekly Progress
- Use
!foodreportto see progress bars for: Fruits, Vegetables, Grains, Protein, Dairy, Oils. - Progress bars are left-aligned for consistent display regardless of label length.
- Use
-
Recommendations
- Use
!recommendto receive a set of tailored food ideas to complete any incomplete group targets.
- Use
User (in #food): Today I ate a bowl of kale salad
Bot (breakdown):
📝 Current Meal Breakdown (fractions of weekly goals):
- Fruits : 0.00
- Vegetables : 0.12
- Grains : 0.00
- Protein : 0.02
- Dairy : 0.00
- Oils : 0.01
Bot (tip):
💡 **Meal Tip:** Your kale salad is packed with vegetables and fiber—great job! Consider drinking a glass of water afterward to stay hydrated.
Bot (weekly progress):
🍽️ **Weekly Progress:**
- **Fruits **: [░░░░░░░░░░] 0% of weekly goal
- **Vegetables **: [███░░░░░░░] 30% of weekly goal
- **Grains **: [░░░░░░░░░░] 0% of weekly goal
- **Protein **: [█░░░░░░░░░] 10% of weekly goal
- **Dairy **: [░░░░░░░░░░] 0% of weekly goal
- **Oils **: [░░░░░░░░░░] 0% of weekly goal- discord.py
- python-dotenv
- google-genai
- requests
- SQLite3 (bundled with Python)
Place a .env file in the project root with:
DISCORD_TOKEN=your_discord_bot_token
GEMINI_API_KEY=your_google_gemini_api_keyNote: Never commit your actual tokens or API keys to source control.
This project is licensed under the MIT License. See the LICENSE file for details.