# gustavoviti/kaisen architecture

> Architecture diagram of the GitHub repository gustavoviti/kaisen, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gustavoviti/kaisen
- Repository: https://github.com/gustavoviti/kaisen

## Overview

Kaisen is a gamified habit-tracking PWA. Users sign in, manage and complete habits, and receive XP, levels, streaks, badges, activity history, and progress charts. The dashboard controller coordinates Firebase-backed profile and habit operations, while charting and install-prompt features support the main experience. The README documents offline caching and push notifications; excerpts show service-worker cache and notification handling, though page registration and some wiring were not shown.

Main entry points: [`js/app.js`](https://github.com/gustavoviti/kaisen/blob/main/js/app.js) (Dashboard controller), [`dashboard.html`](https://github.com/gustavoviti/kaisen/blob/main/dashboard.html) (Habit dashboard), [`js/firebase.js`](https://github.com/gustavoviti/kaisen/blob/main/js/firebase.js) (Habit persistence), [`service-worker.js`](https://github.com/gustavoviti/kaisen/blob/main/service-worker.js) (Offline and push worker)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Habit experience"]
  node_login["Authentication screens<br/>[login.html]"]
  node_dashboard["Habit dashboard<br/>[dashboard.html]"]
  node_controller["Dashboard controller<br/>[app.js]"]
  node_habit_ui["Habit management<br/>[app.js]"]
  node_progress_ui["Progress and badges<br/>[app.js]"]
  node_charts["Progress charts<br/>[charts.js]"]
end

subgraph group_firebase["Firebase services"]
  node_auth["Authentication<br/>[firebase.js]"]
  node_profile["Profile and streaks<br/>[firebase.js]"]
  node_habits["Habit persistence<br/>[firebase.js]"]
  node_xp["XP and levels<br/>[firebase.js]"]
  node_badges["Badge awards<br/>[firebase.js]"]
  node_push["Push subscriptions<br/>[firebase.js]"]
end

subgraph group_pwa["PWA capabilities"]
  node_install["Install prompt<br/>[pwa.js]"]
  node_worker["Offline and push worker<br/>[service-worker.js]"]
  node_offline["Offline fallback<br/>[offline.html]"]
  node_manifest["PWA manifest<br/>[manifest.json]"]
end

subgraph group_external["External services"]
  node_firestore[("Cloud Firestore")]
  node_firebase_auth["Firebase Authentication"]
  node_charts_cdn["Chart.js CDN"]
  node_notifications["Push notification services"]
end

node_user(("Habit user"))

node_user -->|"signs in"| node_login
node_login -.->|"authenticates"| node_auth
node_auth -->|"uses"| node_firebase_auth
node_user -->|"uses"| node_dashboard
node_dashboard -->|"loads"| node_controller
node_controller -.->|"checks session"| node_auth
node_controller -->|"loads profile"| node_profile
node_controller -->|"seeds habits"| node_habits
node_controller -->|"renders and handles"| node_habit_ui
node_habit_ui -->|"manages and completes"| node_habits
node_habits -->|"awards XP"| node_xp
node_controller -->|"checks awards"| node_badges
node_controller -->|"renders progress"| node_progress_ui
node_progress_ui -->|"calculates level"| node_xp
node_controller -->|"updates charts"| node_charts
node_charts -->|"renders with"| node_charts_cdn
node_profile -->|"reads and writes"| node_firestore
node_habits -->|"reads and writes"| node_firestore
node_xp -->|"updates profile"| node_firestore
node_badges -->|"stores awards"| node_profile
node_controller -->|"requests permission"| node_push
node_push -->|"subscribes"| node_notifications
node_user -->|"installs app"| node_install
node_worker -->|"serves fallback"| node_offline
node_worker -->|"shows and opens"| node_notifications
node_dashboard -.->|"uses"| node_manifest
node_worker -->|"caches assets"| node_dashboard

click node_login "https://github.com/gustavoviti/kaisen/blob/main/login.html"
click node_dashboard "https://github.com/gustavoviti/kaisen/blob/main/dashboard.html"
click node_controller "https://github.com/gustavoviti/kaisen/blob/main/js/app.js"
click node_habit_ui "https://github.com/gustavoviti/kaisen/blob/main/js/app.js"
click node_progress_ui "https://github.com/gustavoviti/kaisen/blob/main/js/app.js"
click node_charts "https://github.com/gustavoviti/kaisen/blob/main/js/charts.js"
click node_auth "https://github.com/gustavoviti/kaisen/blob/main/js/firebase.js"
click node_profile "https://github.com/gustavoviti/kaisen/blob/main/js/firebase.js"
click node_habits "https://github.com/gustavoviti/kaisen/blob/main/js/firebase.js"
click node_xp "https://github.com/gustavoviti/kaisen/blob/main/js/firebase.js"
click node_badges "https://github.com/gustavoviti/kaisen/blob/main/js/firebase.js"
click node_push "https://github.com/gustavoviti/kaisen/blob/main/js/firebase.js"
click node_install "https://github.com/gustavoviti/kaisen/blob/main/js/pwa.js"
click node_worker "https://github.com/gustavoviti/kaisen/blob/main/service-worker.js"
click node_offline "https://github.com/gustavoviti/kaisen/blob/main/offline.html"
click node_manifest "https://github.com/gustavoviti/kaisen/blob/main/manifest.json"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_login,node_dashboard,node_controller,node_habit_ui,node_progress_ui,node_charts,node_user toneBlue
class node_auth,node_profile,node_habits,node_xp,node_badges,node_push toneAmber
class node_install,node_worker,node_offline,node_manifest toneMint
class node_firestore,node_firebase_auth,node_charts_cdn,node_notifications toneRose
```

## Components

### Habit experience

- [Authentication screens](https://github.com/gustavoviti/kaisen/blob/main/login.html): `login.html`
- [Habit dashboard](https://github.com/gustavoviti/kaisen/blob/main/dashboard.html): `dashboard.html`
- [Dashboard controller](https://github.com/gustavoviti/kaisen/blob/main/js/app.js): `js/app.js`
- [Habit management](https://github.com/gustavoviti/kaisen/blob/main/js/app.js): `js/app.js`
- [Progress and badges](https://github.com/gustavoviti/kaisen/blob/main/js/app.js): `js/app.js`
- [Progress charts](https://github.com/gustavoviti/kaisen/blob/main/js/charts.js): `js/charts.js`

### Firebase services

- [Authentication](https://github.com/gustavoviti/kaisen/blob/main/js/firebase.js): `js/firebase.js`
- [Profile and streaks](https://github.com/gustavoviti/kaisen/blob/main/js/firebase.js): `js/firebase.js`
- [Habit persistence](https://github.com/gustavoviti/kaisen/blob/main/js/firebase.js): `js/firebase.js`
- [XP and levels](https://github.com/gustavoviti/kaisen/blob/main/js/firebase.js): `js/firebase.js`
- [Badge awards](https://github.com/gustavoviti/kaisen/blob/main/js/firebase.js): `js/firebase.js`
- [Push subscriptions](https://github.com/gustavoviti/kaisen/blob/main/js/firebase.js): `js/firebase.js`

### PWA capabilities

- [Install prompt](https://github.com/gustavoviti/kaisen/blob/main/js/pwa.js): `js/pwa.js`
- [Offline and push worker](https://github.com/gustavoviti/kaisen/blob/main/service-worker.js): `service-worker.js`
- [Offline fallback](https://github.com/gustavoviti/kaisen/blob/main/offline.html): `offline.html`
- [PWA manifest](https://github.com/gustavoviti/kaisen/blob/main/manifest.json): `manifest.json`

### External services

- **Cloud Firestore**
- **Firebase Authentication**
- **Chart.js CDN**
- **Push notification services**

### Other components

- **Habit user**

## Connections

- Habit user → Authentication screens: signs in (evidence: `README.md`)
- Authentication screens → Authentication: authenticates
- Authentication → Firebase Authentication: uses (evidence: `js/firebase.js`)
- Habit user → Habit dashboard: uses (evidence: `README.md`)
- Habit dashboard → Dashboard controller: loads (evidence: `README.md`)
- Dashboard controller → Authentication: checks session (evidence: `js/app.js`)
- Dashboard controller → Profile and streaks: loads profile (evidence: `js/app.js`)
- Dashboard controller → Habit persistence: seeds habits (evidence: `js/app.js`)
- Dashboard controller → Habit management: renders and handles (evidence: `js/app.js`)
- Habit management → Habit persistence: manages and completes (evidence: `js/app.js`)
- Habit persistence → XP and levels: awards XP (evidence: `js/firebase.js`)
- Dashboard controller → Badge awards: checks awards (evidence: `js/app.js`)
- Dashboard controller → Progress and badges: renders progress (evidence: `js/app.js`)
- Progress and badges → XP and levels: calculates level (evidence: `js/app.js`)
- Dashboard controller → Progress charts: updates charts (evidence: `js/app.js`)
- Progress charts → Chart.js CDN: renders with (evidence: `README.md`)
- Profile and streaks → Cloud Firestore: reads and writes (evidence: `js/firebase.js`)
- Habit persistence → Cloud Firestore: reads and writes (evidence: `js/firebase.js`)
- XP and levels → Cloud Firestore: updates profile (evidence: `js/firebase.js`)
- Badge awards → Profile and streaks: stores awards (evidence: `js/firebase.js`)
- Dashboard controller → Push subscriptions: requests permission (evidence: `js/app.js`)
- Push subscriptions → Push notification services: subscribes (evidence: `js/firebase.js`)
- Habit user → Install prompt: installs app (evidence: `js/pwa.js`)
- Offline and push worker → Offline fallback: serves fallback (evidence: `service-worker.js`)
- Offline and push worker → Push notification services: shows and opens (evidence: `service-worker.js`)
- Habit dashboard → PWA manifest: uses
- Offline and push worker → Habit dashboard: caches assets (evidence: `service-worker.js`)
