https://github.com/jacobstephens2/macrotracker
A self-hosted PWA for tracking daily macronutrients and calories, built as a MyFitnessPal replacement. Features meal logging, food search via Open Food Facts and USDA APIs, barcode scanning, recipe management, weight tracking, and CSV export — with a TypeScript/Vite frontend and a Node.js/Express/SQLite backend.
https://github.com/jacobstephens2/macrotracker
barcode-scanner calorie-tracker express macro-tracker nodejs nutrition pwa recipe-manager self-hosted sqlite typescript vite weight-tracker
Last synced: 5 days ago
JSON representation
A self-hosted PWA for tracking daily macronutrients and calories, built as a MyFitnessPal replacement. Features meal logging, food search via Open Food Facts and USDA APIs, barcode scanning, recipe management, weight tracking, and CSV export — with a TypeScript/Vite frontend and a Node.js/Express/SQLite backend.
- Host: GitHub
- URL: https://github.com/jacobstephens2/macrotracker
- Owner: JacobStephens2
- Created: 2026-03-22T15:01:10.000Z (21 days ago)
- Default Branch: main
- Last Pushed: 2026-03-31T13:10:50.000Z (12 days ago)
- Last Synced: 2026-03-31T15:12:43.023Z (12 days ago)
- Topics: barcode-scanner, calorie-tracker, express, macro-tracker, nodejs, nutrition, pwa, recipe-manager, self-hosted, sqlite, typescript, vite, weight-tracker
- Language: TypeScript
- Homepage: https://macros.stephens.page
- Size: 828 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Macro Tracker
A self-hosted macronutrient tracking PWA built to replace MyFitnessPal. Track daily carbs, protein, fat, and calories with per-meal breakdowns, food search, barcode scanning, recipe management, and weight tracking over time.
Live at **https://macros.stephens.page**
## Features
- **Daily macro dashboard** — calorie ring, carbs/protein/fat progress bars with remaining totals, per-meal targets with color coding
- **Meal logging** — breakfast, lunch, dinner, snacks with per-meal subtotals
- **Food search** — combo search across Open Food Facts and USDA FoodData Central APIs
- **Barcode scanner** — scan packaged foods using device camera
- **Custom foods** — create your own foods with manual macro entry, auto-calculated calories
- **Recipes** — build from ingredients or enter macros manually, custom serving units
- **Weight tracking** — log weight with trend chart (Chart.js)
- **Copy previous day** — one-tap meal duplication for repetitive diets
- **Tap to edit, swipe to delete** — touch-friendly meal management
- **CSV export** — download meal logs and weight data
- **Dark mode** — automatic via `prefers-color-scheme`
- **Email/password auth** — with email verification and password reset (Mandrill SMTP)
- **PWA** — installable, service worker for fast loading, TWA-ready for Google Play
## Tech Stack
- **Frontend:** TypeScript, Vite, Chart.js, html5-qrcode, vite-plugin-pwa
- **Backend:** Node.js, Express, better-sqlite3, JWT (httpOnly cookies), bcrypt, nodemailer
- **Hosting:** Apache (reverse proxy), Let's Encrypt SSL, systemd
## Development
```bash
# Frontend
npm install
npm run dev # Vite dev server on :5173, proxies /api to :3457
# Server
cd server
npm install
npx tsc # Compile TypeScript
node dist/index.js # Runs on :3457
```
Environment variables for the server (set in systemd service or `.env`):
| Variable | Description |
|---|---|
| `JWT_SECRET` | Secret for signing JWTs |
| `PORT` | Server port (default: 3457) |
| `SMTP_HOST` | SMTP server hostname |
| `SMTP_PORT` | SMTP server port |
| `SMTP_USER` | SMTP username |
| `SMTP_PASS` | SMTP password |
| `SMTP_FROM` | From email address |
| `APP_URL` | Public URL (for email links) |
| `USDA_API_KEY` | USDA FoodData Central API key |
| `FATSECRET_CLIENT_ID` | FatSecret Platform API client ID |
| `FATSECRET_CLIENT_SECRET` | FatSecret Platform API client secret |
## Deploy
```bash
# Frontend
npm run build
sudo cp -r dist/* /var/www/macros.stephens.page/
# Server
cd server
npx tsc
sudo systemctl restart macros-api
```
## License
Personal project. Not licensed for redistribution.