# ayushj0704/waterintakeproject architecture

> Architecture diagram of the GitHub repository ayushj0704/waterintakeproject, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ayushj0704/waterintakeproject
- Repository: https://github.com/ayushj0704/waterintakeproject

## Overview

##### 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

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "UI Layer"
        direction TB
        Browser["Browser / Client Host"]:::ui
        index["index.html"]:::ui
        styles["styles.css"]:::ui
        SVG["SVG Renderer"]:::ui
    end

    subgraph "Application Logic"
        direction TB
        script["script.js"]:::logic
    end

    subgraph "Storage"
        direction TB
        storage["LocalStorage"]:::storage
    end

    subgraph "External Services"
        direction TB
        notif["Notifications API"]:::external
    end

    Browser -->|"loads"| index
    index -->|"includes"| styles
    index -->|"includes"| script
    script -->|"reads/writes"| storage
    script -->|"invokes"| notif
    script -->|"updates DOM & SVG"| SVG

    timer["Scheduler Timer"]:::logic
    timer -.->|"timer event"| script

    click index "https://github.com/ayushj0704/waterintakeproject/blob/main/index.html"
    click styles "https://github.com/ayushj0704/waterintakeproject/blob/main/styles.css"
    click script "https://github.com/ayushj0704/waterintakeproject/blob/main/script.js"

    classDef ui fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef logic fill:#90EE90,stroke:#000,stroke-width:1px
    classDef storage fill:#FFFF99,stroke:#000,stroke-width:1px
    classDef external fill:#FFA500,stroke:#000,stroke-width:1px
```
