Cut Tracker
A multi-user fat-loss tracking web app that accepts meal descriptions in any language and converts them into precise macro breakdowns via AI, presenting daily energy balance in a profit-and-loss accounting format.
Why I Built This
I wanted a dead-simple way to know my calorie balance at any point in the day — not a full nutrition app, just a quick answer to "am I in a deficit today?" Calorie-tracking apps required searching for every food, logging gram weights, and couldn't export data. An Excel sheet fixed the export problem but required looking up macro values for every food item through AI chat or nutrition databases, then copying numbers into cells. The fix: collapse everything into one step. Describe the meal in whatever language you think in, let DeepSeek handle the lookup and calculation, store the result, and surface it as a clean dashboard with one-click CSV export.
In Practice
Logging a meal
Log in any language — English, Chinese, Japanese, or whatever comes naturally.
Sourdough toast (1 slice, ~40g) — 105 kcal · P 4g · C 20g · F 1g
Oat milk latte (medium, ~350ml) — 130 kcal · P 4g · C 19g · F 4g
─────────────────────────────────────────────────────────
Total — 455 kcal · P 22g · C 39g · F 22g
红烧肉 (3块, ~120g) — 395 kcal · P 18g · C 8g · F 32g
炒青菜 (1份, ~150g) — 80 kcal · P 3g · C 6g · F 5g
豆腐汤 (1碗, ~250ml) — 65 kcal · P 6g · C 3g · F 3g
─────────────────────────────────────────────────
合计 — 800 kcal · P 32g · C 74g · F 41g
Logging exercise
Brisk walk (20 min) — ~110 kcal
──────────────────────────────────
Exercise total — ~380 kcal added to TDEE
End-of-day balance
TDEE (BMR × NEAT + exer) — 2,310 kcal
──────────────────────────────────────
Net Energy Balance — −470 kcal ✓ deficit
When the cut is done, hit Export — every logged day comes out as a CSV with per-item macros, daily totals, and energy balance, ready for further analysis in Excel or wherever.
System Overview
Cut Tracker is a server-rendered web app: Python/FastAPI backend, SQLite database, DeepSeek V3 API for multilingual macro parsing. Authentication is session-token-based with bcrypt password hashing and strict user-scoped data isolation.
session tokens · bcrypt
food log · activity · weight · admin
records.db
multilingual input → macros JSON
validate · store · calculate
How It Works
1. Food Logging via AI
Free-form meal descriptions in any language are sent to DeepSeek V3, which returns structured JSON with per-item calories, protein, carbs, and fat. The server validates and stores the result.
API cost is approximately $0.0001 per log entry. At one log per day, annual cost is under $0.04.
2. Energy Accounting Model
A P&L-style energy balance calculation performed fresh on each dashboard load.
3. NEAT Activity Multipliers
Multipliers applied to BMR before exercise is added:
Sedentary — desk work, minimal movement
Light walking, some standing throughout the day
On feet regularly, moderate physical demands
Physical labour, high-step-count day
4. Request Lifecycle
Session token extracted from cookie, looked up in DB. Request is rejected if token is absent, expired, or unrecognised.
Form data is sanitised. Food descriptions are forwarded to DeepSeek V3 with a structured prompt enforcing JSON output.
Parsed macro data, activity entries, and weight measurements are written to the user's isolated rows in SQLite.
On each page load, the full energy balance is recomputed from today's records and rendered. Historical charts aggregate 7-day and 30-day windows.
One-click CSV generation serialises all of the user's records and returns them as a file download.
5. Multi-user & Admin
All data queries are scoped by user ID — no cross-user data leakage. A hidden admin panel at /admin is protected by a separate secret key.
Infrastructure
Deployed on Railway with continuous deployment from GitHub. SQLite persisted via Railway volume mount. Environment variables manage API keys and secrets — none committed to the repository.
API keys · secrets
records.db