This calorie counter and food search web app is for individuals who want to track their calories and macros throughout the day and week. For searching data, it uses a REST API from the USDA FDC API. It is also embedded with a chatbot that helps you achieve your goals.
-
Clone this repository
git clone https://github.com/jericho1050/calorie-contra.git
-
Create a virtual environment
virtualenv env
or
python -m venv env
then activate it
# MacOS source env/bin/activate
# Windows .\env\Scripts\activate
-
Install the dependencies
pip install -r requirements.txt
-
Create a
.env
file for API keys and secret variables# .env api_key = "your_api_key_here" # https://fdc.nal.usda.gov/api-key-signup.html SECRET_KEY = "your_secret_key_here" gemini_api_key = "your_api_key_here" # https://ai.google.dev
-
Run the server
python app.py
- Purpose: Displays the search form and handles search queries.
- Methods:
GET
: Renders the home page.POST
: Processes the search query and redirects to the search results.
- Purpose: Returns a list of foods matching the search query.
- Methods:
GET
: Renders the search results page.
- Purpose: API endpoint to search for foods using the USDA FoodData Central API.
- Methods:
GET
: Returns JSON data of the search results.
- Purpose: Logs the user in.
- Methods:
GET
: Renders the login page.POST
: Authenticates the user and starts a session.
- Purpose: Registers a new user.
- Methods:
GET
: Renders the registration page.POST
: Processes the registration form and creates a new user.
- Purpose: Logs the user out.
- Methods:
GET
: Clears the session and redirects to the home page.
- Purpose: Displays the selected food's nutrition facts.
- Methods:
GET
: Renders the food details page.
- Purpose: Displays and updates the user's food log.
- Methods:
GET
: Renders the food log page.POST
: Adds a new food entry to the user's log.
- Purpose: Generates a response using the generative AI model.
- Methods:
POST
: Processes the user's input and returns the AI-generated response.
TODO
TODO