Skip to content

Repository files navigation

MacroTrack

A minimal, mobile-first macro and calorie tracker. Log food by meal, review daily/weekly/monthly progress, and manage your food library — with MongoDB or local JSON storage.

Features

  • Today tab — Log breakfast, lunch, dinner, and snacks. Navigate today and the past 6 days.
  • Dashboard — Day / week / month views with progress rings, conic progress outlines, and over/under highlighting.
  • Foods tab — Dedicated page to add foods, search the library, tap to select & edit, or delete.
  • Settings — Profile, daily goals, logout.
  • Auth — Email + password (min 8 chars) with first-login onboarding.
  • MongoDB — Set MONGODB_URI in .env and the app switches automatically. Falls back to JSON files when unset.

Quick start

cd macro-track
npm install
cp .env.example .env   # add your MONGODB_URI
npm run dev

Open http://localhost:3000, sign up, complete onboarding, and start logging.

MongoDB setup

  1. Create a free cluster on MongoDB Atlas.
  2. Copy your connection string into .env:
MONGODB_URI=mongodb+srv://user:pass@cluster.mongodb.net/
MONGODB_DB_NAME=macrotrack
JWT_SECRET=your-long-random-secret
  1. Restart the dev server. On first run, seed foods from data/foods.json are inserted automatically.

Collections used:

Collection Purpose
users Accounts, profiles, goals
foods Food library
day_logs Per-user daily log entries

Without MONGODB_URI, the app uses local JSON files in data/ (fine for local dev only).

Food library page

Go to the Foods tab to:

  • Search and browse all foods
  • Tap any item to load it into the edit form
  • Add new foods with serving size, macros, and optional auto-calorie calc
  • Delete foods from the library

Data files (JSON fallback)

File Purpose
data/foods.json Seed food library
data/users.json User accounts (gitignored)
data/logs/{userId}.json Per-user logs (gitignored)

Architecture

All data access goes through repository interfaces in src/lib/db/interfaces.ts. The factory in src/lib/db/index.ts picks MongoDB or JSON based on MONGODB_URI.

Deploying to Vercel

Set MONGODB_URI and JWT_SECRET in Vercel environment variables. JSON file storage does not persist on serverless — MongoDB is required for production.

Tech stack

  • Next.js 16 (App Router)
  • TypeScript + Tailwind CSS
  • MongoDB (official driver) or local JSON
  • bcryptjs + JWT session cookies

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages