AI-powered Telegram calorie and nutrition tracker running on Cloudflare Workers. The bot extracts meal details with Gemini, stores logs in PostgreSQL, and gives daily summaries.
- Onboards users with name, timezone, and calorie goal
- Logs meals from free-text input using AI extraction
- Supports guided logging with
/logand review buttons - Saves detailed nutrient fields for each food item
- Shows grouped daily totals with
/today
Use either option below:
- Open bot link: Open Telegram Bot (or)
- Scan QR code:
Place your QR image at docs/images/telegram-bot-qr.png so it renders on GitHub.
/start- Start onboarding/log- Start guided logging (bot asks for meal text next)/log <meal text>- Quick log in one message/today- Show today's saved foods and totals
- Cloudflare Workers + Wrangler
- TypeScript
- PostgreSQL (
postgresruntime client) - Prisma schema and migrations
- Gemini API
src/
data/db.ts
handlers/telegram-handler.ts
services/ai.ts
services/telegram.ts
types/index.ts
worker.ts
docs/
backend-architecture-v2.md
- Node.js 20+
- npm
- Cloudflare account
- PostgreSQL database
- Telegram bot token
npm installSet Worker secrets:
wrangler secret put DATABASE_URL
wrangler secret put TELEGRAM_BOT_TOKEN
wrangler secret put TELEGRAM_WEBHOOK_SECRETGEMINI_MODEL is configured via wrangler.toml.
Gemini API keys are loaded from DB table gemini_keys.
npm run cf:login
npm run cf:whoami
npm run cf:devnpm run cf:deployGET /health- Health checkPOST /telegram-webhook- Telegram updates
npm run prisma:validate
npm run prisma:generate
npm run prisma:pushnpm run typecheck