Skip to content

bybysker/Coachbot

Repository files navigation

Coachbot

Welcome to the Coachbot, a web-based tool that generates personalized workout plans based on user inputs. This app is designed to provide users with a customized training plan based on their goals, preferences, and personal details such as fitness level, frequency, equipment, and intensity.

The app leverages Flask for web interactions, WeasyPrint to create downloadable PDFs, and a custom CoachBot AI to generate workout plans.

Features

  • Form-Based Input: Users fill out a form with their details (name, age, weight, fitness goals, etc.), and the app generates a tailored gym plan.
  • AI-Powered Response: The workout plan is generated by an AI model (CoachBot) which interprets the user’s input and returns a personalized gym plan.
  • Downloadable PDF: Users can download their generated gym plan as a professionally formatted PDF.

Requirements

  • Python (3.8+)
  • Flask
  • WeasyPrint
  • dotenv

You can install the dependencies via pip:

pip install Flask WeasyPrint python-dotenv

Setup

  1. Clone the Repository:

    git clone <repository-url>
    cd gymplan-generator-app
  2. Install Dependencies:

    pip install -r requirements.txt
  3. Environment Variables:
    Ensure a .env file exists with your environment settings. For example, you can add your app’s secret key:

    SECRET_KEY=supersecretkey
    
  4. Run the App:

    python app.py

    This will start the Flask server at http://127.0.0.1:5000/.

How to Use

  1. Navigate to the app’s homepage (http://127.0.0.1:5000/).
  2. Fill out the form with your personal details such as name, age, weight, fitness level, goals, and training preferences.
  3. Submit the form to receive a personalized gym plan generated by the AI (CoachBot).
  4. You can download the gym plan as a PDF by clicking on the "Download PDF" button.

Endpoints

/

  • Method: GET, POST
  • Description: Renders the main form where users input their details to generate a gym plan.

/generate_gymplan

  • Method: POST
  • Description: Handles the form submission, processes the user input, and generates a personalized gym plan using the CoachBot. The result is rendered in HTML format on the page.

/download_pdf

  • Method: GET, POST
  • Description: Allows the user to download the generated gym plan as a PDF. The HTML response is converted to a styled PDF using WeasyPrint.

File Structure

├── app/
│   ├── __pycache__/
│   ├── static/
│   │   ├── css/                  # Stylesheets (includes gymplan_style_pdf.css)
│   │   └── js/                   # Javascript files (if any)
│   ├── templates/                # HTML templates
│   │   ├── gymplan.html
│   │   ├── gymplan2pdf.html
│   │   └── index2.html
│   ├── __init__.py               # Initialization for the app (optional, good for scalability)
│   ├── routes.py                 # Handles the routes (endpoints)
│   ├── forms.py                  # If you need to handle form validation logic, separate this here (optional)
│   └── utils.py                  # Helper functions, possibly PDF generation or chatbot interactions
├── coachbot/
│   ├── __init__.py               # Init file for CoachBot
│   ├── coach.py                  # Main CoachBot logic (existing coachbot.py)
│   ├── config.py                 # Configuration for the bot responses (includes gymplan header/footer)
│   ├── prompts.py                # Predefined prompts, if you have many prewritten prompts
├── .env                          # Environment variables
├── Dockerfile                    # Docker setup for containerization
├── requirements.txt              # Python package dependencies
├── README.md                     # Documentation (this file)
├── Untitled-1.ipynb              # Jupyter notebook (assuming this is for testing/exploring code)
├── cloudbuild.yaml               # Cloud build configuration
└── script.sh                     # Deployment or setup scripts

Customization

You can easily customize the form fields or adjust the way the gym plan is generated by editing the relevant sections in app.py or modifying the CoachBot in coachbot.py.

Changing Templates

  • To modify the user interface, edit templates/index2.html.
  • The structure of the generated gym plan (HTML and PDF) is defined in config.py with gymplan_header and gymplan_tail for the PDF's header and footer.

Adding New Fields

To add new fields to the form:

  1. Add the new input field in the HTML (index2.html).
  2. Update the form processing logic in the /generate_gymplan route of app.py.

License

This project is licensed under the MIT License. Feel free to use, modify, and distribute it as needed.


Feel free to reach out with any questions or suggestions! Happy training with your personalized GymPlan! 💪