Conception and construction of a CRUD habit tracker with some analytical functionality. -> Backend + CLI
The core functionality of the habit tracker are:
- Add habit
- Remove habit
- Add a description of the habit
- Define the tracking frequency of habits (Daily or weekly)
- Checkoff a habit once it is done for its frenquence
- get a reminder if a habid period got missed
- get some congratulation if a habit successfully got tracked for 2 weeks
The tracker allows some analytical actions like:
- View all habits from the DB and its core data
- View all habits from the DB specified by a certain linked periodicity
- View the longest streak of all habits
- return the longest streak for a given habit
Make sure Python 3.12 + is installed on your OS.
- Python 3.12 +
- Questionary
- sqlite3 (already included in the python package)
- datetime
Check your local python version and if required download the latest version of Python from this link - [Make sure to check "ADD to path" in the Python installer.]
After installing Python, proceed with the installation of the following libraries:
-
Questionary
pip install questionary
-
datetime
pip install datetime
To ensure the validity of the habit tracker, its habit tracking components and the analytics module get tested by a unit test suite. To run the tests, you will need the following packages installed: Pytest - For testing functions:
pip install -U pytest
Also change the Database from main.db to test.db.
Upon completing the installation of the necessary dependencies, download the files from this repository and store them in a separate folder. Access your terminal and navigate to the downloaded folder. Input the following command to run the program:
python3 main.py
Now the habit tracker CLI will be launched and you can follow the displayed options in the CLI.
There are 5 predefined habits that the user can delete later.
To run the test, navigate to the test folder and type
pytest
Follow the instructions on your CLI after starting the programm. For navigation use the arrow-keys of your keyboard. Confirm with the enter-key.
The user can edit the descriptiption or the habit frequency.
The user is asked to check off a habit at least once in the predefined periodicity. He can do so by selecting this option from the main menu. A habit can just be checked off once in a period. The checking off of a habit gets registered by the period_count by +1. The period count resets to 0 if a habit gets missed in the preset period. In the period_archive the highest value of the period counter gets stored in a list. Like that the trackking data can be analyzed later.
Shows a table of all the stored habits along with their information of Name, Description, Periodicity.
The following operations can get analysed by the habit tracker:
- return a list of all currently tracked habits.
- return a list of all habits with the same frequency (daily, weekly).
- return the longest run streak of all defined habits (→ checks the streak_archive and streak_count for the highest nr among all habits)
- return the longest streak for a given habit (→ checks the streak_archive and streak_count of a given habit)