# reginacas/sense-ui architecture

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

- Interactive diagram: https://gitdiagram.com/reginacas/sense-ui
- Repository: https://github.com/reginacas/sense-ui

## Overview

1. **What this repository is**
   SenseUI is a **Chromium extension**, not a server-backed app. The runtime boundary is the browser itself plus an **external AI provider** configured by the user. There is no backend service in this repo.

2. **Top-level runtime shape**
   The extension is organized around a **background script** and several **HTML-based UI surfaces**. The key runtime files are `src/background.js` and the bundled page scripts: `script-bundled.js`, `settings-bundled.js`, `projects-bundled.js`, and `about-bundled.js`.

3. **Main user-facing surface**
   `src/index.html` is the primary chat interface. It is the place where users ask questions about the current webpage, trigger quick prompts, and read structured feedback. `src/styles.css` provides the shared visual layer across these pages.

4. **Extension entry and navigation**
   `src/manifest.json` defines the extension’s entry points and browser integration, including the popup/page wiring and the keyboard shortcut mentioned in the README (`Ctrl + Shift + S`). The manifest is the boundary that connects the browser’s extension lifecycle to the extension’s pages and background logic.

5. **Background orchestration**
   `src/background.js` is the coordination layer. It is where extension-wide events are handled: lifecycle events, shortcut/command handling, and message passing between UI pages and the browser APIs. This script is the natural place for tab capture and any privileged browser interactions.

6. **AI feedback pipeline**
   The core data flow is: **user prompt + current tab context → request to AI provider → response returned to the UI**. The README says SenseUI uses the active tab’s **HTML/CSS and screenshots** to generate feedback, so the extension’s job is to collect page context, package it into a request, and render the returned guidance in the chat UI.

7. **Page context capture**
   A major architectural concern is **current-page inspection**. The roadmap states the extension moved from viewport-only screenshots to **full-page screenshots**, configurable from settings. That means the capture subsystem likely needs browser permissions, tab access, and screenshot APIs, and it must balance fidelity with accessibility/performance.

8. **Settings as a control plane**
   `src/settings.html` and `src/settings-bundled.js` manage user configuration. This includes AI credentials, feedback/detail preferences, shortcut customization, screenshot mode, and reset behavior. Settings are a key boundary because they control how the rest of the extension behaves without changing the main chat UI.

9. **Secondary UI surfaces**
   `src/help.html`, `src/welcome.html`, and `src/projects.html` are separate extension pages with their own bundled scripts. Based on the README and filenames, these are supporting surfaces for onboarding/help, project or context management, and potentially future workflow organization. They are not the primary chat runtime, but they extend the product around it.

10. **State and persistence**
   The extension is designed around **local browser persistence** for settings and session state. The README also calls out future/ongoing support for **chat persistence across restarts** and download/export behavior. That means the architecture likely centers on browser storage rather than a remote database.

11. **Accessibility-first design**
   Accessibility is not just a feature; it is a core architectural constraint. The repo emphasizes keyboard navigation, semantic headings, screen-reader-friendly interaction, quick action prompts, and structured responses. The UI layer therefore needs to be navigable without sight and should preserve meaningful reading order and focus behavior.

12. **Operational/documentation layer**
   The repository includes extensive policy and process docs: privacy/data handling, contribution rules, setup, quickstart, and sprint retrospectives. These don’t change runtime behavior, but they matter for architecture because they reflect the project’s privacy-sensitive research context and its user-testing workflow with blind and low-vision contributors.

13. **Tooling and packaging**
   The presence of `*-bundled.js` files suggests the source is built into browser-ready bundles before release. The repo also uses linting/formatting and Git hooks, but those are supporting engineering controls rather than runtime components.

14. **How to draw the diagram**
   A good architecture diagram should show:
   - the **browser extension shell** as the main system,
   - **background.js** as the coordinator,
   - **index/settings/help/projects/welcome** as separate extension pages,
   - the **active webpage** as the source of page context,
   - the **external AI API** as the only external service boundary,
   - and **browser storage** as the persistence layer for settings and conversation state.

Main entry points: [`src/background.js`](https://github.com/reginacas/sense-ui/blob/main/src/background.js) (Background), [`src/manifest.json`](https://github.com/reginacas/sense-ui/blob/main/src/manifest.json) (Manifest), [`src/styles.css`](https://github.com/reginacas/sense-ui/blob/main/src/styles.css) (Styles), [`src/index.html`](https://github.com/reginacas/sense-ui/blob/main/src/index.html) (Chat UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_extension["Extension runtime"]
  node_manifest["Manifest<br/>extension config<br/>[manifest.json]"]
  node_background["Background<br/>coordinator<br/>[background.js]"]
  node_chat_ui["Chat UI<br/>popup page<br/>[index.html]"]
  node_chat_script["Chat Script<br/>ui logic<br/>[script-bundled.js]"]
  node_settings_page["Settings<br/>[settings.html]"]
  node_settings_script["Settings Logic"]
  node_projects_page["Projects<br/>project page<br/>[projects.html]"]
  node_projects_script["Projects Logic<br/>project logic"]
  node_help_page["Help<br/>support page<br/>[help.html]"]
  node_welcome_page["Welcome<br/>onboarding page<br/>[welcome.html]"]
  node_about_script["About Logic<br/>info logic<br/>[about-bundled.js]"]
  node_styles["Styles<br/>shared css<br/>[styles.css]"]
end

subgraph group_platform["Browser + AI"]
  node_active_tab(("Active Tab<br/>webpage context"))
  node_browser_api{{"Browser APIs<br/>extension api"}}
  node_storage[("Local Storage<br/>persistence")]
  node_ai_provider{{"AI Provider<br/>external service"}}
end

subgraph group_support["Support files"]
  node_docs["Docs & Policy<br/>repo docs<br/>[README.md]"]
end

node_manifest -->|"registers"| node_background
node_manifest -->|"opens"| node_chat_ui
node_manifest -->|"opens"| node_settings_page
node_manifest -->|"opens"| node_projects_page
node_manifest -->|"opens"| node_help_page
node_manifest -->|"opens"| node_welcome_page
node_background -->|"uses"| node_browser_api
node_background -->|"captures"| node_active_tab
node_background -->|"requests"| node_ai_provider
node_background -->|"reads/writes"| node_storage
node_chat_ui -->|"runs"| node_chat_script
node_chat_ui -->|"uses"| node_styles
node_chat_script -->|"messages"| node_background
node_chat_script -->|"reads/writes"| node_storage
node_settings_page -->|"runs"| node_settings_script
node_settings_page -->|"uses"| node_styles
node_settings_script -->|"updates"| node_storage
node_projects_page -->|"runs"| node_projects_script
node_projects_page -->|"uses"| node_styles
node_projects_script -->|"updates"| node_storage
node_help_page -->|"uses"| node_styles
node_welcome_page -->|"uses"| node_styles
node_about_script -->|"uses"| node_styles
node_background -->|"notifies"| node_chat_ui

click node_manifest "https://github.com/reginacas/sense-ui/blob/main/src/manifest.json"
click node_background "https://github.com/reginacas/sense-ui/blob/main/src/background.js"
click node_chat_ui "https://github.com/reginacas/sense-ui/blob/main/src/index.html"
click node_chat_script "https://github.com/reginacas/sense-ui/blob/main/src/script-bundled.js"
click node_settings_page "https://github.com/reginacas/sense-ui/blob/main/src/settings.html"
click node_settings_script "https://github.com/reginacas/sense-ui/blob/main/src/settings-bundled.js"
click node_projects_page "https://github.com/reginacas/sense-ui/blob/main/src/projects.html"
click node_projects_script "https://github.com/reginacas/sense-ui/blob/main/src/projects-bundled.js"
click node_help_page "https://github.com/reginacas/sense-ui/blob/main/src/help.html"
click node_welcome_page "https://github.com/reginacas/sense-ui/blob/main/src/welcome.html"
click node_about_script "https://github.com/reginacas/sense-ui/blob/main/src/about-bundled.js"
click node_styles "https://github.com/reginacas/sense-ui/blob/main/src/styles.css"
click node_docs "https://github.com/reginacas/sense-ui/blob/main/README.md"

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_manifest,node_background,node_chat_ui,node_chat_script,node_settings_page,node_settings_script,node_projects_page,node_projects_script,node_help_page,node_welcome_page,node_about_script,node_styles toneBlue
class node_active_tab,node_browser_api,node_storage,node_ai_provider toneAmber
class node_docs toneMint
```

## Components

### Extension runtime

Browser extension shell, background coordination, and UI surfaces.

- [Manifest](https://github.com/reginacas/sense-ui/blob/main/src/manifest.json): extension config · Declares extension entry points, permissions, and commands. · `src/manifest.json`
- [Background](https://github.com/reginacas/sense-ui/blob/main/src/background.js): coordinator · Handles extension lifecycle, commands, messaging, and privileged browser work. · `src/background.js`
- [Chat UI](https://github.com/reginacas/sense-ui/blob/main/src/index.html): popup page · Primary user interface for prompts, feedback, and page-aware chat. · `src/index.html`
- [Chat Script](https://github.com/reginacas/sense-ui/blob/main/src/script-bundled.js): ui logic · Runs the main chat experience and renders returned guidance. · `src/script-bundled.js`
- [Settings](https://github.com/reginacas/sense-ui/blob/main/src/settings.html): settings page · Configuration surface for credentials, preferences, shortcuts, and reset behavior. · `src/settings.html`
- [Settings Logic](https://github.com/reginacas/sense-ui/blob/main/src/settings-bundled.js): settings logic · Applies user preferences and stores extension configuration. · `src/settings-bundled.js`
- [Projects](https://github.com/reginacas/sense-ui/blob/main/src/projects.html): project page · Project or context management surface for organizing work. · `src/projects.html`
- [Projects Logic](https://github.com/reginacas/sense-ui/blob/main/src/projects-bundled.js): project logic · Implements project-related page behavior. · `src/projects-bundled.js`
- [Help](https://github.com/reginacas/sense-ui/blob/main/src/help.html): support page · Onboarding and help surface. · `src/help.html`
- [Welcome](https://github.com/reginacas/sense-ui/blob/main/src/welcome.html): onboarding page · First-run or introductory extension page. · `src/welcome.html`
- [About Logic](https://github.com/reginacas/sense-ui/blob/main/src/about-bundled.js): info logic · Implements the about page behavior. · `src/about-bundled.js`
- [Styles](https://github.com/reginacas/sense-ui/blob/main/src/styles.css): shared css · Shared visual layer across extension pages. · `src/styles.css`

### Browser + AI

External boundaries the extension talks to at runtime.

- **Active Tab**: webpage context · Current webpage inspected for HTML, CSS, and screenshots.
- **Browser APIs**: extension api · Tabs, commands, screenshots, storage, and messaging primitives.
- **Local Storage**: persistence · Browser-local persistence for settings and session state.
- **AI Provider**: external service · User-configured external model or API endpoint.

### Support files

Shared presentation and non-runtime supporting pages.

- [Docs & Policy](https://github.com/reginacas/sense-ui/blob/main/README.md): repo docs · Setup, privacy, contribution, and project documentation. · `README.md`

## Connections

- Manifest → Background: registers · Wires lifecycle, commands, and privileged entry points.
- Manifest → Chat UI: opens · Defines the primary extension surface.
- Manifest → Settings: opens · Exposes settings as a separate page.
- Manifest → Projects: opens · Exposes project management page.
- Manifest → Help: opens · Exposes help page.
- Manifest → Welcome: opens · Exposes onboarding page.
- Background → Browser APIs: uses · Performs extension-wide browser interactions.
- Background → Active Tab: captures · Reads the current page context for feedback generation.
- Background → AI Provider: requests · Sends prompt plus page context to the configured model.
- Background → Local Storage: reads/writes · Persists settings and session state.
- Chat UI → Chat Script: runs · HTML shell loads the main chat logic.
- Chat UI → Styles: uses · Shares the common visual layer.
- Chat Script → Background: messages · Sends user prompts and receives generated feedback.
- Chat Script → Local Storage: reads/writes · Uses local persistence for chat state.
- Settings → Settings Logic: runs · HTML shell loads settings logic.
- Settings → Styles: uses · Shares the common visual layer.
- Settings Logic → Local Storage: updates · Stores preferences, credentials, and shortcuts.
- Projects → Projects Logic: runs · HTML shell loads project logic.
- Projects → Styles: uses · Shares the common visual layer.
- Projects Logic → Local Storage: updates · Persists project-related state.
- Help → Styles: uses · Shares the common visual layer.
- Welcome → Styles: uses · Shares the common visual layer.
- About Logic → Styles: uses · Shares the common visual layer.
- Background → Chat UI: notifies · Pushes results and state changes back to the chat interface.
