# Meal Tracker

A personal food and drink logging application for accountability and macro tracking.

## Project Structure

```
meal-tracker/
├── client/                 # React frontend
│   ├── src/
│   │   ├── components/     # Reusable UI components
│   │   ├── pages/          # Page components
│   │   └── utils/          # Helper functions & API client
│   ├── public/             # Static assets
│   ├── package.json        # Client dependencies
│   └── vite.config.js      # Vite configuration
├── server/                 # Express backend
│   ├── routes/             # API route handlers
│   ├── models/             # Database models
│   ├── middleware/         # Express middleware
│   ├── index.js            # Server entry point
│   └── package.json        # Server dependencies
├── uploads/                # Image uploads (food photos)
├── data/                   # SQLite database
├── docker-compose.yaml     # Docker setup (optional)
└── README.md
```

## Features

### v1 (MVP)
- Manual food entry (name, description, image)
- Image upload support
- Notes field for accountability
- Daily view of entries

### v2
- Food search with macro lookup (OpenFoodFacts API)
- Auto-populate macros from search results
- Manual macro entry override

### v3
- Daily/weekly summary views
- Macro totals (protein, carbs, fat, calories)
- Charts and trends

## Tech Stack

- **Frontend:** React, Vite, Tailwind CSS
- **Backend:** Node.js, Express
- **Database:** SQLite (local)
- **Image Storage:** Local filesystem
- **Food API:** OpenFoodFacts (free, no key required)

## API Endpoints

| Method | Endpoint | Description |
|--------|----------|-------------|
| GET | /api/entries | Get all entries |
| POST | /api/entries | Create new entry |
| GET | /api/entries/:id | Get single entry |
| DELETE | /api/entries/:id | Delete entry |
| GET | /api/foods/search | Search food database |
| GET | /api/summary/daily | Get daily summary |

## Running Locally

```bash
# Install dependencies
cd client && npm install
cd ../server && npm install

# Start backend
cd server && npm start

# Start frontend (separate terminal)
cd client && npm run dev
```

## Environment Variables

See `.env.example` for required configuration.
