Description:
Hydration Tracker is an intuitive application designed to help you stay hydrated throughout the day. It allows you to set daily water intake goals, track your water consumption, and receive reminders to drink water at regular intervals. With its customizable features, the app ensures you maintain optimal hydration levels for improved health and well-being.
- Set personalized daily water intake goals.
- Log water consumption with ease.
- Receive reminders to drink water at regular intervals.
- View daily, weekly, and monthly hydration statistics.
- Customize reminder intervals and notification settings.
- Notifications via desktop, email, and WhatsApp.
- Programming Language: Python
- Database: MySQL
- Version Control: Git
-
Clone the Repository:
git clone https://github.com/yourusername/hydration-tracker.git
-
Navigate to the Project Directory:
cd hydration-tracker
-
Install Dependencies:
pip install -r requirements.txt
-
Create a Virtual Environment:
python -m venv venv
-
Activate the Virtual Environment:
- On Windows:
venv\Scripts\activate
- On macOS/Linux:
source venv/bin/activate
- On Windows:
-
Configure Environment Variables:
- Copy the
.env.example
file to.env
and fill in the required values.cp .env.example .env
- Copy the
-
Set Up the Database:
- Configure the MySQL database and update the settings in the project configuration.
-
Run the Application:
python main.py
The core script that orchestrates the application’s functionality.
Responsibilities:
- Configures logging with daily rotation.
- Ensures the
logs
folder exists. - Manages threads for sending notifications and updating hydration logs.
- Opens another terminal to run
follow_latest_log.py
. - Handles graceful shutdown using signal handling.
Manages sending hydration reminders and notifications.
Responsibilities:
- Sends desktop notifications via the
plyer
library. - Sends email reminders using
channels/email_notification.py
. - Sends WhatsApp messages using
channels/whatsapp_notification.py
. - Prompts users to confirm water intake in the terminal.
- Logs hydration reminders and weekly goals to the database.
Handles database interactions and provides a CLI for updating hydration logs.
Responsibilities:
- Initializes the database and creates necessary tables.
- Fetches the last hydration log time and email log time.
- Logs hydration reminders and email statuses to the database.
- Checks and logs weekly hydration goals.
- Provides a CLI to update pending hydration logs.
Handles sending email notifications.
Responsibilities:
- Sends email reminders using the SMTP protocol.
- Logs the status of email notifications to the database.
Handles sending WhatsApp notifications.
Responsibilities:
- Sends WhatsApp messages using the
pywhatkit
library. - Logs the status of WhatsApp notifications.
Monitors logs dynamically.
Responsibilities:
- Finds the latest log file based on creation time.
- Follows the latest log file, similar to
tail -f
.
-
Run the Application:
python main.py
-
Follow Logs:
- The
main.py
script will automatically open another terminal and runfollow_latest_log.py
to monitor logs dynamically.
- The
-
Update Logs Using CLI:
python utils/db_utils.py
-
Stop the Application:
- Use
Ctrl+C
to stop the script gracefully.
- Use
hydration/
├── channels/
│ ├── email_notification.py
│ └── whatsapp_notification.py
├── utils/
│ └── db_utils.py
├── follow_latest_log.py
├── main.py
└── handlers/
└── notification_handler.py
main.py
: Manages the application lifecycle, logging, and opens a terminal to follow logs.notification_handler.py
: Sends reminders and logs hydration data.db_utils.py
: Handles database interactions and provides a CLI.email_notification.py
: Sends email notifications.whatsapp_notification.py
: Sends WhatsApp notifications.follow_latest_log.py
: Monitors logs dynamically.
This robust setup ensures smooth operation and easy tracking of your hydration habits.