A comprehensive nutrition tracking and recommendation application
Built with FastAPI, React, MySQL, and Redis
- FastAPI Backend: RESTful API with MySQL database and Redis caching
- BCNF-Normalized Database: Efficient, normalized MySQL schema
- React Frontend: Modern, responsive UI with reusable components
- RAG-Based Recommender: AI-powered food recommendations using Retrieval-Augmented Generation
- User Preferences: Customizable food preferences and dietary restrictions
- Daily Reports: Automated nutrition analysis and recommendations
- SOLID Principles: Clean, maintainable code following SOLID principles
- Comprehensive Testing: Pytest for backend, Cypress for frontend
- CI/CD Pipeline: Automated testing and deployment with GitHub Actions
- FastAPI
- SQLAlchemy (ORM)
- MySQL
- Redis (caching/sessions)
- Pydantic (validation)
- LangChain (RAG)
- OpenAI API
- Pytest
- React 18
- React Router
- TanStack Query (React Query)
- Axios
- Vite
- Cypress
NutriBite/
├── backend/
│ ├── app/
│ │ ├── api/ # API routes
│ │ ├── core/ # Core configuration
│ │ ├── models/ # Database models
│ │ ├── schemas/ # Pydantic schemas
│ │ └── services/ # Business logic
│ ├── database/
│ │ └── schema.sql # Database schema
│ ├── tests/ # Pytest tests
│ └── requirements.txt
├── frontend/
│ ├── src/
│ │ ├── components/ # Reusable components
│ │ ├── contexts/ # React contexts
│ │ ├── pages/ # Page components
│ │ └── services/ # API services
│ ├── cypress/ # Cypress tests
│ └── package.json
└── .github/
└── workflows/ # CI/CD pipelines
- Python 3.11+
- Node.js 18+
- MySQL 8.0+
- Redis 7+
- Navigate to backend directory:
cd backend- Create and activate virtual environment:
python -m venv nutribite
# On Windows:
.\nutribite\Scripts\Activate.ps1
# On Linux/Mac:
source nutribite/bin/activate- Install dependencies:
pip install --upgrade pip setuptools wheel
pip install -r requirements.txt- Set up environment variables:
cp .env.example .env
# Edit .env with your configuration (DATABASE_URL, REDIS_URL, SECRET_KEY, etc.)- Set up database:
mysql -u root -p < database/schema.sql- Run the server:
python run.py
# Or: uvicorn app.main:app --reload- Navigate to frontend directory:
cd frontend- Install dependencies:
npm install- Start development server:
npm run devcd backend
pytest tests/ -vcd frontend
npm run test # Headless mode
npm run test:open # Interactive modeOnce the backend is running, visit:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
The database follows BCNF (Boyce-Codd Normal Form) normalization:
- Users: User accounts and profiles
- Foods: Food catalog with nutrition information
- Meals: Meal instances
- MealFoods: Junction table for meals and foods
- UserPreferences: User nutrition targets and preferences
- DietaryRestrictions: User dietary restrictions
- Goals: User fitness goals
- DailyReports: Daily nutrition summaries
- FoodSelector: Search and select foods with quantity
- PreferenceForm: Manage user preferences and dietary restrictions
The recommender uses Retrieval-Augmented Generation to provide personalized food recommendations based on:
- User preferences
- Dietary restrictions
- Target calories
- Historical meal data
- User data cached in Redis
- Food search results cached
- Meal data cached for performance
The project includes GitHub Actions workflows for:
- Automated backend testing
- Frontend build and Cypress tests
- Code linting
- Coverage reporting
Backend:
cd backend
.\nutribite\Scripts\Activate.ps1 # Windows
python run.pyFrontend:
cd frontend
npm run devThe frontend will be available at http://localhost:3000 and the backend API at http://localhost:8000.
Contributions are welcome! Please follow these guidelines:
- Follow SOLID principles
- Write tests for new features
- Update documentation
- Ensure all tests pass
- Follow the existing code style
✅ Backend API complete
✅ Frontend UI complete
✅ Database schema implemented
✅ RAG recommender integrated
✅ Test suite configured
✅ CI/CD pipeline set up
This project is licensed under the MIT License - see the LICENSE file for details.
Note: Update the GitHub username in the badges above (yourusername) to match your repository.