Mobile-first calorie, carbs, and protein tracker using Firebase Authentication, Firestore, and Firebase Hosting.
- Email/password authentication with 30-minute inactivity timeout
- Daily dashboard with totals and entries per day (past/future navigation)
- Add/edit/delete entries with live totals
- Food picker with favorites-first sorting, local filtering, and inline creation when no results are found
- Foods management with favorites, edit, and delete (entries keep stored snapshots)
- Firebase Hosting deployment workflow (GitHub Actions)
- Node.js 18+
- Firebase project with Authentication (Email/Password) and Firestore enabled
- Firebase CLI installed locally for manual deploys
npm installCreate a .env.local file (Vite-compatible) with your Firebase project credentials:
VITE_FIREBASE_API_KEY=your-api-key
VITE_FIREBASE_AUTH_DOMAIN=your-project.firebaseapp.com
VITE_FIREBASE_PROJECT_ID=your-project-id
VITE_FIREBASE_STORAGE_BUCKET=your-project.appspot.com
VITE_FIREBASE_MESSAGING_SENDER_ID=sender-id
VITE_FIREBASE_APP_ID=app-id
VITE_USDA_API_KEY=your-usda-api-key
- Create a free developer account at https://fdc.nal.usda.gov/api-key-signup.html.
- Copy the issued key and set
VITE_USDA_API_KEYin your.env.local. - The app uses this key when you click "Lookup nutrition" while creating or editing foods.
npm run devOpen the printed URL (defaults to http://localhost:5173).
npm run build- Update
.firebasercwith your project id or set theFIREBASE_PROJECT_IDsecret in GitHub Actions. - Add a base64-encoded Firebase service account JSON to the
FIREBASE_SERVICE_ACCOUNTGitHub secret (or use a localfirebase login+firebase deploy). - Push to
mainto trigger the GitHub Actions workflow or runfirebase deploy --only hosting,firestore:ruleslocally.
Rules in firestore.rules restrict all reads/writes to the authenticated user within their own users/{uid} subtree.
users/{uid}/foods/{foodId}: name, caloriesPerServing, carbsPerServing, proteinPerServing, favorite, createdAtusers/{uid}/entries/{date}/items/{entryId}: foodName, servings, caloriesPerServing, carbsPerServing, proteinPerServing, createdAt
Entries store snapshot values so historical data is preserved even if foods change.
Any interaction (click, scroll, typing, touch) resets a 30-minute inactivity timer. When the timer elapses, the user is signed out and must log in again.
A GitHub Actions workflow (.github/workflows/deploy.yml) installs dependencies, builds the app, and deploys to Firebase Hosting on pushes to main.