# subhankarsahoopersonal/attendo-attendance-tracker architecture

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

- Interactive diagram: https://gitdiagram.com/subhankarsahoopersonal/attendo-attendance-tracker
- Repository: https://github.com/subhankarsahoopersonal/attendo-attendance-tracker

## Overview

##### Client-side “application layer” (modules)
- `js/app.js` — likely app bootstrap, routing/view switching, wiring modules
- `js/dashboard.js` — dashboard rendering + “today’s classes” interactions
- `js/timetable.js` — weekly schedule + extra classes CRUD UI
- `js/chatbot.js` — NLP-ish pattern matching, quick buttons, “bunk” queries
- `js/calculator.js` — attendance math engine (threshold, projections, recovery)
- `js/auth.js` — Google + email/password sign-in, auth-gating UI
- `js/storage.js` — *critical*: localStorage + Firestore sync layer (“StorageManager / FirestoreSync”)
- `js/firebase-config.js` — Firebase initialization (SDK config, app init)

##### Assets
- `assets/` — logo, static resources

##### External systems (not in repo, but essential
- **Firebase Auth**
- **Cloud Firestore**
- **(Potential) Firebase Cloud Messaging / browser Notifications API**
README promises push notifications. Even if implementation is client-side timers + Notifications API (not true push), represent the notification mechanism explicitly because it’s a core feature.
- **Netlify hosting** (serving the static app)

##### FirestoreSync writes to Cloud Firestore

**Read path (on login / app load)**
##### UI modules render from storage state

- **Serverless backend**: Firebase Auth + Firestore replace a custom API server.
- **Offline-first / cache-first**: localStorage is the immediate source for responsiveness; Firestore becomes the synced canonical store after auth.
- **Auth-gated data access**: app UI hidden until auth; Firestore reads/writes scoped by user (Security Rules).
- **Module-based separation**: feature modules (dashboard/timetable/chatbot) separated from data + auth + domain math.
- **Client-side “NLP” chatbot**: pattern matching within `chatbot.js` (not an external LLM service).

##### Container view (recommended minimum)
- User
- Browser: AttenDO Web App
- Browser: localStorage
- Firebase Auth
- Cloud Firestore
- Notifications (Browser API / FCM)
- Netlify Hosting

##### Component view (inside Browser)
- app.js (bootstrap)
- firebase-config.js (init)
- auth.js
- storage.js (local + sync)
- calculator.js
- dashboard.js
- timetable.js
- chatbot.js

And then connect:
- UI modules → storage.js
- chatbot/dashboard → calculator.js
- auth.js → storage.js (enables cloud sync after login)
- storage.js ↔ localStorage / Firestore

## Diagram (Mermaid)

```mermaid
flowchart TD
  %% ========== View A: Context / Container (C4 L1-L2) ==========
  subgraph V1["View A — Context / Container"]
    direction TB

    U["Student / User"]:::actor

    subgraph BROW["User Device — Browser"]
      direction TB
      WEB["AttenDO Web App (Vanilla JS SPA)"]:::app
      LS[("localStorage\n(offline cache + pre-login data)")]:::store
      NOTIF["Notifications\n(Browser Notifications API / FCM)"]:::notify
    end

    subgraph FIRE["Firebase Cloud (Managed Services)"]
      direction TB
      FA["Firebase Authentication\n(Google, Email/Password)"]:::cloudSvc
      FS[("Cloud Firestore\n(per-user attendance/timetable/settings)")]:::db
    end

    subgraph HOST["Hosting & Other"]
      direction TB
      NET["Netlify Static Hosting"]:::cloudHost
    end

    %% Container relationships
    U -->|"UI actions"| WEB
    NET -->|"Serve static HTML/CSS/JS/assets"| WEB

    WEB -->|"Sign-in / auth state listener"| FA
    WEB <-->|"Read/write user dataset"| FS

    WEB <-->|"Cache-first reads + immediate local write"| LS
    WEB -->|"Schedule/display reminders & warnings"| NOTIF
  end

  %% ========== View B: Component Diagram (C4 L3 inside Browser) ==========
  subgraph V2["View B — Browser App Components (C4 L3)"]
    direction TB

    subgraph SHELL["Presentation / App Shell"]
      direction TB
      IDX["index.html\n(App shell + login containers)"]:::file
      CSS["styles.css\n(Design system + UI styling)"]:::file
      ASSETS["assets/\n(Logos + static resources)"]:::dir
    end

    subgraph APP["Client-side Application Layer (JS modules)"]
      direction TB

      APPJS["app.js\n(Bootstrap/orchestration, event binding, view state)"]:::module

      subgraph AUTH["Authentication"]
        direction TB
        FBCFG["firebase-config.js\n(Firebase SDK init/config)"]:::module
        AUTHJS["auth.js\n(Login flows, auth-gating UI, auth listener)"]:::module
      end

      subgraph DATA["Data Layer"]
        direction TB
        STOR["storage.js\n(StorageManager + FirestoreSync)\n(localStorage + sync + migration)"]:::module
        LS2[("localStorage")]:::store
        FS2[("Cloud Firestore")]:::db
      end

      subgraph DOMAIN["Domain Logic"]
        direction TB
        CALC["calculator.js\n(Attendance math: thresholds, projections, recovery)"]:::module
      end

      subgraph UI["Feature / UI Modules"]
        direction TB
        DASH["dashboard.js\n(Today's classes, stats/projections)"]:::module
        TT["timetable.js\n(Weekly schedule + extra classes CRUD)"]:::module
        BOT["chatbot.js\n(Pattern matching + quick buttons + bunk queries)"]:::module
      end
    end

    %% Wiring (module relationships)
    IDX -->|"Loads"| CSS
    IDX -->|"Loads"| APPJS
    IDX -->|"Loads"| ASSETS

    APPJS -->|"Init"| FBCFG
    APPJS -->|"Auth-gate UI"| AUTHJS
    APPJS -->|"Initialize data layer"| STOR
    APPJS -->|"Render views"| DASH
    APPJS -->|"Render views"| TT
    APPJS -->|"Render views"| BOT

    AUTHJS -->|"Enables Firestore access\n(after login)"| STOR
    FBCFG -->|"Configures SDK used by"| AUTHJS
    FBCFG -->|"Configures SDK used by"| STOR

    DASH -->|"Read/write data"| STOR
    TT -->|"Read/write data"| STOR
    BOT -->|"Read/write data"| STOR

    DASH -->|"Compute stats / bunk prediction"| CALC
    BOT -->|"Predictions & answers"| CALC

    STOR <-->|"Cache-first reads/writes"| LS2
    STOR <-->|"Sync (auth-gated)"| FS2
  end

  %% ========== View C: Data Flow (README-backed) ==========
  subgraph V3["View C — Data Flow (Write + Read)"]
    direction TB

    subgraph WRITE["Write Path (typical interaction)"]
      direction TB
      WU["User action:\nmark attendance / edit timetable"]:::actor
      WUI["UI module\n(dashboard/timetable/chatbot)"]:::module
      WSM["StorageManager\n(storage.js)"]:::module
      WLS[("localStorage\n(immediate write)")]:::store
      WDEB["FirestoreSync\n(debounced)"]:::module
      WFS[("Cloud Firestore")]:::db

      WU -->|"Update attendance/timetable"| WUI
      WUI -->|"Persist change"| WSM
      WSM -->|"Immediate local write"| WLS
      WSM -->|"Trigger debounced sync"| WDEB
      WDEB -->|"Write to cloud"| WFS
    end

    subgraph READ["Read Path (on login / app load)"]
      direction TB
      RA["auth.js\n(auth state listener)"]:::module
      RS["storage.js\n(pull + merge/migrate)"]:::module
      RFS[("Cloud Firestore\n(authoritative on login)")]:::db
      RLS[("localStorage\n(existing cache)")]:::store
      RM["Merge/migrate\n(local → cloud on first login)"]:::note
      RUI["UI modules\n(render from storage state)"]:::module

      RA -->|"Login success"| RS
      RS -->|"Pull user dataset"| RFS
      RS -->|"Read local cache"| RLS
      RS -->|"Merge/migrate"| RM
      RM -->|"Resulting state"| RS
      RS -->|"Provide state"| RUI
    end
  end

  %% ========== Legend ==========
  subgraph LEG["Legend"]
    direction TB
    L1["auth-gated"]:::note
    L2["debounced sync"]:::note
    L3["merge/migration"]:::note
  end

  %% ========== Click events (from component_mapping) ==========
  click IDX "https://github.com/subhankarsahoopersonal/attendo-attendance-tracker/blob/main/index.html"
  click CSS "https://github.com/subhankarsahoopersonal/attendo-attendance-tracker/blob/main/css/styles.css"
  click ASSETS "https://github.com/subhankarsahoopersonal/attendo-attendance-tracker/tree/main/assets/"
  click APPJS "https://github.com/subhankarsahoopersonal/attendo-attendance-tracker/blob/main/js/app.js"
  click AUTHJS "https://github.com/subhankarsahoopersonal/attendo-attendance-tracker/blob/main/js/auth.js"
  click FBCFG "https://github.com/subhankarsahoopersonal/attendo-attendance-tracker/blob/main/js/firebase-config.js"
  click STOR "https://github.com/subhankarsahoopersonal/attendo-attendance-tracker/blob/main/js/storage.js"
  click CALC "https://github.com/subhankarsahoopersonal/attendo-attendance-tracker/blob/main/js/calculator.js"
  click DASH "https://github.com/subhankarsahoopersonal/attendo-attendance-tracker/blob/main/js/dashboard.js"
  click TT "https://github.com/subhankarsahoopersonal/attendo-attendance-tracker/blob/main/js/timetable.js"
  click BOT "https://github.com/subhankarsahoopersonal/attendo-attendance-tracker/blob/main/js/chatbot.js"

  %% ========== Styles ==========
  classDef actor fill:#FFE8A3,stroke:#8A6D00,stroke-width:1.5px,color:#1f1f1f;
  classDef app fill:#D6F5E3,stroke:#1F7A4D,stroke-width:1.5px,color:#0f2b1d;
  classDef module fill:#E7F0FF,stroke:#2B5FB8,stroke-width:1.2px,color:#0b1b33;
  classDef file fill:#F3E8FF,stroke:#6B21A8,stroke-width:1.2px,color:#1f1033;
  classDef dir fill:#FCE7F3,stroke:#9D174D,stroke-width:1.2px,color:#2a0b18;
  classDef store fill:#FFF1D6,stroke:#B45309,stroke-width:1.4px,color:#2a1402;
  classDef db fill:#FFE2E2,stroke:#B91C1C,stroke-width:1.5px,color:#2a0b0b;
  classDef cloudSvc fill:#DFF7FF,stroke:#0284C7,stroke-width:1.5px,color:#06202c;
  classDef cloudHost fill:#E0E7FF,stroke:#3730A3,stroke-width:1.5px,color:#0b0a2a;
  classDef notify fill:#E6FFFA,stroke:#0F766E,stroke-width:1.5px,color:#022c2a;
  classDef note fill:#F8FAFC,stroke:#64748B,stroke-dasharray: 4 3,color:#0f172a;
```
