A full-stack web application (PWA) for tracking food intake, analyzing nutrients, and generating personalized diet recommendations using AI.
- 🍽️ Food Logging: Log your meals by time (morning, afternoon, evening)
- 🤖 AI-Powered Analysis: Automatic nutrient breakdown (calories, protein, carbs, fats, fiber)
- 📊 Daily Summaries: Get AI-generated summaries of your daily food intake
- 🎯 Personalized Diet Plans: After 3-4 days of logging, receive personalized recommendations
- 🔄 Food Replacements: Get suggestions to replace high-calorie, low-nutrition foods with better alternatives
- 📱 PWA Support: Install as a mobile app on iOS and Android
- Next.js 16 (App Router)
- TypeScript
- Tailwind CSS
- PWA (Progressive Web App)
- FastAPI (Python)
- SQLAlchemy (ORM)
- SQLite/PostgreSQL (Database)
- OpenAI GPT-4 (AI Analysis)
FitBuddy/
├── frontend/ # Next.js frontend application
│ ├── app/ # Next.js app directory
│ ├── components/ # React components
│ ├── lib/ # API utilities
│ └── public/ # Static assets
├── backend/ # FastAPI backend application
│ ├── app/
│ │ ├── routers/ # API route handlers
│ │ ├── services/ # Business logic (AI service)
│ │ ├── models.py # Database models
│ │ └── schemas.py # Pydantic schemas
│ └── requirements.txt
└── README.md
- Node.js 18+ and npm
- Python 3.9+
- OpenAI API key
- Navigate to the backend directory:
cd backend- Create a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Create a
.envfile:
cp .env.example .env- Update
.envwith your configuration:
DATABASE_URL=sqlite:///./fitbuddy.db
OPENAI_API_KEY=your_openai_api_key_here
SECRET_KEY=your_secret_key_here- Run the backend server:
uvicorn app.main:app --reloadThe API will be available at http://localhost:8000
API documentation: http://localhost:8000/docs
- Navigate to the frontend directory:
cd frontend- Install dependencies:
npm install- Create a
.env.localfile (optional, defaults to localhost:8000):
NEXT_PUBLIC_API_URL=http://localhost:8000- Run the development server:
npm run devThe app will be available at http://localhost:3000
Frontend:
cd frontend
npm run build
npm startBackend:
cd backend
uvicorn app.main:app --host 0.0.0.0 --port 8000- Log Food: Select a date and meal time, then describe what you ate
- Analyze: Click "Analyze Nutrients" on any food log to get detailed nutritional information
- View Summary: See daily summaries and total nutrients for each day
- Generate Diet Plan: After logging food for 3-4 days, go to the "Diet Plan" tab and click "Generate Plan" to get personalized recommendations
POST /api/food-logs/- Create a food logGET /api/food-logs/- Get all food logs (optionaldatequery parameter)GET /api/food-logs/{id}- Get a specific food logPUT /api/food-logs/{id}- Update a food logDELETE /api/food-logs/{id}- Delete a food log
POST /api/ai/analyze- Analyze a food log and extract nutrientsPOST /api/ai/summarize- Get daily food summaryGET /api/ai/nutrients/{date}- Get total nutrients for a date
POST /api/diet-plan/generate- Generate a personalized diet planGET /api/diet-plan/- Get the latest diet plan
- Open the app in a mobile browser (Chrome, Safari)
- Look for the "Add to Home Screen" prompt or use the browser menu
- The app will be installed and can be used offline (with cached data)
- Backend: Add new routes in
backend/app/routers/ - Frontend: Add new components in
frontend/components/ - AI Service: Modify
backend/app/services/ai_service.pyfor AI-related changes
MIT
Contributions are welcome! Please feel free to submit a Pull Request.