A simple and effective Habit Tracker built with Python. This application allows users to track and analyze their daily and weekly habits, set goals, and monitor their progress over time.
- Create Habits: Create new daily and weekly habits.
- Track Habit Completion: Mark tasks as completed for daily/weekly habits.
- Analytics: Analyze your habit progress with streaks and completion data.
- Persistent Data Storage: Habit data is stored in a file to retain progress between sessions.
- Command-line Interface (CLI): Interact with the habit tracker through a simple CLI.
- Python 3.7 or later
pytest
orunittest
for testing purposes
-
Clone this repository to your local machine:
git clone https://github.com/ONEONUORA/Habit-Tracker.git cd habit-tracker
-
Set up a virtual environment:
python -m venv venv
-
Activate the virtual environment:
- On Windows:
.\venv\Scripts\activate
- On macOS/Linux:
source venv/bin/activate
-
Install the dependencies:
pip install -r requirements.txt
-
Create a Habit
To create a habit, use the following command:
python main.py create-habit
You'll be prompted to enter:
- Habit name
- Habit description
- Habit period (daily or weekly)
Example:
$ python main.py create-habit Habit name: Exercise Habit description: Morning workout Habit period (daily/weekly): daily
-
Complete a Habit
To mark a habit as completed, use the following command:
python main.py complete-habit habit name:
Example:
$ python main.py complete-habit --name "Exercise"
-
List All Habits
To list all currently tracked habits:
python main.py list-habits
-
List Habits by Period
To list habits based on their periodicity (daily or weekly):
python main.py list-habits-by-period --period "daily"
-
View Analytics
To view the longest streak for all habits:
python main.py longest-overall-streak
To view the longest streak for a specific habit:
python main.py longest-streak Habit name: "Enter habit name"
Unit tests are provided for the core functionality of the Habit Tracker. To run the tests, use pytest:
- Install pytest if you haven't already:
pip install pytest
- Run the tests:
pytest
habit-tracker/
├── src/
│ ├── analytics/
│ │ └── analyzer.py
│ ├── cli/
│ │ └── interface.py
│ ├── models/
│ │ └── habit.py
│ ├── storage/
│ └── database.py
│
├── tests/
│ └── test_analytics.py
| |__test_database.py
│ └── test_habit.py
└── README.md
|___requirements.txt
|__ main.py
If you'd like to contribute to this project, feel free to open an issue or submit a pull request.
Fork the repository.
Create a new branch (git checkout -b feature-name)
.
Commit your changes (git commit -am 'Add feature')
.
Push to the branch (git push origin feature-name)
.
Create a new pull request.
This project is licensed under the MIT License.
### Key Sections in the README:
- **Features**: Highlights the core functionality of the project.
- **Installation**: Provides clear steps on how to set up the project.
- **Usage**: Describes how to interact with the Habit Tracker via the command line.
- **Tests**: Instructions for running unit tests.
- **Project Structure**: Shows the layout of the project files and directories.
- **Contributing**: Encourages open-source collaboration with contribution guidelines.
- **License**: Indicates that the project is licensed under the MIT License.
---