How ayushj0704/waterintakeproject works
Project type and purpose
• This is a single‐page, client-side web application (no server or backend).
• Its purpose is to let users set and track daily water‐intake goals, view history, and receive hydration reminders.
File structure
• index.html: The root HTML shell and entry point.
• styles.css: All styling and responsive layouts.
• script.js: Core application logic—state management, UI updates, persistence, notifications.
• README.md: Project overview and tech stack.
• No “backend” directory or API endpoints—everything runs in the browser.
Key technologies & roles
• HTML5: Defines UI structure and ARIA roles for accessibility.
• CSS3: Layout, theming, responsiveness, mobile optimization.
• JavaScript (Vanilla):
• Manages application state (current intake, history array).
• Reads/writes LocalStorage for persistence.
• Renders SVG radial progress.
• Schedules midnight reset and Notifications API reminders.
• LocalStorage API: Stores daily goal, history, current progress.
• Notifications API: Issues periodic hydration reminders.
• SVG: Draws the circular progress indicator.
Main components & their interactions
a. UI Layer (index.html + styles.css)
• Input controls for setting goal and adding intake.
• SVG container for progress visualization.
• History panel showing up to seven days.
b. Application Logic (script.js)
• State Manager: loads/saves data, computes percentages.
• UI Renderer: updates DOM and SVG elements.
• Scheduler: resets counters at 00:00, triggers notifications.
c. Persistence Layer (LocalStorage)
• Persists JSON blob of goals, intake log, history.
d. Notification Service (Notifications API)
• Requests permission, schedules periodic reminders.
• Browser loads index.html → includes styles.css + script.js
• On load: script.js ▶ reads LocalStorage ▶ initializes state ▶ calls UI Renderer
• User actions (button clicks) ▶ script.js updates state ▶ writes to LocalStorage ▶ UI Renderer updates DOM & SVG
• Scheduler within script.js ▶ at intervals or midnight ▶ updates state & UI, sends notifications via Notifications API
• History queries LocalStorage and displays past seven days
Architectural patterns & design principles
• Single Responsibility: script.js segments into state management, rendering, scheduling.
• Event-Driven: UI button events and timers drive state changes.
• Client-Only MVC-lite:
• Model = data in LocalStorage + in-memory state
• View = HTML + CSS + generated SVG
• Controller = event handlers & scheduler in script.js