How ziadtamer52/habits works
Project type and purpose
• This is a single-page, front-end–only web application.
File structure
• Top‐level files:
• index.html – the main HTML shell
• style.css – styling (including theme switching)
• script.js – core JavaScript logic
• Chart.js (via CDN in index.html) – external visualization library
• localStorage (browser-built-in) for persistence
• No backend or external APIs beyond Chart.js and the browser runtime.
Extract insights from the README
• Tech stack: HTML5, CSS3, vanilla JavaScript, Chart.js, localStorage.
• Key functional areas: habit CRUD (Create, Read, Update, Delete), progress tracking, chart rendering, theme toggle.
Main components and interactions
a. Components
1. Browser / User Agent
2. UI Layer (HTML + CSS)
3. Application Logic (script.js)
– Habit Manager (adds/deletes marks habits)
– Theme Controller (toggles light/dark)
– Chart Controller (feeds data to Chart.js)
4. Data Store (localStorage)
5. Visualization Library (Chart.js)
b. Relationships & Data Flow
1. User → UI Layer (click “Add Habit”, “✔”, “❌”, theme switch)
2. UI Layer → Application Logic
3. App Logic ↔ localStorage (read/write habit data)
4. App Logic → Chart.js API (updates bar chart)
5. Chart.js → UI Layer (renders canvas)
c. Architectural patterns
– Separation of concerns:
• UI (structure & style)
• Logic (habit, theme, chart controllers)
• Persistence (localStorage)
– Single‐page app pattern (all in one HTML file)
d. Key technologies
– HTML5, CSS3 (UI)
– Vanilla JS (DOM manipulation & controllers)
– Chart.js (visualization)
– localStorage (persistence)
Putting it all together
• Habit Manager
• Theme Controller
• Chart Controller