Home
Softono
calorie-contra

calorie-contra

Open source MIT HTML
13
Stars
0
Forks
0
Issues
1
Watchers
1 year
Last Commit

About calorie-contra

A calorie counter web app that searches for food and keeps tracks of your macros and calories, embedded with a nutritionist chatbot

Platforms

Web Self-hosted

Languages

HTML

Calorie Contra

Demo

Calorie Contra

Description

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.

Usage

  1. Clone this repository

     git clone https://github.com/jericho1050/calorie-contra.git
  2. Create a virtual environment

     virtualenv env

    or

     python -m venv env

    then activate it

     # MacOS
     source env/bin/activate
     # Windows
     .\env\Scripts\activate
  3. Install the dependencies

     pip install -r requirements.txt
  4. 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
  5. Run the server

     python app.py

Walkthrough

app.py Routes

/home (GET, POST)

  • 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.

/search (GET)

  • Purpose: Returns a list of foods matching the search query.
  • Methods:
    • GET: Renders the search results page.

/api/search_foods (GET)

  • Purpose: API endpoint to search for foods using the USDA FoodData Central API.
  • Methods:
    • GET: Returns JSON data of the search results.

/login (GET, POST)

  • Purpose: Logs the user in.
  • Methods:
    • GET: Renders the login page.
    • POST: Authenticates the user and starts a session.

/register (GET, POST)

  • Purpose: Registers a new user.
  • Methods:
    • GET: Renders the registration page.
    • POST: Processes the registration form and creates a new user.

/logout (GET)

  • Purpose: Logs the user out.
  • Methods:
    • GET: Clears the session and redirects to the home page.

/food/<int:id> (GET)

  • Purpose: Displays the selected food's nutrition facts.
  • Methods:
    • GET: Renders the food details page.

/food-log (GET, POST)

  • 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.

/generate (POST)

  • Purpose: Generates a response using the generative AI model.
  • Methods:
    • POST: Processes the user's input and returns the AI-generated response.

Test

TODO

Contribution Guideline

TODO