Skip to main content
parsefood

Python License OpenRouter

🍽️ Parse food logs from Telegram and track calories with AI 📊

Quick Start · Features · Documentation


Overview

The Pain: Manually tracking calories from natural-language food notes is tedious, error-prone, and never gets done consistently.

The Solution: parsefood connects to your Telegram, reads your food log messages in Portuguese, and uses LLMs to extract ingredients, match them against a structured nutrition database, and calculate calories automatically.

The Result: Daily calorie trend visualizations and Telegram bot progress reports — with zero manual data entry.

Features

  • AI-Powered Extraction — Uses OpenRouter LLMs (Gemini, GPT, Claude) to parse natural language food entries in Portuguese
  • Structured Food Database — JSON-based nutrition database with per-100g values and unit conversions
  • Calorie Trend Visualization — Polynomial regression plots showing intake patterns over time
  • Telegram Bot Integration — Get daily progress reports with colorful progress bars
  • Multiple Input Methods — Add foods via product label images (vision AI) or web scraping from supermarket URLs
  • Multi-User Profiles — YAML-based profile system for tracking multiple users
  • Automatic Backups — Timestamped backups before any processing

🚀 Quick Start

# Clone and install
git clone https://github.com/tsilva/parsefood.git
cd parsefood
uv sync

# Configure
cp .env.example .env
# Edit .env with your OPENROUTER_API_KEY

# Run
uv run python main.py

View your calorie trend at data/plot.png.

Daily Status

# Quick read-only view of today's progress
uv run python main.py --today

🔧 Installation

Prerequisites

Setup

# Install uv (if needed)
curl -LsSf https://astral.sh/uv/install.sh | sh

# Clone repository
git clone https://github.com/tsilva/parsefood.git
cd parsefood

# Install dependencies
uv sync

# Configure environment
cp .env.example .env

Edit .env with your settings:

MODEL_ID=google/gemini-2.5-flash
OPENROUTER_API_KEY=your_api_key_here
TARGET_CALORIES=2000
BED_TIME=22:00

📖 Usage

Processing Food Logs

  1. Export your Telegram chat as JSON (or use the built-in Telegram sync)
  2. Place the export at data/result.json
  3. Run the parser:
uv run python main.py

The tool will:

  • Back up existing data with timestamps
  • Sync latest messages from Telegram
  • Parse food log messages using the LLM
  • Extract ingredients and calculate calories using the food database
  • Generate a calorie trend visualization at data/plot.png

Multi-User Profiles

# List available profiles
uv run python main.py --list-profiles

# Process with a specific profile
uv run python main.py --profile cristina

# Quick daily status for a profile
uv run python main.py --profile cristina --today

Profiles are YAML files in profiles/:

name: "Cristina"
sender_name: "Cristina"
data_path: "/path/to/data"
target_calories: 2000

Telegram Bot

Get daily calorie progress reports via Telegram.

Setup:

  1. Create a bot via @BotFather and copy the token
  2. Get your chat ID from @userinfobot
  3. Add to .env:
    TELEGRAM_BOT_TOKEN=your_bot_token
    TELEGRAM_CHAT_ID=your_chat_id
    

Usage:

# Interactive bot mode
uv run python telegram_bot.py --bot

# One-time report (for cron jobs)
uv run python telegram_bot.py

Commands: /start, /report

Adding Foods to Database

From product label images:

# Place images in labels/ directory (productname_1.jpg, etc.)
uv run python process_labels.py

From supermarket URLs:

# Dry-run (display only)
uv run python scrape_food.py URL

# Add to database
uv run python scrape_food.py --add URL

# With custom name
uv run python scrape_food.py --add --name "food name" URL

Supported sites: Continente.pt

Validation

# Validate all processed data
uv run python main.py validate data/date_messages_map.json

# Inspect specific date
uv run python main.py validate data/date_messages_map.json 2024-03-27

# Quick calorie recalculation check (no LLM)
uv run python scripts/compare_migration.py --quick -n 50

📁 Data Files

File Description
data/result.json Telegram export (input)
data/date_messages_map.json Processed food log data
data/plot.png Calorie trend visualization
food_database.json Nutrition database
data/backups/ Timestamped backups

📚 Documentation

  • CLAUDE.md — Comprehensive architecture guide, data structures, and development workflows
  • docs/pipeline.md — Detailed data processing pipeline documentation

License

MIT License

Metadata

Release files for parsefood 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for parsefood 0.1.0
File Size Uploaded Provenance Actions
parsefood-0.1.0.tar.gz 457.7 kB With provenance Details for parsefood-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for parsefood 0.1.0
File Interpreter ABI Platform Actions
parsefood-0.1.0-py3-none-any.whl Python 3 none any Details for parsefood-0.1.0-py3-none-any.whl

Total release size: 945.6 kB

Release files / parsefood-0.1.0.tar.gz

Download URL parsefood-0.1.0.tar.gz
Size 457.7 kB
Tags Source
SHA-256 checksum
How to use checksums
f4785d1597c4773036abfdef57b07ec1569444c706e86acf49ebda508d1d08a4
BLAKE2b-256 checksum
How to use checksums
ce93764db70e1e34a5137dda75bd58fe2769a779b485cf394548c6a0b948d52b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 28, 2026.

Transparency log

Release files / parsefood-0.1.0-py3-none-any.whl

Download URL parsefood-0.1.0-py3-none-any.whl
Size 487.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dda75e1f2956d3313630ff5816b40714a661c48eda29d0c58fa25dad361e4fb9
BLAKE2b-256 checksum
How to use checksums
e01158a424b15916634ba1b11fd5e05c51ace8fff6778f7e9b077e84b8f50001
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 28, 2026.

Transparency log

Security for parsefood 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for parsefood-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 28, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page