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.
- 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_URIin.envand the app switches automatically. Falls back to JSON files when unset.
cd macro-track
npm install
cp .env.example .env # add your MONGODB_URI
npm run devOpen http://localhost:3000, sign up, complete onboarding, and start logging.
- Create a free cluster on MongoDB Atlas.
- 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- Restart the dev server. On first run, seed foods from
data/foods.jsonare 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).
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
| File | Purpose |
|---|---|
data/foods.json |
Seed food library |
data/users.json |
User accounts (gitignored) |
data/logs/{userId}.json |
Per-user logs (gitignored) |
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.
Set MONGODB_URI and JWT_SECRET in Vercel environment variables. JSON file storage does not persist on serverless — MongoDB is required for production.
- Next.js 16 (App Router)
- TypeScript + Tailwind CSS
- MongoDB (official driver) or local JSON
- bcryptjs + JWT session cookies