Home
Softono
macrotrackr

macrotrackr

Open source TypeScript
16
Stars
1
Forks
2
Issues
1
Watchers
1 week
Last Commit

About macrotrackr

Macrotrackr is an open-source nutrition and macro tracking application designed for self-hosting, licensed under AGPLv3. It enables users to log their daily food intake and monitor macronutrient consumption including proteins, fats, and carbohydrates. The backend is built with Bun and Elysia, using SQLite as the database with local authentication enabled and billing disabled by default in self-hosted mode. Sessions are managed through secure cookies with database-backed storage. The frontend is a React application built with Vite, supporting a local authentication user interface. Key features include local user registration and login, macro and nutrition tracking, optional analytics integration via PostHog, optional email support through Resend or SMTP, and environment-based configuration for branding and support links. For deployment, Macrotrackr offers Docker Compose using prebuilt images from GitHub Container Registry, with an nginx proxy enabling same-origin API requests. The default stack exposes the fro

Platforms

Web Self-hosted

Languages

TypeScript

Macro Tracker

Macro Tracker is an AGPLv3 nutrition and macro tracking application designed for self-hosting.

The backend uses SQLite with local authentication and billing disabled by default.

License

This project is licensed under the GNU Affero General Public License v3.0. See LICENSE.

Self-Hosted Mode

  • APP_MODE=self-hosted
  • AUTH_MODE=local
  • BILLING_MODE=disabled

Expected behavior:

  • Local auth routes enabled (/api/auth/* local endpoints)
  • Session transport via mt_session secure cookie + DB-backed sessions
  • Billing routes unmounted (404 by absence)
  • Billing UI hidden

Environment Contracts

Backend canonical variables:

  • ANALYTICS_MODE, EMAIL_MODE
  • APP_URL, PUBLIC_APP_NAME, SUPPORT_EMAIL
  • ENABLE_METRICS

Frontend optional branding/public link variables:

  • VITE_APP_URL
  • VITE_PUBLIC_APP_NAME
  • VITE_SUPPORT_EMAIL
  • VITE_GITHUB_REPO_URL
  • VITE_DOCS_URL

Provider env vars are only required when corresponding modes are enabled:

  • PostHog keys only when ANALYTICS_MODE=posthog
  • Resend/SMTP keys only when EMAIL_MODE=resend|smtp

Reference templates:

  • backend/.env.example
  • frontend/.env.example

Quick Start (Local Development)

bun install
cp backend/.env.example backend/.env.development
cp frontend/.env.example frontend/.env.development
bun run dev

Useful scripts:

bun run dev:backend
bun run dev:frontend
bun run --cwd backend test
bun run --cwd frontend test
bun run typecheck
bun run lint

Self-Hosting with Docker Compose

This repository includes a self-host starter compose stack.

mkdir -p data
docker compose pull
docker compose up -d

The default compose file uses prebuilt GHCR images in local-auth mode (VITE_AUTH_MODE=local), so no Clerk publishable key is required for self-hosted deployments. It also uses same-origin API requests (/api) through nginx proxying, so clients do not need to reach backend on localhost.

Services:

  • frontend: http://localhost:5173 (Mapped to internal container port 80)
  • backend API: http://localhost:3000 (Direct access usually not needed since frontend proxies /api)

The SQLite database is persisted at ./data/macrotrackr.db.

Build from source instead of pulling images

docker compose -f docker-compose.yml -f docker-compose.build.yml up --build

This mode is useful for contributors and local image customization.

First-run bootstrap

  1. Start the stack.
  2. Open http://localhost:5173/register.
  3. Create the initial local user account.

Backup, Restore, and Upgrade (Self-host)

Backup

cp data/macrotrackr.db data/macrotrackr.db.backup

Restore

cp data/macrotrackr.db.backup data/macrotrackr.db

Upgrade

git pull
docker compose pull
docker compose up -d

Deployment Notes

  • Frontend deployment guide: frontend/docs/DEPLOYMENT.md
  • This public repository focuses on self-hosted deployments.
  • Managed hosting infrastructure is maintained in a separate private repository.

Project Layout

backend/   Bun + Elysia API, SQLite schema, auth modules
frontend/  React + Vite app (local auth UI)
docs/      public project docs

Star History

Star History Chart