Simple PHP+DB calorie tracker
Find a file
2026-04-20 09:41:44 +02:00
.gitignore gitignore wording 2026-04-07 08:31:30 +02:00
api.php Change empty-day-default-to-maintenance logic to look at entries instead of calories such that 0 calorie entries correctly make the whole day 0 calories 2026-04-20 09:30:00 +02:00
example.png first commit 2026-02-19 12:27:25 +01:00
index.php maintenance typo 2026-04-20 09:41:44 +02:00
LICENSE first commit 2026-02-19 12:27:25 +01:00
README.md Clarify how fasting works in readme 2026-04-20 09:39:24 +02:00

calories

Minimal self-hosted calorie tracker: a single-page PHP UI (index.php) with a tiny JSON API (api.php) backed by a local SQLite database.

Screenshot

What it does

  • Add calorie entries for today (kcal + optional description)
  • Delete entries (only works for today. You must edit the db directly to delete older entries)
  • Configure daily goal and maintenance targets
  • Show todays total/remaining and a simple 30-day bar graph

Fasting

Empty days will be counted as the 'Maintenance' number so if you wish to have a fasting day you need to enter a 0-calorie item for that day.

Requirements

  • PHP 8.x recommended, did work on PHP 7.4 previously
  • PHP extension: pdo_sqlite (PDO + SQLite)
  • A writable directory for the SQLite file (calories.db is created automatically)

Project layout

  • index.php: main UI entrypoint (renders HTML/CSS/JS)
  • api.php: JSON API endpoint for add/delete/update actions
  • calories.db: SQLite database file (local/runtime data; not committed)

Install

No dependencies to install, just deploy the PHP files.

How to run

Serve this directory with your web server

  • Point your web root at this directory (or otherwise ensure index.php is reachable).
  • Ensure PHP has pdo_sqlite enabled.
  • Ensure the directory is writable by the PHP user so SQLite can create/write calories.db.

Configuration

  • Database path: hardcoded as calories.db in both index.php and api.php.
  • Daily goal / maintenance: stored in the config table; editable in the UI.