A comprehensive full-stack calorie tracking application built with Flask backend, React frontend, MongoDB database, and a custom CLI for easy management. The application is fully containerized with Docker for seamless deployment.
- ποΈ Full-Stack Architecture: Flask REST API backend with React frontend
- ποΈ MongoDB Database: NoSQL database for flexible data storage
- β‘ Custom CLI Tool: Command-line interface for managing the application
- π³ Docker Support: Fully containerized with docker-compose
- π€ User Management: User registration and profile management
- π½οΈ Meal Tracking: Log and track daily meals and nutrition
- β€οΈ Health Monitoring: Track weight and water intake
- π» Modern UI: Responsive React frontend with component-based architecture
- π REST API: Comprehensive API endpoints for all features
- π± Database Seeding: Built-in script for populating test data
- π§ͺ AI-Powered Research: Intelligent ingredient and recipe discovery using OpenAI or Ollama
- π Letter-Based Research: Systematic research organized by alphabet for comprehensive coverage
CalorIA/
βββ CalorIA/
β βββ __init__.py # Python package initialization
β βββ cli.py # Custom CLI commands
β βββ types.py # Type definitions
β βββ research/ # AI-powered research system
β β βββ __init__.py # Research package initialization
β β βββ tools.py # Base research classes and utilities
β β βββ ingredients.py # Ingredient research functionality
β β βββ recipes.py # Recipe research functionality
β βββ backend/ # Flask backend application
β β βββ app.py # Main Flask application
β β βββ requirements.txt # Python dependencies
β β βββ package-lock.json
β βββ frontend/ # React frontend application
β β βββ src/ # React source code
β β βββ public/ # Public assets
β β βββ package.json # Node.js dependencies
β β βββ build/ # Production build (generated)
β βββ mixins/ # Shared modules and routes
β βββ modules/ # Business logic modules
β β βββ activities.py # Activity tracking functionality
β β βββ ingredients.py # Ingredient management
β β βββ meals.py # Meal tracking and management
β β βββ recipes.py # Recipe management
β β βββ users.py # User management
β β βββ water.py # Water intake tracking
β β βββ weight.py # Weight tracking
β βββ routes/ # API route handlers
β β βββ __init__.py
β β βββ activity_routes.py # Activity endpoints
β β βββ auth_routes.py # Authentication endpoints
β β βββ dashboard_routes.py # Dashboard data endpoints
β β βββ health_routes.py # Health monitoring endpoints
β β βββ ingredient_routes.py # Ingredient CRUD endpoints
β β βββ meal_routes.py # Meal tracking endpoints
β β βββ recipe_routes.py # Recipe management endpoints
β β βββ user_routes.py # User management endpoints
β β βββ water_routes.py # Water intake endpoints
β β βββ weight_routes.py # Weight tracking endpoints
β βββ jwt_utils.py # JWT utilities
β βββ mongo.py # MongoDB connection utilities
β βββ tools.py # General utilities
βββ docker-compose.yml # Docker composition configuration
βββ Dockerfile # Docker image configuration
βββ setup.py # Python package setup
βββ .env.copy # Environment variables template
βββ README.md # This file
Before running the application locally, ensure you have the following installed:
- Python 3.7+: Download from python.org
- Node.js 16+: Download from nodejs.org
- MongoDB: Download from mongodb.com
-
Copy the environment template and configure your settings:
cp .env.copy .env
-
Edit the
.envfile with your configuration:MONGODB_URI=mongodb://localhost:27017/caloria FLASK_DEBUG=1 SECRET_KEY=your-secret-key-here # AI Research Configuration (optional) AI_PROVIDER=openai # or 'ollama' OPENAI_API_KEY=your_openai_api_key_here OPENAI_MODEL=gpt-4 OLLAMA_BASE_URL=http://localhost:11434 OLLAMA_MODEL=llama2
-
Clone the repository:
git clone <repository-url> cd CalorIA
-
Install Python dependencies:
pip install -r CalorIA/backend/requirements.txt
-
Install Node.js dependencies:
cd CalorIA/frontend npm install cd ../..
-
Install the CLI tool:
pip install -e . -
Start MongoDB (if running locally):
mongod
-
Seed the database (optional):
caloria seed
The caloria CLI provides several commands to manage the application:
-
caloria backend- Start the Flask backend servercaloria backend --host 127.0.0.1 --port 4032 --debug
--host: Host to bind to (default: 127.0.0.1)--port: Port to bind to (default: 4032)--debug: Run in debug mode
-
caloria frontend- Start the React development servercaloria frontend --port 3000
--port: Port for development server (default: 3000)
-
caloria build- Build the React frontend for productioncaloria build --output-dir build
--output-dir: Output directory for build (default: build)
-
caloria seed- Seed the database with sample datacaloria seed
-
caloria unseed- Remove all system-generated sample data from the databasecaloria unseed --confirm
--confirm: Confirm deletion without prompting
-
caloria research-ingredients- Research and add missing ingredients using AIcaloria research-ingredients --category Vegetables --letters A,B,C --max-ingredients 10
--category: Specific category to research (Vegetables, Proteins, Fruits, etc.)--letters: Comma-separated letters to research (e.g., "A,B,C")--max-ingredients: Maximum number of ingredients to add--dry-run: Show what would be added without actually adding
-
caloria research-recipes- Research and add missing recipes using AIcaloria research-recipes --category breakfast --letters A,B,C --max-recipes 5
--category: Specific category to research (breakfast, lunch, dinner, etc.)--letters: Comma-separated letters to research (e.g., "A,B,C")--max-recipes: Maximum number of recipes to add--dry-run: Show what would be added without actually adding
-
Start the full application (recommended for development):
# Terminal 1: Start the backend (includes building frontend) caloria backend --debug # Terminal 2: Start the frontend dev server (for hot reloading) caloria frontend
-
Production build:
caloria build caloria backend --host 0.0.0.0 --port 4032
-
AI Research Examples:
# Research vegetables starting with A, B, C caloria research-ingredients --category Vegetables --letters A,B,C --max-ingredients 15 # Research breakfast recipes (dry run) caloria research-recipes --category breakfast --dry-run # Research proteins systematically caloria research-ingredients --category Proteins --max-ingredients 20
-
Build and run the entire application:
docker-compose up --build
-
Run in detached mode:
docker-compose up -d --build
-
Stop the application:
docker-compose down
-
View logs:
docker-compose logs -f
The docker-compose configuration includes:
- app: The main CalorIA application (Flask + React)
- Exposed on port 4032
- Automatically builds frontend and runs backend
- mongo: MongoDB database
- Exposed on port 27017
- Data persisted in
mongo-datavolume
CalorIA includes an intelligent AI-powered research system that can discover and add missing ingredients and recipes to your database. The system supports both OpenAI and Ollama as AI providers.
- Letter-Based Research: Systematically research ingredients/recipes by alphabet for comprehensive coverage
- Category-Specific: Research specific categories like Vegetables, Proteins, Fruits, etc.
- Duplicate Prevention: Automatically checks for existing items before adding
- Dry Run Mode: Test research without modifying the database
- Batch Processing: Process multiple items efficiently with progress tracking
- Requires API key
- Supports GPT-3.5-turbo and GPT-4 models
- Higher quality responses
- Requires internet connection
- Runs locally on your machine
- Supports various open-source models (Llama, Mistral, etc.)
- No API costs
- Works offline
Ingredients:
- Vegetables, Fruits, Proteins, Grains & Starches
- Dairy, Oils & Fats, Nuts & Seeds
- Condiments & Sauces, Sweeteners, Spices
- Beverages, Supplements, Baking & Flours
Recipes:
- Breakfast, Lunch, Dinner, Snacks
- Desserts, Beverages, Appetizers
- Soups, Salads, Main Courses, Side Dishes
# Research vegetables starting with specific letters
caloria research-ingredients --category Vegetables --letters A,B,C,D,E
# Research breakfast recipes (systematic approach)
caloria research-recipes --category breakfast --max-recipes 10
# Dry run to see what would be added
caloria research-ingredients --category Proteins --dry-run
# Research with custom limits
caloria research-recipes --category dinner --max-recipes 5 --letters M,N,O- Get an API key from OpenAI
- Add to your
.envfile:AI_PROVIDER=openai OPENAI_API_KEY=your_api_key_here OPENAI_MODEL=gpt-4
- Install Ollama from ollama.ai
- Pull a model:
ollama pull llama2 - Add to your
.envfile:AI_PROVIDER=ollama OLLAMA_BASE_URL=http://localhost:11434 OLLAMA_MODEL=llama2
The CalorIA REST API provides the following endpoint categories:
- POST
/api/auth/login- User login - POST
/api/auth/register- User registration - POST
/api/auth/logout- User logout
- GET
/api/user/<user_id>- Get user information - POST
/api/user- Create new user - PUT
/api/user/<user_id>- Update user information - DELETE
/api/user/<user_id>- Delete user
- GET
/api/ingredients- Get all ingredients (with pagination and search)- Query parameters:
page,limit,search,is_system
- Query parameters:
- GET
/api/ingredients/<ingredient_id>- Get specific ingredient - POST
/api/ingredients- Create new ingredient - PUT
/api/ingredients/<ingredient_id>- Update ingredient - DELETE
/api/ingredients/<ingredient_id>- Delete ingredient
- GET
/api/recipes- Get all recipes (with pagination and search) - GET
/api/recipes/<recipe_id>- Get specific recipe - POST
/api/recipes- Create new recipe - PUT
/api/recipes/<recipe_id>- Update recipe - DELETE
/api/recipes/<recipe_id>- Delete recipe
- GET
/api/meals/<user_id>- Get user's meals - POST
/api/meals- Log a new meal - PUT
/api/meals/<meal_id>- Update meal information - DELETE
/api/meals/<meal_id>- Delete meal
- GET
/api/health/<user_id>- Get health status - POST
/api/health- Update health metrics
- GET
/api/weight/<user_id>- Get weight history - POST
/api/weight- Log weight entry - PUT
/api/weight/<entry_id>- Update weight entry - DELETE
/api/weight/<entry_id>- Delete weight entry
- GET
/api/water/<user_id>- Get water intake history - POST
/api/water- Log water intake - PUT
/api/water/<entry_id>- Update water entry - DELETE
/api/water/<entry_id>- Delete water entry
- GET
/api/dashboard/<user_id>- Get user dashboard data
- Backend: Flask application with Blueprint-based routing
- Frontend: React application with component-based architecture
- Database: MongoDB with PyMongo driver
- CLI: Click-based command-line interface
- Containerization: Docker with multi-stage builds
- Backend: Flask, PyMongo, Click
- Frontend: React, Node.js, npm
- Database: MongoDB
- DevOps: Docker, docker-compose
- Python: 3.7+ compatible
- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Make your changes and test them
- Commit your changes:
git commit -m 'Add feature' - Push to the branch:
git push origin feature-name - Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.