Food Logging Automation is a modular project designed to streamline logging food intake into the Lose It! website using Selenium automation. Users can submit their food details to a custom GPT which responds with formatted food item details ready for logging. The system automatically updates water intake when drinks or soups are logged.
It integrates with the Estimate Nutritional Info GPT, allowing users to query nutritional information. By copying the GPT's output into the web interface, the system logs meals, nutritional details, and updates water intake accurately.
The application uses Google OAuth 2.0 for secure authentication. Originally deployed on Heroku, the project has now been migrated entirely to a Windows 11 desktop environment. (Cloudflare is used solely for DNS A record hosting.)
-
Automated Food and Water Logging:
Seamlessly log meals by querying nutritional info via GPT. The automation script automatically logs water intake when applicable. -
Flask Web Application:
Provides a user-friendly interface for entering food data and processing GPT results. -
Secure Google OAuth 2.0 Authentication:
Ensures that only authenticated users can log food. -
Accurate Data Logging:
Verifies that the nutritional data logged into Lose It! matches the user’s input. -
Comprehensive Error Handling and Logging:
Detailed logging and error reporting aid in troubleshooting.
This is the main interface where users enter food data or paste nutritional info retrieved from GPT.
After submitting food data, it automatically appears on your Lose It! account.
After submitting a drink or soup, the water intake is automatically updated in your Lose It! account.
-
Query Nutritional Info via GPT:
Users ask the Estimate Nutritional Info GPT about a meal. The GPT provides detailed nutritional data formatted for logging. -
Copy Results to Web App:
The GPT output is pasted into the web app’s interface. -
Automated Logging:
- Food Logging: Selenium logs into Lose It!, navigates the site, and logs the provided food data.
- Water Intake Logging: When applicable, the script automatically updates water intake based on the logged food item.
-
Validation:
The system verifies that the data logged matches the input provided. -
Results:
A confirmation message is displayed once logging is complete, and the logged data appears on Lose It!.
-
Clone the Repository:
git clone https://github.com/yourusername/automated-food-logger.git cd automated-food-logger
-
Set Up the Environment:
- Create and activate a Python virtual environment:
python -m venv venv venv\Scripts\activate.bat
- Install the required packages:
pip install --upgrade pip pip install -r requirements.txt
- Create and activate a Python virtual environment:
-
Running the Application:
- Development Mode:
Usestart_dev.bat
to stop the production service, activate the virtual environment, setENV=dev
, and start the Flask development server on port 5001.
Access the app at http://localhost:5001/foodlog. - Production Mode:
Usestart_prod.bat
to stop any development instance and start the Flask app as a Windows service (managed by NSSM, service name: FoodLogApp). Nginx (configured for SSL) proxies external requests (e.g., https://theespeys.com/foodlog) to port 5001.
- Development Mode:
-
Additional Setup (Optional):
- Configure Nginx for reverse proxy and SSL termination using Let’s Encrypt certificates (obtained via win-acme).
- Use NSSM to manage the Flask app and Nginx as Windows services.
- Authentication: Google OAuth 2.0 in
app.py
secures user access. - Food Log Processing:
- Users input food data at
/foodlog
. - On submission,
scripts/main.py
orchestrates:- Parsing input with
scripts/utils.py
. - Navigating the Lose It! website using
scripts/navigation.py
. - Entering food details via
scripts/food_entry.py
. - Updating water intake with
scripts/water_intake.py
. - Validating logged data.
- Parsing input with
- Users input food data at
- Error Handling:
Theretry_on_failure
decorator in various modules automatically retries Selenium operations upon common failures.
MIT License