AI-powered meal tracking and nutrition analysis app with GPT-4o vision.
- Analyze meal images to estimate calories and nutritional content
- Multi-language support (English and Turkish)
- Clarification questions for uncertain food items
- Macro breakdown (Protein, Carbs, Fat)
- JWT-based authentication
- User registration and login
- Customizable nutritional goals
- Profile management
- Save analyzed meals to your food diary
- Track meals by date and type (breakfast, lunch, dinner, snack)
- View historical food logs
- Delete entries
- Today's nutritional summary
- Weekly statistics
- Monthly progress tracking
- Progress towards calorie and macro goals
- Meal frequency analysis
- PostgreSQL database
- Local image storage
- Secure password hashing
# Run the setup script
./scripts/setup_dev.sh# 1. Install dependencies
pip install -e ".[dev]"
# 2. Start PostgreSQL
docker-compose up -d
# 3. Setup environment
cp env.example .env
# Edit .env and set OPENAI_API_KEY and JWT_SECRET_KEY
# 4. Run migrations
alembic upgrade head
# 5. Start server
uvicorn cal_ai.main:app --reloadSee SETUP_GUIDE.md for detailed instructions.
Once running, visit:
- Interactive Docs: http://localhost:8000/docs
- Alternative Docs: http://localhost:8000/redoc
POST /v1/auth/register- Create accountPOST /v1/auth/login- LoginPOST /v1/auth/refresh- Refresh tokenPOST /v1/auth/logout- LogoutGET /v1/auth/me- Get current user
GET /v1/users/me/profile- Get profilePATCH /v1/users/me/goals- Set calorie/macro goals
POST /v1/analyze- Analyze meal imagePOST /v1/analyze/{id}/clarify- Answer questions
POST /v1/food-logs- Save mealGET /v1/food-logs- Get history
GET /v1/dashboard/today- Today's summaryGET /v1/dashboard/week- Weekly stats
Required environment variables:
OPENAI_API_KEY- Your OpenAI API keyJWT_SECRET_KEY- Secret for JWT tokens (generate with:python -c "import secrets; print(secrets.token_urlsafe(32))")DATABASE_URL- PostgreSQL connection string
See env.example for all configuration options.
The API is designed to work with mobile apps. See docs/FRONTEND_INTEGRATION.md for complete integration guide.
Key flows:
- Registration/Login → Get JWT tokens
- Set Goals → Define calorie and macro targets
- Analyze Meal → Take photo, get nutritional info
- Save to Log → Add to food diary
- View Dashboard → Track progress
The frontend guide includes:
- Complete API reference with examples
- TypeScript data models
- Screen-by-screen integration guide
- React Native code examples
- Authentication & error handling
- Best practices for offline support, caching, and image optimization
# Run all tests
pytest
# Run with coverage
pytest --cov=cal_ai
# Test specific module
pytest tests/test_analyzer.py# Create migration after model changes
alembic revision --autogenerate -m "description"
# Apply migrations
alembic upgrade head
# Rollback
alembic downgrade -1- SETUP_GUIDE.md - Complete setup instructions
- MIGRATION_SUMMARY.md - What's new in v0.2.0
- docs/DATABASE_SETUP.md - Database management
- docs/ARCHITECTURE.md - System architecture
- docs/FRONTEND_INTEGRATION.md - Complete mobile app integration guide with examples
- Backend: FastAPI, Python 3.11+
- Database: PostgreSQL with SQLAlchemy (async)
- AI: OpenAI GPT-4o Vision
- Auth: JWT with bcrypt
- Migrations: Alembic
cal_ai/
├── src/cal_ai/
│ ├── api/ # API routes
│ ├── auth/ # Authentication
│ ├── database/ # Database models
│ ├── agent/ # AI analysis logic
│ ├── models/ # Pydantic models
│ ├── utils/ # Utilities
│ └── main.py # Application entry
├── alembic/ # Database migrations
├── docs/ # Documentation
├── tests/ # Tests
└── scripts/ # Setup scripts
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests
- Submit a pull request
[Your License Here]