# 1129aliasgar/openbrowser architecture

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

- Interactive diagram: https://gitdiagram.com/1129aliasgar/openbrowser
- Repository: https://github.com/1129aliasgar/openbrowser

## Overview

OpenBrowser is a local CLI agent harness that connects a developer’s project to browser-based AI chat without API keys. The main workflow gathers optional project context, builds an ask or agent prompt, sends it through the local bridge to the browser extension, and returns the AI response to the terminal. Agent responses are parsed and validated before changes are previewed and applied. The README documents the browser bridge and supported providers; some internal extension wiring is not shown in the excerpts, so those links are omitted or marked unverified.

Main entry points: [`src/server/index.ts`](https://github.com/1129aliasgar/openbrowser/blob/main/src/server/index.ts) (Bridge API), [`src/index.ts`](https://github.com/1129aliasgar/openbrowser/blob/main/src/index.ts) (CLI modes), [`browser-extension/src/providers.js`](https://github.com/1129aliasgar/openbrowser/blob/main/browser-extension/src/providers.js) (Provider registry), [`src/client/bridge-client.ts`](https://github.com/1129aliasgar/openbrowser/blob/main/src/client/bridge-client.ts) (Bridge client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI workflow"]
  node_cli["CLI modes<br/>[index.ts]"]
  node_context["Project context<br/>[file-context.ts]"]
  node_prompts["System prompts<br/>[system.ts]"]
  node_client["Bridge client<br/>[bridge-client.ts]"]
  node_terminal["Terminal output<br/>[terminal.ts]"]
end

subgraph group_bridge["Local bridge"]
  node_server["Bridge API<br/>[index.ts]"]
  node_sessions[("Session store<br/>[session-store.ts]")]
  node_sse["SSE hub<br/>[sse-hub.ts]"]
end

subgraph group_agent["Agent processing"]
  node_parser["Agent response parser<br/>[index.ts]"]
  node_validation["Operation validation<br/>[index.ts]"]
  node_operations["Diff and apply<br/>[index.ts]"]
end

subgraph group_extension["Browser extension"]
  node_extension["Extension background<br/>[background.js]"]
  node_content["AI page integration<br/>[content-script.js]"]
  node_providers["Provider registry<br/>[providers.js]"]
  node_chatgpt["ChatGPT adapter<br/>[chatgpt-api.js]"]
  node_gemini["Gemini adapter<br/>[gemini-api.js]"]
  node_deepseek["DeepSeek adapter<br/>[deepseek-api.js]"]
end

subgraph group_state["Workspace state"]
  node_filesystem[("Project files")]
  node_memory[("Project memory<br/>[index.ts]")]
  node_promptfile["Large prompt files<br/>[index.ts]"]
end

node_developer(("Developer"))
node_ai(("Browser AI service"))

node_developer -->|"runs modes"| node_cli
node_cli -->|"loads context"| node_context
node_cli -->|"builds prompt"| node_prompts
node_cli -->|"submits prompt"| node_client
node_cli -->|"starts bridge"| node_server
node_cli -->|"prints results"| node_terminal
node_client -->|"uses local API"| node_server
node_server -->|"manages sessions"| node_sessions
node_server -->|"streams events"| node_sse
node_server -->|"generates context"| node_context
node_server -->|"executes operations"| node_operations
node_server -->|"stores prompts"| node_memory
node_server -->|"writes large prompts"| node_promptfile
node_extension -->|"bridges over local API"| node_server
node_extension -.->|"coordinates page capture"| node_content
node_content -->|"injects and captures"| node_ai
node_providers -.->|"selects adapter"| node_chatgpt
node_providers -.->|"selects adapter"| node_gemini
node_providers -.->|"selects adapter"| node_deepseek
node_server -.->|"parses agent response"| node_parser
node_parser -->|"validates operations"| node_validation
node_server -->|"validates submissions"| node_validation
node_operations -->|"plans and applies diffs"| node_filesystem
node_operations -->|"appends history"| node_memory
node_context -->|"reads project files"| node_filesystem
node_memory -->|"stores prompt text"| node_promptfile
node_client -.->|"waits for response"| node_sessions

click node_cli "https://github.com/1129aliasgar/openbrowser/blob/main/src/index.ts"
click node_context "https://github.com/1129aliasgar/openbrowser/blob/main/src/context/file-context.ts"
click node_prompts "https://github.com/1129aliasgar/openbrowser/blob/main/src/prompts/system.ts"
click node_client "https://github.com/1129aliasgar/openbrowser/blob/main/src/client/bridge-client.ts"
click node_terminal "https://github.com/1129aliasgar/openbrowser/blob/main/src/shared/terminal.ts"
click node_server "https://github.com/1129aliasgar/openbrowser/blob/main/src/server/index.ts"
click node_sessions "https://github.com/1129aliasgar/openbrowser/blob/main/src/server/session-store.ts"
click node_sse "https://github.com/1129aliasgar/openbrowser/blob/main/src/server/sse-hub.ts"
click node_extension "https://github.com/1129aliasgar/openbrowser/blob/main/browser-extension/src/background.js"
click node_content "https://github.com/1129aliasgar/openbrowser/blob/main/browser-extension/src/content-script.js"
click node_providers "https://github.com/1129aliasgar/openbrowser/blob/main/browser-extension/src/providers.js"
click node_chatgpt "https://github.com/1129aliasgar/openbrowser/blob/main/browser-extension/src/chatgpt-api.js"
click node_gemini "https://github.com/1129aliasgar/openbrowser/blob/main/browser-extension/src/gemini-api.js"
click node_deepseek "https://github.com/1129aliasgar/openbrowser/blob/main/browser-extension/src/deepseek-api.js"
click node_parser "https://github.com/1129aliasgar/openbrowser/blob/main/src/parser/index.ts"
click node_validation "https://github.com/1129aliasgar/openbrowser/blob/main/src/protocol/index.ts"
click node_operations "https://github.com/1129aliasgar/openbrowser/blob/main/src/operations/index.ts"
click node_memory "https://github.com/1129aliasgar/openbrowser/blob/main/src/memory/index.ts"
click node_promptfile "https://github.com/1129aliasgar/openbrowser/blob/main/src/memory/index.ts"

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_cli,node_context,node_prompts,node_client,node_terminal,node_ai toneBlue
class node_server,node_sessions,node_sse toneAmber
class node_parser,node_validation,node_operations toneMint
class node_extension,node_content,node_providers,node_chatgpt,node_gemini,node_deepseek toneRose
class node_filesystem,node_memory,node_promptfile,node_developer toneIndigo
```

## Components

### CLI workflow

- [CLI modes](https://github.com/1129aliasgar/openbrowser/blob/main/src/index.ts): `src/index.ts`
- [Project context](https://github.com/1129aliasgar/openbrowser/blob/main/src/context/file-context.ts): `src/context/file-context.ts`
- [System prompts](https://github.com/1129aliasgar/openbrowser/blob/main/src/prompts/system.ts): `src/prompts/system.ts`
- [Bridge client](https://github.com/1129aliasgar/openbrowser/blob/main/src/client/bridge-client.ts): `src/client/bridge-client.ts`
- [Terminal output](https://github.com/1129aliasgar/openbrowser/blob/main/src/shared/terminal.ts): `src/shared/terminal.ts`

### Local bridge

- [Bridge API](https://github.com/1129aliasgar/openbrowser/blob/main/src/server/index.ts): `src/server/index.ts`
- [Session store](https://github.com/1129aliasgar/openbrowser/blob/main/src/server/session-store.ts): `src/server/session-store.ts`
- [SSE hub](https://github.com/1129aliasgar/openbrowser/blob/main/src/server/sse-hub.ts): `src/server/sse-hub.ts`

### Agent processing

- [Agent response parser](https://github.com/1129aliasgar/openbrowser/blob/main/src/parser/index.ts): `src/parser/index.ts`
- [Operation validation](https://github.com/1129aliasgar/openbrowser/blob/main/src/protocol/index.ts): `src/protocol/index.ts`
- [Diff and apply](https://github.com/1129aliasgar/openbrowser/blob/main/src/operations/index.ts): `src/operations/index.ts`

### Browser extension

- [Extension background](https://github.com/1129aliasgar/openbrowser/blob/main/browser-extension/src/background.js): `browser-extension/src/background.js`
- [AI page integration](https://github.com/1129aliasgar/openbrowser/blob/main/browser-extension/src/content-script.js): `browser-extension/src/content-script.js`
- [Provider registry](https://github.com/1129aliasgar/openbrowser/blob/main/browser-extension/src/providers.js): `browser-extension/src/providers.js`
- [ChatGPT adapter](https://github.com/1129aliasgar/openbrowser/blob/main/browser-extension/src/chatgpt-api.js): `browser-extension/src/chatgpt-api.js`
- [Gemini adapter](https://github.com/1129aliasgar/openbrowser/blob/main/browser-extension/src/gemini-api.js): `browser-extension/src/gemini-api.js`
- [DeepSeek adapter](https://github.com/1129aliasgar/openbrowser/blob/main/browser-extension/src/deepseek-api.js): `browser-extension/src/deepseek-api.js`

### Workspace state

- **Project files**
- [Project memory](https://github.com/1129aliasgar/openbrowser/blob/main/src/memory/index.ts): `src/memory/index.ts`
- [Large prompt files](https://github.com/1129aliasgar/openbrowser/blob/main/src/memory/index.ts): `src/memory/index.ts`

### Other components

- **Developer**
- **Browser AI service**

## Connections

- Developer → CLI modes: runs modes (evidence: `README.md`)
- CLI modes → Project context: loads context (evidence: `src/index.ts`)
- CLI modes → System prompts: builds prompt (evidence: `src/index.ts`)
- CLI modes → Bridge client: submits prompt (evidence: `src/index.ts`)
- CLI modes → Bridge API: starts bridge (evidence: `src/index.ts`)
- CLI modes → Terminal output: prints results (evidence: `src/index.ts`)
- Bridge client → Bridge API: uses local API (evidence: `README.md`)
- Bridge API → Session store: manages sessions (evidence: `src/server/index.ts`)
- Bridge API → SSE hub: streams events (evidence: `src/server/index.ts`)
- Bridge API → Project context: generates context (evidence: `src/server/index.ts`)
- Bridge API → Diff and apply: executes operations (evidence: `src/server/index.ts`)
- Bridge API → Project memory: stores prompts (evidence: `src/server/index.ts`)
- Bridge API → Large prompt files: writes large prompts (evidence: `src/server/index.ts`)
- Extension background → Bridge API: bridges over local API (evidence: `README.md`)
- Extension background → AI page integration: coordinates page capture
- AI page integration → Browser AI service: injects and captures (evidence: `README.md`)
- Provider registry → ChatGPT adapter: selects adapter
- Provider registry → Gemini adapter: selects adapter
- Provider registry → DeepSeek adapter: selects adapter
- Bridge API → Agent response parser: parses agent response
- Agent response parser → Operation validation: validates operations (evidence: `src/parser/index.ts`)
- Bridge API → Operation validation: validates submissions (evidence: `src/server/index.ts`)
- Diff and apply → Project files: plans and applies diffs (evidence: `src/operations/index.ts`)
- Diff and apply → Project memory: appends history (evidence: `src/operations/index.ts`)
- Project context → Project files: reads project files (evidence: `src/context/file-context.ts`)
- Project memory → Large prompt files: stores prompt text (evidence: `src/memory/index.ts`)
- Bridge client → Session store: waits for response (evidence: `src/client/bridge-client.ts`)
