How sivayerasi/habit_tracker_cli- works
Habit Tracker is a local Python CLI for defining habits, recording done or skipped days, and reviewing status, history, streaks, and weekly progress. The principal workflow routes a user’s command through the CLI entry point to a command handler; handlers read or update JSON-backed habits and logs, while reporting handlers pass data to terminal formatters. Core models, date utilities, and streak calculations support these operations. The README documents all major commands; some command implementations were not excerpted, so their links rely on the SOURCE INDEX references.
Main entry points: storage.py JSON storage · habit.py Command router · display.py Terminal formatters · log.py Record log
Components 18
CLI entry
- Command router
habit.py
Habit commands
- Add habit
commands/add.py - Edit habit
commands/edit.py - Delete habit
commands/delete.py - List habits
commands/list.py - Record log
commands/log.py - Daily status
commands/status.py - Habit history
commands/history.py - Streak report
commands/streak.py - Weekly summary
commands/summary.py
Domain and storage
- Habit and log models
core/models.py - JSON storage
core/storage.py - Habit records
data/habits.json - Daily log records
data/logs.json
Reporting and display
- Date utilities
utils/date_utils.py - Streak calculations
core/streak_engine.py - Terminal formatters
utils/display.py
Other components
- CLI user
Connections 39
- CLI user → Command router: runs command
README.md - Command router → Add habit: routes add
habit.py - Command router → Edit habit: routes edit
habit.py - Command router → Delete habit: routes delete
habit.py - Command router → List habits: routes list
habit.py - Command router → Record log: routes log
habit.py - Command router → Daily status: routes status
habit.py - Command router → Habit history: routes history
habit.py - Command router → Streak report: routes streak
habit.py - Command router → Weekly summary: routes summary
habit.py - Add habit → Habit and log models: creates habit
commands/add.py - Add habit → JSON storage: loads and saves
commands/add.py - Add habit → Date utilities: gets today
commands/add.py - Edit habit → JSON storage: loads and saves
commands/edit.py - Edit habit → Terminal formatters: prints habit list
commands/edit.py - Delete habit → JSON storage: updates records
commands/delete.py - Delete habit → Terminal formatters: prints habit list
commands/delete.py - List habits → JSON storage: loads habits
commands/list.py - List habits → Terminal formatters: prints habit list
commands/list.py - Record log → Habit and log models: creates log
commands/log.py - Record log → JSON storage: reads and writes logs
commands/log.py - Record log → Date utilities: validates date
commands/log.py - Record log → Terminal formatters: prints habit list
commands/log.py - Daily status → JSON storage: loads records
commands/status.py - Daily status → Date utilities: gets today
commands/status.py - Daily status → Terminal formatters: formats status
commands/status.py - Habit history → JSON storage: loads records
commands/history.py - Habit history → Date utilities: builds date range
commands/history.py - Habit history → Terminal formatters: formats history
commands/history.py - Streak report → JSON storage: loads records
commands/streak.py - Streak report → Terminal formatters: formats streaks
commands/streak.py - Weekly summary → JSON storage: loads records
commands/summary.py - Weekly summary → Terminal formatters: formats summary
commands/summary.py - JSON storage → Habit and log models: serializes records
core/storage.py - JSON storage → Habit records: reads and writes
core/storage.py - JSON storage → Daily log records: reads and writes
core/storage.py - Terminal formatters → Streak calculations: calculates streaks
utils/display.py - Terminal formatters → Date utilities: uses date helpers
utils/display.py - Streak calculations → Habit and log models: reads log records
core/streak_engine.py