# samihzs/sih2026 architecture

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

- Interactive diagram: https://gitdiagram.com/samihzs/sih2026
- Repository: https://github.com/samihzs/sih2026

## Overview

SIH26171 is a Chrome MV3 privacy-preserving browser assistant. The main workflow observes a page, performs local visual and text privacy processing, sends sanitized context to a selected model, grounds its intent to page-owned elements, then validates and executes bounded actions with fresh observations. README documents the pipeline and safety guarantees; sampled source confirms key visual, model-routing, detector, and UI behavior, but several runtime connections rely on that documentation.

Main entry points: [`extension/background.js`](https://github.com/samihzs/sih2026/blob/main/extension/background.js) (Service worker), [`extension/agentCoordinator.js`](https://github.com/samihzs/sih2026/blob/main/extension/agentCoordinator.js) (Agent coordinator), [`extension/modelManager.js`](https://github.com/samihzs/sih2026/blob/main/extension/modelManager.js) (Model router), [`extension/content.js`](https://github.com/samihzs/sih2026/blob/main/extension/content.js) (Page observer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Assistant experience"]
  node_sidebar["Assistant sidebar<br/>[sidebar.js]"]
  node_options["Provider settings<br/>[options.js]"]
  node_background["Service worker<br/>[background.js]"]
end

subgraph group_privacy["Local perception privacy"]
  node_content["Page observer<br/>[content.js]"]
  node_dom["DOM PII detector<br/>[domDetector.js]"]
  node_regex["Text PII detector<br/>[regexDetector.js]"]
  node_fusion["Detection fusion<br/>[detectionFusion.js]"]
  node_visual["Visual pipeline<br/>[visualPipeline.js]"]
  node_worker["Offscreen processor<br/>[visualWorker.js]"]
  node_ocr["Local OCR<br/>[ocrDetector.js]"]
  node_sanitize["Context sanitizer<br/>[sanitize.js]"]
end

subgraph group_actions["Grounded safe actions"]
  node_coordinator["Agent coordinator"]
  node_registry["Element registry<br/>[elementRegistry.js]"]
  node_grounding["Intent grounding<br/>[grounding.js]"]
  node_validate["Action firewall<br/>[validate.js]"]
  node_execute["Bounded executor<br/>[execute.js]"]
end

subgraph group_models["Model integrations"]
  node_manager["Model router<br/>[modelManager.js]"]
  node_gemini["Gemini adapter<br/>[geminiProvider.js]"]
  node_groq["Groq adapter<br/>[groqProvider.js]"]
  node_openrouter["OpenRouter adapter"]
  node_local["Local model adapter<br/>[localProvider.js]"]
end

node_user(("User"))
node_page["Browser page"]
node_chrome["Chrome APIs"]
node_provider_api(("Configured model service"))
node_storage[("Extension storage")]

node_user -->|"requests help"| node_sidebar
node_sidebar -->|"sends requests"| node_background
node_options -->|"configures provider"| node_background
node_background -->|"requests observation"| node_content
node_page -->|"provides DOM"| node_content
node_content -->|"scans elements"| node_dom
node_content -->|"scans visible text"| node_regex
node_content -->|"requests analysis"| node_visual
node_visual -->|"requests processing"| node_background
node_background -->|"captures viewport"| node_chrome
node_background -->|"dispatches image"| node_worker
node_worker -->|"recognizes redacted canvas"| node_ocr
node_dom -->|"supplies detections"| node_fusion
node_regex -->|"supplies detections"| node_fusion
node_worker -->|"supplies visual findings"| node_fusion
node_fusion -->|"provides detections"| node_sanitize
node_content -->|"provides page context"| node_sanitize
node_sanitize -->|"returns protected context"| node_background
node_background -->|"updates context"| node_sidebar
node_background -->|"starts transaction"| node_coordinator
node_coordinator -->|"requests model response"| node_manager
node_manager -->|"routes request"| node_gemini
node_manager -->|"routes request"| node_groq
node_manager -->|"routes request"| node_openrouter
node_manager -->|"routes request"| node_local
node_gemini -.->|"sends sanitized request"| node_provider_api
node_groq -.->|"sends sanitized request"| node_provider_api
node_openrouter -.->|"sends sanitized request"| node_provider_api
node_manager -->|"reads and writes config"| node_storage
node_coordinator -->|"uses page index"| node_registry
node_coordinator -->|"grounds intent"| node_grounding
node_coordinator -->|"checks action"| node_validate
node_coordinator -->|"dispatches action"| node_execute
node_execute -->|"performs bounded action"| node_page
node_coordinator -->|"requests fresh observation"| node_background

click node_sidebar "https://github.com/samihzs/sih2026/blob/main/extension/sidebar.js"
click node_options "https://github.com/samihzs/sih2026/blob/main/extension/options.js"
click node_background "https://github.com/samihzs/sih2026/blob/main/extension/background.js"
click node_content "https://github.com/samihzs/sih2026/blob/main/extension/content.js"
click node_dom "https://github.com/samihzs/sih2026/blob/main/extension/detectors/domDetector.js"
click node_regex "https://github.com/samihzs/sih2026/blob/main/extension/detectors/regexDetector.js"
click node_fusion "https://github.com/samihzs/sih2026/blob/main/extension/detectionFusion.js"
click node_visual "https://github.com/samihzs/sih2026/blob/main/extension/vision/visualPipeline.js"
click node_worker "https://github.com/samihzs/sih2026/blob/main/extension/vision/visualWorker.js"
click node_ocr "https://github.com/samihzs/sih2026/blob/main/extension/detectors/ocrDetector.js"
click node_sanitize "https://github.com/samihzs/sih2026/blob/main/extension/sanitize.js"
click node_coordinator "https://github.com/samihzs/sih2026/blob/main/extension/agentCoordinator.js"
click node_registry "https://github.com/samihzs/sih2026/blob/main/extension/elementRegistry.js"
click node_grounding "https://github.com/samihzs/sih2026/blob/main/extension/grounding.js"
click node_validate "https://github.com/samihzs/sih2026/blob/main/extension/validate.js"
click node_execute "https://github.com/samihzs/sih2026/blob/main/extension/execute.js"
click node_manager "https://github.com/samihzs/sih2026/blob/main/extension/modelManager.js"
click node_gemini "https://github.com/samihzs/sih2026/blob/main/extension/providers/geminiProvider.js"
click node_groq "https://github.com/samihzs/sih2026/blob/main/extension/providers/groqProvider.js"
click node_openrouter "https://github.com/samihzs/sih2026/blob/main/extension/providers/openRouterProvider.js"
click node_local "https://github.com/samihzs/sih2026/blob/main/extension/providers/localProvider.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_sidebar,node_options,node_background,node_user,node_page toneBlue
class node_content,node_dom,node_regex,node_fusion,node_visual,node_worker,node_ocr,node_sanitize,node_storage toneAmber
class node_coordinator,node_registry,node_grounding,node_validate,node_execute,node_chrome toneMint
class node_manager,node_gemini,node_groq,node_openrouter,node_local toneRose
class node_provider_api toneIndigo
```

## Components

### Assistant experience

- [Assistant sidebar](https://github.com/samihzs/sih2026/blob/main/extension/sidebar.js): `extension/sidebar.js`
- [Provider settings](https://github.com/samihzs/sih2026/blob/main/extension/options.js): `extension/options.js`
- [Service worker](https://github.com/samihzs/sih2026/blob/main/extension/background.js): `extension/background.js`

### Local perception privacy

- [Page observer](https://github.com/samihzs/sih2026/blob/main/extension/content.js): `extension/content.js`
- [DOM PII detector](https://github.com/samihzs/sih2026/blob/main/extension/detectors/domDetector.js): `extension/detectors/domDetector.js`
- [Text PII detector](https://github.com/samihzs/sih2026/blob/main/extension/detectors/regexDetector.js): `extension/detectors/regexDetector.js`
- [Detection fusion](https://github.com/samihzs/sih2026/blob/main/extension/detectionFusion.js): `extension/detectionFusion.js`
- [Visual pipeline](https://github.com/samihzs/sih2026/blob/main/extension/vision/visualPipeline.js): `extension/vision/visualPipeline.js`
- [Offscreen processor](https://github.com/samihzs/sih2026/blob/main/extension/vision/visualWorker.js): `extension/vision/visualWorker.js`
- [Local OCR](https://github.com/samihzs/sih2026/blob/main/extension/detectors/ocrDetector.js): `extension/detectors/ocrDetector.js`
- [Context sanitizer](https://github.com/samihzs/sih2026/blob/main/extension/sanitize.js): `extension/sanitize.js`

### Grounded safe actions

- [Agent coordinator](https://github.com/samihzs/sih2026/blob/main/extension/agentCoordinator.js): `extension/agentCoordinator.js`
- [Element registry](https://github.com/samihzs/sih2026/blob/main/extension/elementRegistry.js): `extension/elementRegistry.js`
- [Intent grounding](https://github.com/samihzs/sih2026/blob/main/extension/grounding.js): `extension/grounding.js`
- [Action firewall](https://github.com/samihzs/sih2026/blob/main/extension/validate.js): `extension/validate.js`
- [Bounded executor](https://github.com/samihzs/sih2026/blob/main/extension/execute.js): `extension/execute.js`

### Model integrations

- [Model router](https://github.com/samihzs/sih2026/blob/main/extension/modelManager.js): `extension/modelManager.js`
- [Gemini adapter](https://github.com/samihzs/sih2026/blob/main/extension/providers/geminiProvider.js): `extension/providers/geminiProvider.js`
- [Groq adapter](https://github.com/samihzs/sih2026/blob/main/extension/providers/groqProvider.js): `extension/providers/groqProvider.js`
- [OpenRouter adapter](https://github.com/samihzs/sih2026/blob/main/extension/providers/openRouterProvider.js): `extension/providers/openRouterProvider.js`
- [Local model adapter](https://github.com/samihzs/sih2026/blob/main/extension/providers/localProvider.js): `extension/providers/localProvider.js`

### Other components

- **User**
- **Browser page**
- **Chrome APIs**
- **Configured model service**
- **Extension storage**

## Connections

- User → Assistant sidebar: requests help
- Assistant sidebar → Service worker: sends requests
- Provider settings → Service worker: configures provider
- Service worker → Page observer: requests observation
- Browser page → Page observer: provides DOM
- Page observer → DOM PII detector: scans elements
- Page observer → Text PII detector: scans visible text
- Page observer → Visual pipeline: requests analysis
- Visual pipeline → Service worker: requests processing
- Service worker → Chrome APIs: captures viewport
- Service worker → Offscreen processor: dispatches image
- Offscreen processor → Local OCR: recognizes redacted canvas
- DOM PII detector → Detection fusion: supplies detections
- Text PII detector → Detection fusion: supplies detections
- Offscreen processor → Detection fusion: supplies visual findings
- Detection fusion → Context sanitizer: provides detections
- Page observer → Context sanitizer: provides page context
- Context sanitizer → Service worker: returns protected context
- Service worker → Assistant sidebar: updates context
- Service worker → Agent coordinator: starts transaction
- Agent coordinator → Model router: requests model response
- Model router → Gemini adapter: routes request
- Model router → Groq adapter: routes request
- Model router → OpenRouter adapter: routes request
- Model router → Local model adapter: routes request
- Gemini adapter → Configured model service: sends sanitized request
- Groq adapter → Configured model service: sends sanitized request
- OpenRouter adapter → Configured model service: sends sanitized request
- Model router → Extension storage: reads and writes config
- Agent coordinator → Element registry: uses page index
- Agent coordinator → Intent grounding: grounds intent
- Agent coordinator → Action firewall: checks action
- Agent coordinator → Bounded executor: dispatches action
- Bounded executor → Browser page: performs bounded action
- Agent coordinator → Service worker: requests fresh observation
