# sivayerasi/habit_tracker_cli- architecture

> Architecture diagram of the GitHub repository sivayerasi/habit_tracker_cli-, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sivayerasi/habit_tracker_cli-
- Repository: https://github.com/sivayerasi/habit_tracker_cli-

## Overview

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: [`core/storage.py`](https://github.com/sivayerasi/habit_tracker_cli-/blob/main/core/storage.py) (JSON storage), [`habit.py`](https://github.com/sivayerasi/habit_tracker_cli-/blob/main/habit.py) (Command router), [`utils/display.py`](https://github.com/sivayerasi/habit_tracker_cli-/blob/main/utils/display.py) (Terminal formatters), [`commands/log.py`](https://github.com/sivayerasi/habit_tracker_cli-/blob/main/commands/log.py) (Record log)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI entry"]
  node_cli["Command router<br/>[habit.py]"]
end

subgraph group_commands["Habit commands"]
  node_add["Add habit<br/>[add.py]"]
  node_edit["Edit habit<br/>[edit.py]"]
  node_delete["Delete habit<br/>[delete.py]"]
  node_list["List habits<br/>[list.py]"]
  node_log["Record log<br/>[log.py]"]
  node_status["Daily status<br/>[status.py]"]
  node_history["Habit history<br/>[history.py]"]
  node_streak["Streak report<br/>[streak.py]"]
  node_summary["Weekly summary<br/>[summary.py]"]
end

subgraph group_core["Domain and storage"]
  node_models["Habit and log models<br/>[models.py]"]
  node_storage["JSON storage<br/>[storage.py]"]
  node_habits_data[("Habit records<br/>[habits.json]")]
  node_logs_data[("Daily log records<br/>[logs.json]")]
end

subgraph group_reporting["Reporting and display"]
  node_dates["Date utilities<br/>[date_utils.py]"]
  node_streak_engine["Streak calculations<br/>[streak_engine.py]"]
  node_display["Terminal formatters<br/>[display.py]"]
end

node_user(("CLI user"))

node_user -->|"runs command"| node_cli
node_cli -->|"routes add"| node_add
node_cli -->|"routes edit"| node_edit
node_cli -->|"routes delete"| node_delete
node_cli -->|"routes list"| node_list
node_cli -->|"routes log"| node_log
node_cli -->|"routes status"| node_status
node_cli -->|"routes history"| node_history
node_cli -->|"routes streak"| node_streak
node_cli -->|"routes summary"| node_summary
node_add -->|"creates habit"| node_models
node_add -->|"loads and saves"| node_storage
node_add -->|"gets today"| node_dates
node_edit -->|"loads and saves"| node_storage
node_edit -->|"prints habit list"| node_display
node_delete -->|"updates records"| node_storage
node_delete -->|"prints habit list"| node_display
node_list -->|"loads habits"| node_storage
node_list -->|"prints habit list"| node_display
node_log -->|"creates log"| node_models
node_log -->|"reads and writes logs"| node_storage
node_log -->|"validates date"| node_dates
node_log -->|"prints habit list"| node_display
node_status -->|"loads records"| node_storage
node_status -->|"gets today"| node_dates
node_status -->|"formats status"| node_display
node_history -->|"loads records"| node_storage
node_history -->|"builds date range"| node_dates
node_history -->|"formats history"| node_display
node_streak -->|"loads records"| node_storage
node_streak -->|"formats streaks"| node_display
node_summary -->|"loads records"| node_storage
node_summary -->|"formats summary"| node_display
node_storage -->|"serializes records"| node_models
node_storage -->|"reads and writes"| node_habits_data
node_storage -->|"reads and writes"| node_logs_data
node_display -->|"calculates streaks"| node_streak_engine
node_display -->|"uses date helpers"| node_dates
node_streak_engine -->|"reads log records"| node_models

click node_cli "https://github.com/sivayerasi/habit_tracker_cli-/blob/main/habit.py"
click node_add "https://github.com/sivayerasi/habit_tracker_cli-/blob/main/commands/add.py"
click node_edit "https://github.com/sivayerasi/habit_tracker_cli-/blob/main/commands/edit.py"
click node_delete "https://github.com/sivayerasi/habit_tracker_cli-/blob/main/commands/delete.py"
click node_list "https://github.com/sivayerasi/habit_tracker_cli-/blob/main/commands/list.py"
click node_log "https://github.com/sivayerasi/habit_tracker_cli-/blob/main/commands/log.py"
click node_status "https://github.com/sivayerasi/habit_tracker_cli-/blob/main/commands/status.py"
click node_history "https://github.com/sivayerasi/habit_tracker_cli-/blob/main/commands/history.py"
click node_streak "https://github.com/sivayerasi/habit_tracker_cli-/blob/main/commands/streak.py"
click node_summary "https://github.com/sivayerasi/habit_tracker_cli-/blob/main/commands/summary.py"
click node_models "https://github.com/sivayerasi/habit_tracker_cli-/blob/main/core/models.py"
click node_storage "https://github.com/sivayerasi/habit_tracker_cli-/blob/main/core/storage.py"
click node_habits_data "https://github.com/sivayerasi/habit_tracker_cli-/blob/main/data/habits.json"
click node_logs_data "https://github.com/sivayerasi/habit_tracker_cli-/blob/main/data/logs.json"
click node_dates "https://github.com/sivayerasi/habit_tracker_cli-/blob/main/utils/date_utils.py"
click node_streak_engine "https://github.com/sivayerasi/habit_tracker_cli-/blob/main/core/streak_engine.py"
click node_display "https://github.com/sivayerasi/habit_tracker_cli-/blob/main/utils/display.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_user toneBlue
class node_add,node_edit,node_delete,node_list,node_log,node_status,node_history,node_streak,node_summary toneAmber
class node_models,node_storage,node_habits_data,node_logs_data toneMint
class node_dates,node_streak_engine,node_display toneRose
```

## Components

### CLI entry

- [Command router](https://github.com/sivayerasi/habit_tracker_cli-/blob/main/habit.py): `habit.py`

### Habit commands

- [Add habit](https://github.com/sivayerasi/habit_tracker_cli-/blob/main/commands/add.py): `commands/add.py`
- [Edit habit](https://github.com/sivayerasi/habit_tracker_cli-/blob/main/commands/edit.py): `commands/edit.py`
- [Delete habit](https://github.com/sivayerasi/habit_tracker_cli-/blob/main/commands/delete.py): `commands/delete.py`
- [List habits](https://github.com/sivayerasi/habit_tracker_cli-/blob/main/commands/list.py): `commands/list.py`
- [Record log](https://github.com/sivayerasi/habit_tracker_cli-/blob/main/commands/log.py): `commands/log.py`
- [Daily status](https://github.com/sivayerasi/habit_tracker_cli-/blob/main/commands/status.py): `commands/status.py`
- [Habit history](https://github.com/sivayerasi/habit_tracker_cli-/blob/main/commands/history.py): `commands/history.py`
- [Streak report](https://github.com/sivayerasi/habit_tracker_cli-/blob/main/commands/streak.py): `commands/streak.py`
- [Weekly summary](https://github.com/sivayerasi/habit_tracker_cli-/blob/main/commands/summary.py): `commands/summary.py`

### Domain and storage

- [Habit and log models](https://github.com/sivayerasi/habit_tracker_cli-/blob/main/core/models.py): `core/models.py`
- [JSON storage](https://github.com/sivayerasi/habit_tracker_cli-/blob/main/core/storage.py): `core/storage.py`
- [Habit records](https://github.com/sivayerasi/habit_tracker_cli-/blob/main/data/habits.json): `data/habits.json`
- [Daily log records](https://github.com/sivayerasi/habit_tracker_cli-/blob/main/data/logs.json): `data/logs.json`

### Reporting and display

- [Date utilities](https://github.com/sivayerasi/habit_tracker_cli-/blob/main/utils/date_utils.py): `utils/date_utils.py`
- [Streak calculations](https://github.com/sivayerasi/habit_tracker_cli-/blob/main/core/streak_engine.py): `core/streak_engine.py`
- [Terminal formatters](https://github.com/sivayerasi/habit_tracker_cli-/blob/main/utils/display.py): `utils/display.py`

### Other components

- **CLI user**

## Connections

- CLI user → Command router: runs command (evidence: `README.md`)
- Command router → Add habit: routes add (evidence: `habit.py`)
- Command router → Edit habit: routes edit (evidence: `habit.py`)
- Command router → Delete habit: routes delete (evidence: `habit.py`)
- Command router → List habits: routes list (evidence: `habit.py`)
- Command router → Record log: routes log (evidence: `habit.py`)
- Command router → Daily status: routes status (evidence: `habit.py`)
- Command router → Habit history: routes history (evidence: `habit.py`)
- Command router → Streak report: routes streak (evidence: `habit.py`)
- Command router → Weekly summary: routes summary (evidence: `habit.py`)
- Add habit → Habit and log models: creates habit (evidence: `commands/add.py`)
- Add habit → JSON storage: loads and saves (evidence: `commands/add.py`)
- Add habit → Date utilities: gets today (evidence: `commands/add.py`)
- Edit habit → JSON storage: loads and saves (evidence: `commands/edit.py`)
- Edit habit → Terminal formatters: prints habit list (evidence: `commands/edit.py`)
- Delete habit → JSON storage: updates records (evidence: `commands/delete.py`)
- Delete habit → Terminal formatters: prints habit list (evidence: `commands/delete.py`)
- List habits → JSON storage: loads habits (evidence: `commands/list.py`)
- List habits → Terminal formatters: prints habit list (evidence: `commands/list.py`)
- Record log → Habit and log models: creates log (evidence: `commands/log.py`)
- Record log → JSON storage: reads and writes logs (evidence: `commands/log.py`)
- Record log → Date utilities: validates date (evidence: `commands/log.py`)
- Record log → Terminal formatters: prints habit list (evidence: `commands/log.py`)
- Daily status → JSON storage: loads records (evidence: `commands/status.py`)
- Daily status → Date utilities: gets today (evidence: `commands/status.py`)
- Daily status → Terminal formatters: formats status (evidence: `commands/status.py`)
- Habit history → JSON storage: loads records (evidence: `commands/history.py`)
- Habit history → Date utilities: builds date range (evidence: `commands/history.py`)
- Habit history → Terminal formatters: formats history (evidence: `commands/history.py`)
- Streak report → JSON storage: loads records (evidence: `commands/streak.py`)
- Streak report → Terminal formatters: formats streaks (evidence: `commands/streak.py`)
- Weekly summary → JSON storage: loads records (evidence: `commands/summary.py`)
- Weekly summary → Terminal formatters: formats summary (evidence: `commands/summary.py`)
- JSON storage → Habit and log models: serializes records (evidence: `core/storage.py`)
- JSON storage → Habit records: reads and writes (evidence: `core/storage.py`)
- JSON storage → Daily log records: reads and writes (evidence: `core/storage.py`)
- Terminal formatters → Streak calculations: calculates streaks (evidence: `utils/display.py`)
- Terminal formatters → Date utilities: uses date helpers (evidence: `utils/display.py`)
- Streak calculations → Habit and log models: reads log records (evidence: `core/streak_engine.py`)
