# nishwanth2809/ai-attention architecture

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

- Interactive diagram: https://gitdiagram.com/nishwanth2809/ai-attention
- Repository: https://github.com/nishwanth2809/ai-attention

## Overview

Attn is a browser-first focus coach. The user starts a camera or simulated session, receives sampled focus cues and automation responses, then reviews and exports locally saved reports or adjusts privacy settings. The current React application is the product; the archived Flask app is a distinct legacy monitoring system. The current worker, camera hook and signal code are represented from the tree and README; their internal wiring is not fully evidenced by excerpts, so uncertain links are omitted.

Main entry points: [`legacy/app.py`](https://github.com/nishwanth2809/ai-attention/blob/main/legacy/app.py) (Legacy Flask service), [`frontend/src/features/focus/useFocus.js`](https://github.com/nishwanth2809/ai-attention/blob/main/frontend/src/features/focus/useFocus.js) (Session controller), [`frontend/src/App.jsx`](https://github.com/nishwanth2809/ai-attention/blob/main/frontend/src/App.jsx) (App shell), [`frontend/src/core/session.js`](https://github.com/nishwanth2809/ai-attention/blob/main/frontend/src/core/session.js) (Session aggregates)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Focus application"]
  node_shell["App shell<br/>[App.jsx]"]
  node_workspace["Focus workspace<br/>[FocusSpace.jsx]"]
  node_focus["Session controller<br/>[useFocus.js]"]
end

subgraph group_vision["Vision and signals"]
  node_camera["Camera lifecycle<br/>[useCamera.js]"]
  node_worker["Vision worker<br/>[vision-worker.js]"]
  node_signals["Signal calculation<br/>[signals.js]"]
end

subgraph group_rules["Coaching automations"]
  node_automation["Rule engine<br/>[automation.js]"]
  node_editor["Automation editor<br/>[Automations.jsx]"]
  node_coaching["Coaching actions<br/>[useFocus.js]"]
end

subgraph group_reports["Reports and privacy"]
  node_sessiondata["Session aggregates<br/>[session.js]"]
  node_storage[("Browser storage<br/>[storage.js]")]
  node_dashboard["Reports dashboard<br/>[Reports.jsx]"]
  node_settings["Privacy settings<br/>[Settings.jsx]"]
  node_chart["Chart display<br/>[Chart.jsx]"]
end

subgraph group_legacy["Legacy monitor"]
  node_legacyapp["Legacy Flask service<br/>[app.py]"]
  node_legacyvision["Legacy vision analysis<br/>[attention_score.py]"]
  node_face["Face detection<br/>[face_detection.py]"]
  node_blink["Blink detection<br/>[blink_detection.py]"]
  node_gaze["Gaze tracking<br/>[gaze_tracking.py]"]
  node_pose["Head pose<br/>[head_pose.py]"]
  node_legacyui["Legacy dashboard<br/>[App.jsx]"]
  node_legacyvideo["Video panel<br/>[VideoPanel.jsx]"]
  node_legacydata["Legacy data polling"]
  node_sqlite[("Session database<br/>[app.py]")]
end

node_person(("Focus user"))

node_person -->|"uses"| node_shell
node_shell -->|"creates"| node_focus
node_shell -->|"renders"| node_workspace
node_shell -->|"renders"| node_editor
node_shell -->|"renders"| node_dashboard
node_shell -->|"renders"| node_settings
node_workspace -->|"uses"| node_focus
node_focus -->|"starts"| node_camera
node_focus -->|"evaluates"| node_automation
node_focus -->|"records"| node_sessiondata
node_focus -->|"loads and saves"| node_storage
node_focus -->|"dispatches"| node_coaching
node_camera -->|"uses"| node_signals
node_camera -.->|"processes frames"| node_worker
node_editor -->|"configures"| node_automation
node_editor -->|"formats activity"| node_sessiondata
node_dashboard -->|"formats and exports"| node_sessiondata
node_dashboard -->|"renders"| node_chart
node_settings -->|"clears reports"| node_sessiondata
node_settings -.->|"manages"| node_storage
node_legacyui -->|"renders"| node_legacyvideo
node_legacyui -->|"uses"| node_legacydata
node_legacyvideo -.->|"streams video"| node_legacyapp
node_legacydata -->|"polls scores"| node_legacyapp
node_legacyapp -->|"scores frames"| node_legacyvision
node_legacyapp -->|"detects faces"| node_face
node_legacyapp -->|"measures blinks"| node_blink
node_legacyapp -->|"tracks gaze"| node_gaze
node_legacyapp -->|"estimates pose"| node_pose
node_legacyapp -->|"stores sessions"| node_sqlite

click node_shell "https://github.com/nishwanth2809/ai-attention/blob/main/frontend/src/App.jsx"
click node_workspace "https://github.com/nishwanth2809/ai-attention/blob/main/frontend/src/features/focus/FocusSpace.jsx"
click node_focus "https://github.com/nishwanth2809/ai-attention/blob/main/frontend/src/features/focus/useFocus.js"
click node_camera "https://github.com/nishwanth2809/ai-attention/blob/main/frontend/src/features/focus/useCamera.js"
click node_worker "https://github.com/nishwanth2809/ai-attention/blob/main/frontend/public/vision-worker.js"
click node_signals "https://github.com/nishwanth2809/ai-attention/blob/main/frontend/src/features/focus/signals.js"
click node_automation "https://github.com/nishwanth2809/ai-attention/blob/main/frontend/src/core/automation.js"
click node_editor "https://github.com/nishwanth2809/ai-attention/blob/main/frontend/src/features/automations/Automations.jsx"
click node_coaching "https://github.com/nishwanth2809/ai-attention/blob/main/frontend/src/features/focus/useFocus.js"
click node_sessiondata "https://github.com/nishwanth2809/ai-attention/blob/main/frontend/src/core/session.js"
click node_storage "https://github.com/nishwanth2809/ai-attention/blob/main/frontend/src/core/storage.js"
click node_dashboard "https://github.com/nishwanth2809/ai-attention/blob/main/frontend/src/features/reports/Reports.jsx"
click node_settings "https://github.com/nishwanth2809/ai-attention/blob/main/frontend/src/features/reports/Settings.jsx"
click node_chart "https://github.com/nishwanth2809/ai-attention/blob/main/frontend/src/ui/Chart.jsx"
click node_legacyapp "https://github.com/nishwanth2809/ai-attention/blob/main/legacy/app.py"
click node_legacyvision "https://github.com/nishwanth2809/ai-attention/blob/main/legacy/src/attention_score.py"
click node_face "https://github.com/nishwanth2809/ai-attention/blob/main/legacy/src/face_detection.py"
click node_blink "https://github.com/nishwanth2809/ai-attention/blob/main/legacy/src/blink_detection.py"
click node_gaze "https://github.com/nishwanth2809/ai-attention/blob/main/legacy/src/gaze_tracking.py"
click node_pose "https://github.com/nishwanth2809/ai-attention/blob/main/legacy/src/head_pose.py"
click node_legacyui "https://github.com/nishwanth2809/ai-attention/blob/main/legacy/frontend-src/App.jsx"
click node_legacyvideo "https://github.com/nishwanth2809/ai-attention/blob/main/legacy/frontend-src/components/VideoPanel.jsx"
click node_legacydata "https://github.com/nishwanth2809/ai-attention/blob/main/legacy/frontend-src/hooks/useAttentionData.js"
click node_sqlite "https://github.com/nishwanth2809/ai-attention/blob/main/legacy/app.py"

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_shell,node_workspace,node_focus,node_person toneBlue
class node_camera,node_worker,node_signals toneAmber
class node_automation,node_editor,node_coaching toneMint
class node_sessiondata,node_storage,node_dashboard,node_settings,node_chart toneRose
class node_legacyapp,node_legacyvision,node_face,node_blink,node_gaze,node_pose,node_legacyui,node_legacyvideo,node_legacydata,node_sqlite toneIndigo
```

## Components

### Focus application

- [App shell](https://github.com/nishwanth2809/ai-attention/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Focus workspace](https://github.com/nishwanth2809/ai-attention/blob/main/frontend/src/features/focus/FocusSpace.jsx): `frontend/src/features/focus/FocusSpace.jsx`
- [Session controller](https://github.com/nishwanth2809/ai-attention/blob/main/frontend/src/features/focus/useFocus.js): `frontend/src/features/focus/useFocus.js`

### Vision and signals

- [Camera lifecycle](https://github.com/nishwanth2809/ai-attention/blob/main/frontend/src/features/focus/useCamera.js): `frontend/src/features/focus/useCamera.js`
- [Vision worker](https://github.com/nishwanth2809/ai-attention/blob/main/frontend/public/vision-worker.js): `frontend/public/vision-worker.js`
- [Signal calculation](https://github.com/nishwanth2809/ai-attention/blob/main/frontend/src/features/focus/signals.js): `frontend/src/features/focus/signals.js`

### Coaching automations

- [Rule engine](https://github.com/nishwanth2809/ai-attention/blob/main/frontend/src/core/automation.js): `frontend/src/core/automation.js`
- [Automation editor](https://github.com/nishwanth2809/ai-attention/blob/main/frontend/src/features/automations/Automations.jsx): `frontend/src/features/automations/Automations.jsx`
- [Coaching actions](https://github.com/nishwanth2809/ai-attention/blob/main/frontend/src/features/focus/useFocus.js): `frontend/src/features/focus/useFocus.js`

### Reports and privacy

- [Session aggregates](https://github.com/nishwanth2809/ai-attention/blob/main/frontend/src/core/session.js): `frontend/src/core/session.js`
- [Browser storage](https://github.com/nishwanth2809/ai-attention/blob/main/frontend/src/core/storage.js): `frontend/src/core/storage.js`
- [Reports dashboard](https://github.com/nishwanth2809/ai-attention/blob/main/frontend/src/features/reports/Reports.jsx): `frontend/src/features/reports/Reports.jsx`
- [Privacy settings](https://github.com/nishwanth2809/ai-attention/blob/main/frontend/src/features/reports/Settings.jsx): `frontend/src/features/reports/Settings.jsx`
- [Chart display](https://github.com/nishwanth2809/ai-attention/blob/main/frontend/src/ui/Chart.jsx): `frontend/src/ui/Chart.jsx`

### Legacy monitor

- [Legacy Flask service](https://github.com/nishwanth2809/ai-attention/blob/main/legacy/app.py): `legacy/app.py`
- [Legacy vision analysis](https://github.com/nishwanth2809/ai-attention/blob/main/legacy/src/attention_score.py): `legacy/src/attention_score.py`
- [Face detection](https://github.com/nishwanth2809/ai-attention/blob/main/legacy/src/face_detection.py): `legacy/src/face_detection.py`
- [Blink detection](https://github.com/nishwanth2809/ai-attention/blob/main/legacy/src/blink_detection.py): `legacy/src/blink_detection.py`
- [Gaze tracking](https://github.com/nishwanth2809/ai-attention/blob/main/legacy/src/gaze_tracking.py): `legacy/src/gaze_tracking.py`
- [Head pose](https://github.com/nishwanth2809/ai-attention/blob/main/legacy/src/head_pose.py): `legacy/src/head_pose.py`
- [Legacy dashboard](https://github.com/nishwanth2809/ai-attention/blob/main/legacy/frontend-src/App.jsx): `legacy/frontend-src/App.jsx`
- [Video panel](https://github.com/nishwanth2809/ai-attention/blob/main/legacy/frontend-src/components/VideoPanel.jsx): `legacy/frontend-src/components/VideoPanel.jsx`
- [Legacy data polling](https://github.com/nishwanth2809/ai-attention/blob/main/legacy/frontend-src/hooks/useAttentionData.js): `legacy/frontend-src/hooks/useAttentionData.js`
- [Session database](https://github.com/nishwanth2809/ai-attention/blob/main/legacy/app.py): `legacy/app.py`

### Other components

- **Focus user**

## Connections

- Focus user → App shell: uses (evidence: `frontend/src/App.jsx`)
- App shell → Session controller: creates (evidence: `frontend/src/App.jsx`)
- App shell → Focus workspace: renders (evidence: `frontend/src/App.jsx`)
- App shell → Automation editor: renders (evidence: `frontend/src/App.jsx`)
- App shell → Reports dashboard: renders (evidence: `frontend/src/App.jsx`)
- App shell → Privacy settings: renders (evidence: `frontend/src/App.jsx`)
- Focus workspace → Session controller: uses (evidence: `frontend/src/App.jsx`)
- Session controller → Camera lifecycle: starts (evidence: `frontend/src/features/focus/useFocus.js`)
- Session controller → Rule engine: evaluates (evidence: `frontend/src/features/focus/useFocus.js`)
- Session controller → Session aggregates: records (evidence: `frontend/src/features/focus/useFocus.js`)
- Session controller → Browser storage: loads and saves (evidence: `frontend/src/features/focus/useFocus.js`)
- Session controller → Coaching actions: dispatches (evidence: `frontend/src/features/focus/useFocus.js`)
- Camera lifecycle → Signal calculation: uses (evidence: `frontend/src/features/focus/useCamera.js`)
- Camera lifecycle → Vision worker: processes frames
- Automation editor → Rule engine: configures (evidence: `frontend/src/features/automations/Automations.jsx`)
- Automation editor → Session aggregates: formats activity (evidence: `frontend/src/features/automations/Automations.jsx`)
- Reports dashboard → Session aggregates: formats and exports (evidence: `frontend/src/features/reports/Reports.jsx`)
- Reports dashboard → Chart display: renders (evidence: `README.md`)
- Privacy settings → Session aggregates: clears reports (evidence: `frontend/src/features/reports/Settings.jsx`)
- Privacy settings → Browser storage: manages
- Legacy dashboard → Video panel: renders (evidence: `legacy/frontend-src/App.jsx`)
- Legacy dashboard → Legacy data polling: uses (evidence: `legacy/frontend-src/App.jsx`)
- Video panel → Legacy Flask service: streams video
- Legacy data polling → Legacy Flask service: polls scores (evidence: `legacy/frontend-src/hooks/useAttentionData.js`)
- Legacy Flask service → Legacy vision analysis: scores frames (evidence: `legacy/app.py`)
- Legacy Flask service → Face detection: detects faces (evidence: `legacy/app.py`)
- Legacy Flask service → Blink detection: measures blinks (evidence: `legacy/app.py`)
- Legacy Flask service → Gaze tracking: tracks gaze (evidence: `legacy/app.py`)
- Legacy Flask service → Head pose: estimates pose (evidence: `legacy/app.py`)
- Legacy Flask service → Session database: stores sessions (evidence: `legacy/app.py`)
