A clean Python CLI tool to track daily habits, compute streaks, score consistency, and visualize progress over time.
Building good habits is hard. Knowing whether you're actually improving is harder. This project is a lightweight command-line habit tracker that does three things:
- Logs your daily habits in a CSV (no database setup needed)
- Analyzes patterns β streaks, completion rates, best/worst habits
- Visualizes progress through clean matplotlib charts
Built as a self-driven Python project to practice data handling, CSV I/O, and modular code design.
- β Add habits with a single command
- β Mark habits done for any given day
- π Show today's status, all habits, or delete unwanted ones
- π₯ Streaks β current and longest streaks per habit
- π Completion rates β % of days completed since habit was started
- π Best & worst habit β weighted score based on consistency and streaks
- π Visualizations β bar charts, progress lines, daily activity trends
- πΎ Local storage β all data lives in
data/habits.csv
- Python 3.10+ β uses
match/casesyntax - Pandas β data manipulation and analysis
- NumPy β numerical operations (cumulative sums for progress charts)
- Matplotlib β all visualizations
- CSV β lightweight, human-readable storage
Habit Tracker/
βββ data/
β βββ habits.csv # All habit logs live here
βββ src/
β βββ main.py # Entry point β menu loop
β βββ tracker.py # CRUD operations (add, mark, delete)
β βββ insights.py # Stats engine (streaks, rates, scores)
β βββ visualizer.py # Matplotlib charts
βββ requirements.txt
βββ README.md
The project follows a clean separation of concerns pattern:
βββ> tracker.py (write to CSV)
βββ> insights.py (analyze CSV)
βββ> visualizer.py (plot from CSV)
β
βΌ
data/habits.csv (single source of truth)Each module has one job:
tracker.pyβ only writesinsights.pyβ only reads + computesvisualizer.pyβ only reads + plots
python >= 3.10# Clone the repo
git clone https://github.com/tanmaytiwari37/Habit-Tracker.git
cd Habit-Tracker
# Create virtual environment
python -m venv .venv
# Activate (Windows)
.venv\Scripts\activate
# Activate (Mac/Linux)
source .venv/bin/activate
# Install dependencies
pip install -r requirements.txtpython src/main.pysrc/ β the data path is relative.
=== Habit Tracker ===
Add Habit
Mark Habit as Done
Show Today's Status
View Stats
Visualize Data
Show All Habits
Delete Habit
Exit
π₯ Your Streaks:
Current Longest
Study 5 12
Walk 3 8
Journal 0 4
β
Your Completion Rates:
Start Date Days Missed Completion Rate
Study 2025-01-05 2 93.5
Walk 2025-01-03 7 82.1
Journal 2025-01-08 15 45.2
Walks through each habit's history chronologically, carrying forward the current streak. If yesterday was marked done, increment. If broken, reset. Track the maximum seen.
if status == 1 and (today - prev_date).days == 1:
current_streak += 1
else:
current_streak = 1 if status == 1 else 0
best_streak = max(best_streak, current_streak)A weighted heuristic combining 3 signals:
Score = (Completion Rate / 1.4)
+ (Current Streak % / 2)
+ (Longest Streak % / 4)
The habit with the highest score is your "Best Habit" β the one with both consistency and recent momentum.
Uses np.cumsum to create a line that rises on consecutive days and dips on gaps β a smooth visual signal of consistency vs. relapse.
date,habits,status
2025-01-03,Walk,1
2025-01-04,Walk,1
2025-01-05,Study,0| Column | Type | Meaning |
|---|---|---|
date |
ISO date | When the entry was logged |
habits |
string | Habit name (title-cased) |
status |
0 or 1 | 0 = missed, 1 = completed |
- Modular design β splitting CRUD, analysis, and visualization into separate files
- Pandas β
groupby,iterrows, filtering, joins, and time-delta arithmetic - The accumulator pattern β carrying state across loop iterations (used in streak logic)
- Matplotlib β bar charts, line plots, and date-axis formatting
- DRY principle β visualizer reuses
show_completion_rates()from insights instead of duplicating logic
Tanmay Tiwari β 1st-year B.Tech Aerospace Engineering, VIT Bhopal
- π GitHub: @tanmaytiwari37
- π§ itanmaytiwari37@gmail.com
- π― Currently exploring: data analysis, Python tooling, and ML for engineering applications
This project is licensed under the MIT License β feel free to use, modify, and learn from it.
Built as a self-study project to deepen Python and Pandas skills.