How zamancodexpress/habit-tracker-dashboard works
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: app.js app.js · storage.js storage.js · analytics.js analytics.js · tracker.js tracker.js
Components 13
Presentation
Static HTML/CSS shell and DOM-rendered dashboard UI
- index.html · Single-page entry point that loads the app shell
index.html - style.css · App-wide layout, theming, and responsive presentation
css/style.css - Dashboard UI · Dynamic dashboard sections rendered and updated in the browser
Client Logic
Vanilla JS modules for habits, tracking, analytics, insights, and theme
- app.js · Main orchestrator that initializes modules and drives updates
js/app.js - habits.js · Create, edit, delete, reorder, and organize habit records
js/habits.js - tracker.js · Marks daily completions and computes day-level status
js/tracker.js - streaks.js · Calculates streaks and milestone state from completion history
js/streaks.js - calendar.js · Renders the 365-day completion calendar and habit filters
js/calendar.js - analytics.js · Generates completion charts and statistical summaries
js/analytics.js - insights.js · Produces tips, risks, and human-readable guidance
js/insights.js - theme.js · Handles light/dark mode, system theme, and preference saving
js/theme.js
Persistence
Browser-local durable state via Web Storage
- storage.js · Reads and writes habits, history, and preferences
js/storage.js - LocalStorage · Browser-local persistent storage backing the app state
Connections 23
- 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