Skip to content

Habit_Tracker_Python is a lightweight, extensible habit tracker written in Python that helps you define, record, and analyze daily habits. Track completions, monitor streaks and long-term progress, and export your data for further analysis. Designed for easy customization and local data storage so you can adapt it to personal workflows or extend it

License

Notifications You must be signed in to change notification settings

ehardisonjr-dev/Habit_Tracker_Python

Repository files navigation

Habit Tracker (Python/Flet)

Designed and Created by Bahamut 0 - Ernest Hardison

A robust, high-performance habit tracking application built with Python and Flet. Optimized for desktop and mobile use, featuring fast local storage (SQLite), detailed habit tracking, and user personalization.

🗺️ Architecture Map

This diagram illustrates how the application components interact.

graph TD
    User((User))
    
    subgraph "Entry Point"
        Main[main.py]
    end

    subgraph "Views (UI Screens)"
        Home[views/home_view.py]
        Add[views/add_habit_view.py]
        Settings[views/settings_view.py]
        Profile[views/profile_view.py]
        Help[views/help_view.py]
    end

    subgraph "Components"
        HabitRow[components/habit_item.py]
    end

    subgraph "Data Layer"
        Models[models.py]
        DB[database.py]
        SQLite[(SQLite DB)]
    end

    %% Flows
    User --> Main
    Main --> Home
    
    %% Navigation
    Home -->|Click Add| Add
    Home -->|Click Settings| Settings
    Settings -->|Nav| Profile
    Settings -->|Nav| Help
    
    %% Data Flow
    Home -->|Reads/Writes| DB
    Add -->|Writes| DB
    Profile -->|Reads/Writes| DB
    Home -->|Uses| Models
    
    %% Component Usage
    Home -->|Renders List of| HabitRow
    HabitRow -->|Updates Progress| DB
    
    DB -->|Persists| SQLite
Loading

📂 File Summaries & Functionality

Core Application

  • main.py
    • Summary: The entry point of the application.
    • Functionality: Initializes the Flet page, sets the theme/title, and manages the routing logic (navigation) between different screens (/, /add, /settings, etc.).

Data Layer

  • database.py
    • Summary: The persistence layer managing the SQLite database.
    • Functionality:
      • Creates tables (habits, logs, user_profile) on startup.
      • Handles all SQL queries: add_habit, log_habit, get_profile, etc.
      • Optimized with indexes for fast performance (verified < 2ms).
  • models.py
    • Summary: Data definitions.
    • Functionality: Defines the Habit dataclass to ensure consistent data structures when passing habit information between the Database and the UI.

Views (Screens)

  • views/home_view.py
    • Summary: The main dashboard.
    • Functionality:
      • Displays the list of habits.
      • Calculates and shows daily progress.
      • Provides access to "Add Habit" and "Settings".
      • Handles the "Exit" button logic.
  • views/add_habit_view.py
    • Summary: Creation form.
    • Functionality:
      • Form to input Name, Type (Simple/Quantitative), Goal, and Dates.
      • Common Habits: Quick-add buttons for Water, Gym, etc.
  • views/settings_view.py
    • Summary: Central settings hub.
    • Functionality: Menu navigation to Profile, Help, Updates, and (Stub) Auto Restore.
  • views/profile_view.py
    • Summary: Personalization screen.
    • Functionality: Form to view and edit User Name, Birthdate, Phone, Email, and Goals.
  • views/help_view.py
    • Summary: Educational screen.
    • Functionality: Static guide explaining how to use the app features.

Components

  • components/habit_item.py
    • Summary: A reusable UI widget for a single habit.
    • Functionality:
      • Renders differently based on type (Checkbox for Simple vs Progress Bar for Quantitative).
      • Handles local click events (toggle/increment) and notifies the parent view to update the database.

Utilities

  • perf_test.py
    • Summary: Performance verification script.
    • Functionality: Generates 1 year of dummy data (7,300+ logs) and measures query speed to ensure the app meets the < 2s requirement.
  • CHANGELOG.md
    • Summary: Application history.
    • Functionality: Tracks all changes, new features, and bug fixes version by version.

🚀 How It Works

  1. Startup: executing main.py starts the Flet app. database.py ensures the file habits.db exists.
  2. Navigation: The app uses URL-based routing (e.g., page.go("/add")). main.py listens for route changes and swaps the visible view.
  3. Data Flow:
    • Reads: Views call db.get_all_habits() or db.get_profile().
    • Writes: User actions (clicking checkmarks, saving forms) call methods like db.log_habit() or db.add_habit().
  4. Performance: The app is architected with a "local-first" SQLite approach, ensuring it remains instant even with years of data.

About

Habit_Tracker_Python is a lightweight, extensible habit tracker written in Python that helps you define, record, and analyze daily habits. Track completions, monitor streaks and long-term progress, and export your data for further analysis. Designed for easy customization and local data storage so you can adapt it to personal workflows or extend it

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages