# zamancodexpress/habit-tracker-dashboard architecture

> Architecture diagram of the GitHub repository zamancodexpress/habit-tracker-dashboard, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/zamancodexpress/habit-tracker-dashboard
- Repository: https://github.com/zamancodexpress/habit-tracker-dashboard

## Overview

1. **Repository shape**
   - This is a **single-page, static frontend app**. The entry point is `index.html`, which loads one global stylesheet (`css/style.css`) and a set of modular vanilla JavaScript files under `js/`.
   - There is **no backend, no API layer, and no framework runtime**. The whole application runs in the browser.

2. **Primary architectural boundary**
   - The app is split into two clear layers:
     - **Presentation/UI**: HTML + CSS + DOM rendering
     - **Client logic/state**: JavaScript modules that manage habits, tracking, analytics, themes, and persistence
   - All data lives locally in the browser via **LocalStorage**, so the app is device/browser scoped.

3. **Bootstrap and orchestration**
   - `js/app.js` is the **central controller**. It likely initializes the app on page load, coordinates feature modules, and drives view updates/navigation within the single page.
   - This file is the main integration point for the rest of the modules, rather than a separate service layer.

4. **Persistence subsystem**
   - `js/storage.js` is the **state persistence boundary**.
   - It handles reading/writing habit data and user preferences from **Web Storage / LocalStorage**, making it the durable source of truth across refreshes.
   - The app’s state flow is: user action → module updates in-memory data → storage module saves → UI re-renders from updated state.

5. **Habit management subsystem**
   - `js/habits.js` contains the **core CRUD and organization logic** for habits:
     - create, edit, delete, reorder
     - habit metadata such as icon, color, and frequency
   - This module defines the main business object of the app: the habit record.

6. **Daily tracking subsystem**
   - `js/tracker.js` handles **marking habit completion for the current day** and computing day-level completion status.
   - This is the operational layer users interact with most frequently, and it feeds the rest of the system with completion events and counts.

7. **Streak logic subsystem**
   - `js/streaks.js` is responsible for **streak calculation and milestone detection**.
   - It likely consumes completion history from storage/tracker data and produces streak state used in the dashboard and habit summaries.

8. **Calendar visualization subsystem**
   - `js/calendar.js` renders the **365-day completion heatmap** and supports **filtering by habit**.
   - It also includes the **live clock display** mentioned in the README, making this a combined visualization + time widget module.

9. **Analytics and charting subsystem**
   - `js/analytics.js` generates the dashboard’s **performance charts and statistical summaries**:
     - weekly completion rate
     - monthly trends
     - comparison bars
     - completion distribution pie chart
     - 30-day trend line
   - The README notes the use of the **Canvas API**, so this module is likely the main chart-rendering boundary and does not depend on charting libraries.

10. **Insights subsystem**
   - `js/insights.js` turns raw behavior data into **smart tips, risk detection, and recommendations**.
   - This module sits above the analytics/streak layers, consuming derived metrics and producing human-readable guidance.

11. **Theme subsystem**
   - `js/theme.js` manages **light/dark mode**, **system theme detection**, and saving the preference.
   - This is a cross-cutting UI concern that affects the entire app presentation but stays client-side and persistent via storage.

12. **Data flow across the app**
   - The dominant flow is:
     - user interacts with habit controls or day check-ins
     - feature module updates the model
     - `storage.js` persists the change
     - analytics/calendar/streaks/insights recompute derived views
     - `app.js` triggers DOM updates
   - The modules are separated by responsibility, but they share one browser-local data model.

13. **UI and rendering model**
   - The app is **DOM-driven** rather than server-rendered.
   - `css/style.css` provides the responsive layout, theming, and transitions, while the JavaScript modules populate and update sections of the page dynamically.
   - The interface is designed for a dashboard-style experience with multiple panels rather than navigation to separate pages.

14. **External dependencies and deployment characteristics**
   - There are **no external runtime services** required.
   - The project can be opened directly in a modern browser from `index.html`, which makes the architecture lightweight, offline-friendly, and easy to diagram as a self-contained client application.

Main entry points: [`js/app.js`](https://github.com/zamancodexpress/habit-tracker-dashboard/blob/main/js/app.js) (app.js), [`js/storage.js`](https://github.com/zamancodexpress/habit-tracker-dashboard/blob/main/js/storage.js) (storage.js), [`js/analytics.js`](https://github.com/zamancodexpress/habit-tracker-dashboard/blob/main/js/analytics.js) (analytics.js), [`js/tracker.js`](https://github.com/zamancodexpress/habit-tracker-dashboard/blob/main/js/tracker.js) (tracker.js)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["Presentation"]
  node_index_html["index.html<br/>entry page<br/>[index.html]"]
  node_style_css["style.css<br/>global styles<br/>[style.css]"]
  node_dashboard_dom["Dashboard UI<br/>dom view"]
end

subgraph group_logic["Client Logic"]
  node_app_js["app.js<br/>bootstrap controller<br/>[app.js]"]
  node_habits_js["habits.js<br/>habit CRUD<br/>[habits.js]"]
  node_tracker_js["tracker.js<br/>daily tracking<br/>[tracker.js]"]
  node_streaks_js["streaks.js<br/>streak logic<br/>[streaks.js]"]
  node_calendar_js["calendar.js<br/>heatmap view<br/>[calendar.js]"]
  node_analytics_js["analytics.js<br/>charts & stats<br/>[analytics.js]"]
  node_insights_js["insights.js<br/>recommendations<br/>[insights.js]"]
  node_theme_js["theme.js<br/>theme manager<br/>[theme.js]"]
end

subgraph group_persistence["Persistence"]
  node_storage_js[("storage.js<br/>state store<br/>[storage.js]")]
  node_local_storage[("LocalStorage<br/>web storage")]
end

node_index_html -->|"loads"| node_style_css
node_index_html -->|"boots"| node_app_js
node_app_js -->|"renders"| node_dashboard_dom
node_app_js -->|"coordinates"| node_habits_js
node_app_js -->|"coordinates"| node_tracker_js
node_app_js -->|"coordinates"| node_calendar_js
node_app_js -->|"coordinates"| node_analytics_js
node_app_js -->|"coordinates"| node_insights_js
node_app_js -->|"coordinates"| node_theme_js
node_habits_js -->|"persists"| node_storage_js
node_tracker_js -->|"persists"| node_storage_js
node_tracker_js -->|"feeds"| node_streaks_js
node_streaks_js -->|"reads"| node_storage_js
node_calendar_js -->|"reads"| node_tracker_js
node_calendar_js -->|"reads"| node_storage_js
node_analytics_js -->|"analyzes"| node_tracker_js
node_analytics_js -->|"analyzes"| node_streaks_js
node_analytics_js -->|"reads"| node_storage_js
node_insights_js -->|"derives from"| node_analytics_js
node_insights_js -->|"derives from"| node_streaks_js
node_theme_js -->|"persists"| node_storage_js
node_theme_js -->|"toggles"| node_style_css
node_storage_js -->|"writes/reads"| node_local_storage

click node_index_html "https://github.com/zamancodexpress/habit-tracker-dashboard/blob/main/index.html"
click node_style_css "https://github.com/zamancodexpress/habit-tracker-dashboard/blob/main/css/style.css"
click node_app_js "https://github.com/zamancodexpress/habit-tracker-dashboard/blob/main/js/app.js"
click node_habits_js "https://github.com/zamancodexpress/habit-tracker-dashboard/blob/main/js/habits.js"
click node_tracker_js "https://github.com/zamancodexpress/habit-tracker-dashboard/blob/main/js/tracker.js"
click node_streaks_js "https://github.com/zamancodexpress/habit-tracker-dashboard/blob/main/js/streaks.js"
click node_calendar_js "https://github.com/zamancodexpress/habit-tracker-dashboard/blob/main/js/calendar.js"
click node_analytics_js "https://github.com/zamancodexpress/habit-tracker-dashboard/blob/main/js/analytics.js"
click node_insights_js "https://github.com/zamancodexpress/habit-tracker-dashboard/blob/main/js/insights.js"
click node_theme_js "https://github.com/zamancodexpress/habit-tracker-dashboard/blob/main/js/theme.js"
click node_storage_js "https://github.com/zamancodexpress/habit-tracker-dashboard/blob/main/js/storage.js"

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_index_html,node_style_css,node_dashboard_dom toneBlue
class node_app_js,node_habits_js,node_tracker_js,node_streaks_js,node_calendar_js,node_analytics_js,node_insights_js,node_theme_js toneAmber
class node_storage_js,node_local_storage toneMint
```

## Components

### Presentation

Static HTML/CSS shell and DOM-rendered dashboard UI

- [index.html](https://github.com/zamancodexpress/habit-tracker-dashboard/blob/main/index.html): entry page · Single-page entry point that loads the app shell · `index.html`
- [style.css](https://github.com/zamancodexpress/habit-tracker-dashboard/blob/main/css/style.css): global styles · App-wide layout, theming, and responsive presentation · `css/style.css`
- **Dashboard UI**: dom view · Dynamic dashboard sections rendered and updated in the browser

### Client Logic

Vanilla JS modules for habits, tracking, analytics, insights, and theme

- [app.js](https://github.com/zamancodexpress/habit-tracker-dashboard/blob/main/js/app.js): bootstrap controller · Main orchestrator that initializes modules and drives updates · `js/app.js`
- [habits.js](https://github.com/zamancodexpress/habit-tracker-dashboard/blob/main/js/habits.js): habit CRUD · Create, edit, delete, reorder, and organize habit records · `js/habits.js`
- [tracker.js](https://github.com/zamancodexpress/habit-tracker-dashboard/blob/main/js/tracker.js): daily tracking · Marks daily completions and computes day-level status · `js/tracker.js`
- [streaks.js](https://github.com/zamancodexpress/habit-tracker-dashboard/blob/main/js/streaks.js): streak logic · Calculates streaks and milestone state from completion history · `js/streaks.js`
- [calendar.js](https://github.com/zamancodexpress/habit-tracker-dashboard/blob/main/js/calendar.js): heatmap view · Renders the 365-day completion calendar and habit filters · `js/calendar.js`
- [analytics.js](https://github.com/zamancodexpress/habit-tracker-dashboard/blob/main/js/analytics.js): charts & stats · Generates completion charts and statistical summaries · `js/analytics.js`
- [insights.js](https://github.com/zamancodexpress/habit-tracker-dashboard/blob/main/js/insights.js): recommendations · Produces tips, risks, and human-readable guidance · `js/insights.js`
- [theme.js](https://github.com/zamancodexpress/habit-tracker-dashboard/blob/main/js/theme.js): theme manager · Handles light/dark mode, system theme, and preference saving · `js/theme.js`

### Persistence

Browser-local durable state via Web Storage

- [storage.js](https://github.com/zamancodexpress/habit-tracker-dashboard/blob/main/js/storage.js): state store · Reads and writes habits, history, and preferences · `js/storage.js`
- **LocalStorage**: web storage · Browser-local persistent storage backing the app state

## Connections

- index.html → style.css: loads · The page loads the global stylesheet
- index.html → app.js: boots · The page loads the main application controller
- app.js → Dashboard UI: renders · Initializes and updates the dashboard UI
- app.js → habits.js: coordinates · Delegates habit management actions
- app.js → tracker.js: coordinates · Delegates daily completion actions
- app.js → calendar.js: coordinates · Feeds calendar rendering and filtering
- app.js → analytics.js: coordinates · Triggers chart and summary updates
- app.js → insights.js: coordinates · Refreshes tips and recommendations
- app.js → theme.js: coordinates · Initializes and applies theme state
- habits.js → storage.js: persists · Habit CRUD updates are saved locally
- tracker.js → storage.js: persists · Completion events are written to storage
- tracker.js → streaks.js: feeds · Completion data drives streak calculation
- streaks.js → storage.js: reads · Uses stored history to derive streak state
- calendar.js → tracker.js: reads · Uses tracking data to build the completion heatmap
- calendar.js → storage.js: reads · Loads persisted data for filtering and display
- analytics.js → tracker.js: analyzes · Consumes completion history for charts and trends
- analytics.js → streaks.js: analyzes · Uses derived streak state in summaries
- analytics.js → storage.js: reads · Pulls persisted records for statistical views
- insights.js → analytics.js: derives from · Turns metrics into recommendations
- insights.js → streaks.js: derives from · Uses streak state to detect risk and momentum
- theme.js → storage.js: persists · Theme preference is saved across sessions
- theme.js → style.css: toggles · Theme changes affect the global stylesheet presentation
- storage.js → LocalStorage: writes/reads · Browser storage is the durable state boundary
