# daanyaal5/flowstate architecture

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

- Interactive diagram: https://gitdiagram.com/daanyaal5/flowstate
- Repository: https://github.com/daanyaal5/flowstate

## Overview

FlowState is a Chrome extension for digital wellness. Chrome tab and alarm events feed background monitoring, which records activity and can open an overload overlay or send reminders. Users can review stats in the popup, explore history and charts in the dashboard, adjust settings, and complete a sunset reflection; the dashboard persists reflection answers and can suggest tab cleanup. The README documents additional notification and chart capabilities not fully visible in the excerpts. Some service-worker handlers and UI wiring are unsampled, so those links are shown only where documented or directly evidenced.

Main entry points: [`backend/background.js`](https://github.com/daanyaal5/flowstate/blob/main/backend/background.js) (Background Guardian), [`frontend/dashboard/dashboard.js`](https://github.com/daanyaal5/flowstate/blob/main/frontend/dashboard/dashboard.js) (Analytics Dashboard), [`frontend/popup/popup.js`](https://github.com/daanyaal5/flowstate/blob/main/frontend/popup/popup.js) (Quick Stats Popup), [`frontend/overlay/overlay.js`](https://github.com/daanyaal5/flowstate/blob/main/frontend/overlay/overlay.js) (Intervention Overlay)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_monitoring["Wellness Monitoring"]
  node_background["Background Guardian<br/>[background.js]"]
  node_wellness_data[("Wellness Records<br/>[background.js]")]
end

subgraph group_intervention["Gentle Interventions"]
  node_overlay["Intervention Overlay<br/>[overlay.js]"]
  node_notifications["Wellness Notifications<br/>[background.js]"]
end

subgraph group_reflection["Sunset Reflection"]
  node_sunset["Reflection Journal<br/>[dashboard.js]"]
end

subgraph group_insights["Insights And Controls"]
  node_popup["Quick Stats Popup<br/>[popup.js]"]
  node_settings["Wellness Settings<br/>[popup.js]"]
  node_dashboard["Analytics Dashboard<br/>[dashboard.js]"]
end

node_user(("User"))
node_chrome["Chrome APIs"]

node_chrome -->|"sends events"| node_background
node_background -->|"reads and writes"| node_wellness_data
node_background -->|"checks tabs"| node_chrome
node_background -->|"opens on overload"| node_overlay
node_background -->|"creates nudges"| node_notifications
node_notifications -->|"offers actions"| node_user
node_user -->|"opens extension"| node_popup
node_popup -->|"requests stats"| node_background
node_popup -->|"opens views"| node_chrome
node_popup -->|"edits controls"| node_settings
node_settings -->|"stores preferences"| node_wellness_data
node_user -->|"chooses intervention"| node_overlay
node_overlay -->|"requests tab trim"| node_background
node_overlay -->|"sets cooldown"| node_chrome
node_user -->|"opens dashboard"| node_dashboard
node_dashboard -->|"loads analytics"| node_wellness_data
node_dashboard -->|"creates reflection"| node_sunset
node_sunset -->|"saves journal"| node_wellness_data
node_dashboard -->|"reports reflection"| node_background
node_dashboard -->|"suggests tab cleanup"| node_chrome

click node_background "https://github.com/daanyaal5/flowstate/blob/main/backend/background.js"
click node_wellness_data "https://github.com/daanyaal5/flowstate/blob/main/backend/background.js"
click node_overlay "https://github.com/daanyaal5/flowstate/blob/main/frontend/overlay/overlay.js"
click node_notifications "https://github.com/daanyaal5/flowstate/blob/main/backend/background.js"
click node_popup "https://github.com/daanyaal5/flowstate/blob/main/frontend/popup/popup.js"
click node_settings "https://github.com/daanyaal5/flowstate/blob/main/frontend/popup/popup.js"
click node_dashboard "https://github.com/daanyaal5/flowstate/blob/main/frontend/dashboard/dashboard.js"
click node_sunset "https://github.com/daanyaal5/flowstate/blob/main/frontend/dashboard/dashboard.js"

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_background,node_wellness_data,node_user toneBlue
class node_overlay,node_notifications toneAmber
class node_sunset,node_chrome toneMint
class node_popup,node_settings,node_dashboard toneRose
```

## Components

### Wellness Monitoring

- [Background Guardian](https://github.com/daanyaal5/flowstate/blob/main/backend/background.js): `backend/background.js`
- [Wellness Records](https://github.com/daanyaal5/flowstate/blob/main/backend/background.js): `backend/background.js`

### Gentle Interventions

- [Intervention Overlay](https://github.com/daanyaal5/flowstate/blob/main/frontend/overlay/overlay.js): `frontend/overlay/overlay.js`
- [Wellness Notifications](https://github.com/daanyaal5/flowstate/blob/main/backend/background.js): `backend/background.js`

### Sunset Reflection

- [Reflection Journal](https://github.com/daanyaal5/flowstate/blob/main/frontend/dashboard/dashboard.js): `frontend/dashboard/dashboard.js`

### Insights And Controls

- [Quick Stats Popup](https://github.com/daanyaal5/flowstate/blob/main/frontend/popup/popup.js): `frontend/popup/popup.js`
- [Wellness Settings](https://github.com/daanyaal5/flowstate/blob/main/frontend/popup/popup.js): `frontend/popup/popup.js`
- [Analytics Dashboard](https://github.com/daanyaal5/flowstate/blob/main/frontend/dashboard/dashboard.js): `frontend/dashboard/dashboard.js`

### Other components

- **User**
- **Chrome APIs**

## Connections

- Chrome APIs → Background Guardian: sends events (evidence: `backend/background.js`)
- Background Guardian → Wellness Records: reads and writes (evidence: `backend/background.js`)
- Background Guardian → Chrome APIs: checks tabs (evidence: `backend/background.js`)
- Background Guardian → Intervention Overlay: opens on overload (evidence: `backend/background.js`)
- Background Guardian → Wellness Notifications: creates nudges (evidence: `backend/background.js`)
- Wellness Notifications → User: offers actions (evidence: `README.md`)
- User → Quick Stats Popup: opens extension (evidence: `README.md`)
- Quick Stats Popup → Background Guardian: requests stats (evidence: `frontend/popup/popup.js`)
- Quick Stats Popup → Chrome APIs: opens views (evidence: `frontend/popup/popup.js`)
- Quick Stats Popup → Wellness Settings: edits controls (evidence: `frontend/popup/popup.js`)
- Wellness Settings → Wellness Records: stores preferences (evidence: `frontend/popup/popup.js`)
- User → Intervention Overlay: chooses intervention (evidence: `README.md`)
- Intervention Overlay → Background Guardian: requests tab trim (evidence: `frontend/overlay/overlay.js`)
- Intervention Overlay → Chrome APIs: sets cooldown (evidence: `frontend/overlay/overlay.js`)
- User → Analytics Dashboard: opens dashboard (evidence: `README.md`)
- Analytics Dashboard → Wellness Records: loads analytics (evidence: `frontend/dashboard/dashboard.js`)
- Analytics Dashboard → Reflection Journal: creates reflection (evidence: `frontend/dashboard/dashboard.js`)
- Reflection Journal → Wellness Records: saves journal (evidence: `frontend/dashboard/dashboard.js`)
- Analytics Dashboard → Background Guardian: reports reflection (evidence: `frontend/dashboard/dashboard.js`)
- Analytics Dashboard → Chrome APIs: suggests tab cleanup (evidence: `README.md`)
