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.
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
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.).
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).
- Creates tables (
models.py- Summary: Data definitions.
- Functionality: Defines the
Habitdataclass to ensure consistent data structures when passing habit information between the Database and the UI.
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/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.
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.
- Startup: executing
main.pystarts the Flet app.database.pyensures the filehabits.dbexists. - Navigation: The app uses URL-based routing (e.g.,
page.go("/add")).main.pylistens for route changes and swaps the visible view. - Data Flow:
- Reads: Views call
db.get_all_habits()ordb.get_profile(). - Writes: User actions (clicking checkmarks, saving forms) call methods like
db.log_habit()ordb.add_habit().
- Reads: Views call
- Performance: The app is architected with a "local-first" SQLite approach, ensuring it remains instant even with years of data.