# ggprompts/tabzchrome architecture

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

- Interactive diagram: https://gitdiagram.com/ggprompts/tabzchrome
- Repository: https://github.com/ggprompts/tabzchrome

## Overview

1. **The runtime is split into three cooperating parts:** a Chrome Extension UI, a local Node.js backend on port 8129, and a local MCP server for Claude Code/browser automation. The key architectural boundary is that **terminal processes live on the host via tmux**, while the browser extension is mostly the presentation and browser-control layer.

2. **Chrome Extension is the main user-facing shell.** It is a Manifest V3 extension with multiple surfaces: the **side panel** for active terminals, a **dashboard** for management pages, a **new tab** launcher, a **popup**, **devtools** panels, and a **content script** for page-level actions. The background service worker is the hub for extension messaging, Chrome API calls, and relaying events.

3. **The side panel is the terminal cockpit.** It renders xterm.js terminals, session tabs, profile selectors, working-directory controls, and status indicators. User actions such as spawn, detach, reattach, kill, paste, and tab switching are sent through the background layer to the backend.

4. **The backend is the system of record for terminal lifecycle coordination.** Under `backend/modules`, the main responsibilities are PTY handling, tmux session management, terminal registry, spawn orchestration, file watching, git helpers, logging, and optional audio generation. The backend exposes REST routes and a WebSocket channel, and also serves the local dashboard assets.

5. **tmux is the durable persistence layer for terminal sessions.** New terminals are spawned through the backend into tmux sessions, and the terminal UI attaches to those sessions over PTY/WebSocket plumbing. This is why sessions survive sidebar closure, browser restarts, and backend restarts; tmux is effectively the source of truth, not browser state.

6. **The terminal data flow is: profile/config → backend spawn → tmux/PTY → websocket stream → xterm.js UI.** Profiles define working directory, startup command, fonts, and theme. The backend uses that config to start or reconnect a session, and terminal output/status is streamed back to the extension and dashboard.

7. **Profiles and working-directory state are shared, but not centralized in one database.** Profile definitions live in extension-side storage/files, while the backend also exposes working-directory settings and session state. The UI synchronizes these settings so profiles can inherit a global project directory and so detached sessions can be rediscovered by the “ghost badge”/orphan-session flow.

8. **Browser automation is handled inside the extension, not by remote debugging.** The `background/browserMcp` modules wrap Chrome extension APIs for tabs, windows, screenshots, downloads, history, bookmarks, cookies, tab groups, scripting, emulation, and interaction. The content script and context menus add page-level affordances like “Send to Tabz,” “Paste to Terminal,” and data-terminal-command buttons.

9. **The dashboard is the operational admin console.** It provides pages for terminals, profiles, files, git, API testing, MCP settings, audio, notifications, and a catalog of backend-served pages. The Files and Git sections depend on backend file and repo data; the Audio and MCP settings pages control runtime features that affect both the extension and backend behavior.

10. **Claude Code integration is a separate automation plane.** The `tabz-mcp-server` package exposes a large toolset for browser control and terminal-related operations, and is launched as a local process configured with `BACKEND_URL`. It is designed so Claude Code can drive Tabz without loading all tool schemas up front, making it a companion process rather than part of the Chrome extension runtime.

11. **Audio and notifications are cross-cutting features.** The backend can generate speech via `edge-tts`, then broadcast playback events to connected clients over WebSocket. The extension also manages desktop/audio notifications and per-event voice/sound settings, so alerts can be triggered by terminal status, Claude activity, downloads, or browser events.

12. **Builds and tests are split by runtime boundary.** The repository contains separate TypeScript/Vite/Vitest setups for the extension, backend, and MCP server. The extension source in `extension/` builds to `dist-extension/`, while the backend and MCP server each have their own package/configuration, reflecting the fact that this is a multi-process local system rather than a single app.

Main entry points: [`extension/background/index.ts`](https://github.com/ggprompts/tabzchrome/blob/main/extension/background/index.ts) (Background hub), [`backend/server.js`](https://github.com/ggprompts/tabzchrome/blob/main/backend/server.js) (Backend server), [`backend/modules/unified-spawn.js`](https://github.com/ggprompts/tabzchrome/blob/main/backend/modules/unified-spawn.js) (Spawn core), [`plugins/tabz/tabz-mcp-server/src/index.ts`](https://github.com/ggprompts/tabzchrome/blob/main/plugins/tabz/tabz-mcp-server/src/index.ts) (MCP server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_grp_extension["Chrome Extension"]
  node_node_extension_background["Background hub<br/>MV3 worker<br/>[index.ts]"]
  node_node_extension_sidepanel["Side panel<br/>terminal cockpit<br/>[sidepanel.tsx]"]
  node_node_extension_dashboard["Dashboard<br/>admin console<br/>[App.tsx]"]
  node_node_extension_newtab["New tab<br/>launcher UI<br/>[NewTab.tsx]"]
  node_node_extension_popup["Popup<br/>quick actions<br/>[popup.tsx]"]
  node_node_extension_devtools["Devtools panel<br/>inspection UI<br/>[panel.tsx]"]
  node_node_extension_content["Content script<br/>page bridge<br/>[content.ts]"]
  node_node_extension_browsermcp["Browser MCP<br/>chrome automation<br/>[index.ts]"]
end

subgraph group_grp_backend["Local Backend"]
  node_node_backend_server["Backend server<br/>node api server<br/>[server.js]"]
  node_node_backend_spawn["Spawn core<br/>terminal lifecycle<br/>[unified-spawn.js]"]
  node_node_backend_tmux[("tmux manager<br/>durable sessions")]
  node_node_backend_pty["PTY handler<br/>terminal io<br/>[pty-handler.js]"]
  node_node_backend_registry["Terminal registry<br/>session state"]
  node_node_backend_routes["API routes<br/>http routes<br/>[api.js]"]
  node_node_backend_files_git["Files & git<br/>repo services<br/>[file-watcher.js]"]
  node_node_backend_audio["Audio engine<br/>tts alerts<br/>[audio-generator.js]"]
end

subgraph group_grp_mcp["MCP Server"]
  node_node_mcp_server["MCP server<br/>companion process<br/>[index.ts]"]
  node_node_mcp_tools["MCP tools<br/>toolset<br/>[terminals.ts]"]
end

subgraph group_grp_docs["Docs & Plans"]
  node_node_docs_plans["Docs & plans<br/>repo guidance<br/>[README.md]"]
end

node_node_extension_sidepanel -->|"terminal actions"| node_node_extension_background
node_node_extension_newtab -->|"launch state"| node_node_extension_background
node_node_extension_popup -->|"commands"| node_node_extension_background
node_node_extension_devtools -->|"inspect events"| node_node_extension_background
node_node_extension_content -->|"page actions"| node_node_extension_browsermcp
node_node_extension_background -->|"ws + http"| node_node_backend_server
node_node_extension_background -->|"chrome apis"| node_node_extension_browsermcp
node_node_backend_server -->|"serves api"| node_node_backend_routes
node_node_backend_server -->|"orchestrates"| node_node_backend_spawn
node_node_backend_spawn -->|"persist sessions"| node_node_backend_tmux
node_node_backend_spawn -->|"pty stream"| node_node_backend_pty
node_node_backend_spawn -->|"register sessions"| node_node_backend_registry
node_node_backend_pty -->|"terminal output"| node_node_extension_sidepanel
node_node_backend_registry -->|"session state"| node_node_extension_dashboard
node_node_backend_routes -->|"file repo ops"| node_node_backend_files_git
node_node_backend_audio -->|"alerts"| node_node_extension_background
node_node_mcp_server -->|"automation plane"| node_node_extension_browsermcp
node_node_mcp_server -->|"backend url"| node_node_backend_server
node_node_mcp_server -->|"loads tools"| node_node_mcp_tools
node_node_docs_plans -.->|"guidance"| node_node_extension_dashboard
node_node_docs_plans -.->|"guidance"| node_node_backend_server
node_node_docs_plans -.->|"guidance"| node_node_mcp_server

click node_node_extension_background "https://github.com/ggprompts/tabzchrome/blob/main/extension/background/index.ts"
click node_node_extension_sidepanel "https://github.com/ggprompts/tabzchrome/blob/main/extension/sidepanel/sidepanel.tsx"
click node_node_extension_dashboard "https://github.com/ggprompts/tabzchrome/blob/main/extension/dashboard/App.tsx"
click node_node_extension_newtab "https://github.com/ggprompts/tabzchrome/blob/main/extension/newtab/NewTab.tsx"
click node_node_extension_popup "https://github.com/ggprompts/tabzchrome/blob/main/extension/popup/popup.tsx"
click node_node_extension_devtools "https://github.com/ggprompts/tabzchrome/blob/main/extension/devtools/panel.tsx"
click node_node_extension_content "https://github.com/ggprompts/tabzchrome/blob/main/extension/content/content.ts"
click node_node_extension_browsermcp "https://github.com/ggprompts/tabzchrome/blob/main/extension/background/browserMcp/index.ts"
click node_node_backend_server "https://github.com/ggprompts/tabzchrome/blob/main/backend/server.js"
click node_node_backend_spawn "https://github.com/ggprompts/tabzchrome/blob/main/backend/modules/unified-spawn.js"
click node_node_backend_tmux "https://github.com/ggprompts/tabzchrome/blob/main/backend/modules/tmux-session-manager.js"
click node_node_backend_pty "https://github.com/ggprompts/tabzchrome/blob/main/backend/modules/pty-handler.js"
click node_node_backend_registry "https://github.com/ggprompts/tabzchrome/blob/main/backend/modules/terminal-registry.js"
click node_node_backend_routes "https://github.com/ggprompts/tabzchrome/blob/main/backend/routes/api.js"
click node_node_backend_files_git "https://github.com/ggprompts/tabzchrome/blob/main/backend/modules/file-watcher.js"
click node_node_backend_audio "https://github.com/ggprompts/tabzchrome/blob/main/backend/modules/audio-generator.js"
click node_node_mcp_server "https://github.com/ggprompts/tabzchrome/blob/main/plugins/tabz/tabz-mcp-server/src/index.ts"
click node_node_mcp_tools "https://github.com/ggprompts/tabzchrome/blob/main/plugins/tabz/tabz-mcp-server/src/tools/terminals.ts"
click node_node_docs_plans "https://github.com/ggprompts/tabzchrome/blob/main/docs/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_node_extension_background,node_node_extension_sidepanel,node_node_extension_dashboard,node_node_extension_newtab,node_node_extension_popup,node_node_extension_devtools,node_node_extension_content,node_node_extension_browsermcp toneBlue
class node_node_backend_server,node_node_backend_spawn,node_node_backend_tmux,node_node_backend_pty,node_node_backend_registry,node_node_backend_routes,node_node_backend_files_git,node_node_backend_audio toneAmber
class node_node_mcp_server,node_node_mcp_tools toneMint
class node_node_docs_plans toneRose
```

## Components

### Chrome Extension

Manifest V3 UI shell and browser-control runtime

- [Background hub](https://github.com/ggprompts/tabzchrome/blob/main/extension/background/index.ts): MV3 worker · Central message router, Chrome API gateway, websocket client, and state coordinator · `extension/background/index.ts`
- [Side panel](https://github.com/ggprompts/tabzchrome/blob/main/extension/sidepanel/sidepanel.tsx): terminal cockpit · Main terminal UI with tabs, profiles, working dir controls, and session actions · `extension/sidepanel/sidepanel.tsx`
- [Dashboard](https://github.com/ggprompts/tabzchrome/blob/main/extension/dashboard/App.tsx): admin console · Operational pages for terminals, files, git, API testing, audio, notifications, profiles, and MCP settings · `extension/dashboard/App.tsx`
- [New tab](https://github.com/ggprompts/tabzchrome/blob/main/extension/newtab/NewTab.tsx): launcher UI · Quick launch surface for profiles, recent dirs, shortcuts, and status · `extension/newtab/NewTab.tsx`
- [Popup](https://github.com/ggprompts/tabzchrome/blob/main/extension/popup/popup.tsx): quick actions · Compact extension entry point for fast access to controls · `extension/popup/popup.tsx`
- [Devtools panel](https://github.com/ggprompts/tabzchrome/blob/main/extension/devtools/panel.tsx): inspection UI · Developer-facing panel surface integrated into Chrome devtools · `extension/devtools/panel.tsx`
- [Content script](https://github.com/ggprompts/tabzchrome/blob/main/extension/content/content.ts): page bridge · Page-level affordances, commands, and context actions injected into web pages · `extension/content/content.ts`
- [Browser MCP](https://github.com/ggprompts/tabzchrome/blob/main/extension/background/browserMcp/index.ts): chrome automation · Extension-side wrappers for tabs, windows, screenshots, downloads, history, bookmarks, cookies, scripting, and interaction · `extension/background/browserMcp/index.ts`

### Local Backend

Node.js terminal orchestration and dashboard server

- [Backend server](https://github.com/ggprompts/tabzchrome/blob/main/backend/server.js): node api server · Local server on port 8129 exposing REST, websocket, and static dashboard assets · `backend/server.js`
- [Spawn core](https://github.com/ggprompts/tabzchrome/blob/main/backend/modules/unified-spawn.js): terminal lifecycle · Unified spawn orchestration over PTY and tmux session creation · `backend/modules/unified-spawn.js`
- [tmux manager](https://github.com/ggprompts/tabzchrome/blob/main/backend/modules/tmux-session-manager.js): durable sessions · Session persistence and attachment layer for terminal state · `backend/modules/tmux-session-manager.js`
- [PTY handler](https://github.com/ggprompts/tabzchrome/blob/main/backend/modules/pty-handler.js): terminal io · Pseudo-terminal plumbing between spawned processes and websocket clients · `backend/modules/pty-handler.js`
- [Terminal registry](https://github.com/ggprompts/tabzchrome/blob/main/backend/modules/terminal-registry.js): session state · Tracks terminals, ghost/orphan recovery, and session metadata · `backend/modules/terminal-registry.js`
- [API routes](https://github.com/ggprompts/tabzchrome/blob/main/backend/routes/api.js): http routes · REST endpoints for api, browser, files, and git operations · `backend/routes/api.js`
- [Files & git](https://github.com/ggprompts/tabzchrome/blob/main/backend/modules/file-watcher.js): repo services · Backend helpers for file watching, filesystem access, and git state/actions · `backend/modules/file-watcher.js`
- [Audio engine](https://github.com/ggprompts/tabzchrome/blob/main/backend/modules/audio-generator.js): tts alerts · Speech generation and sound-event broadcasting for notifications · `backend/modules/audio-generator.js`

### MCP Server

Companion automation server for Claude Code

- [MCP server](https://github.com/ggprompts/tabzchrome/blob/main/plugins/tabz/tabz-mcp-server/src/index.ts): companion process · Local Claude Code automation server configured through BACKEND_URL · `plugins/tabz/tabz-mcp-server/src/index.ts`
- [MCP tools](https://github.com/ggprompts/tabzchrome/blob/main/plugins/tabz/tabz-mcp-server/src/tools/terminals.ts): toolset · Tool modules for browser control, terminals, screenshots, downloads, page actions, and notifications · `plugins/tabz/tabz-mcp-server/src/tools/terminals.ts`

### Docs & Plans

Repository guidance, audits, and operational notes

- [Docs & plans](https://github.com/ggprompts/tabzchrome/blob/main/docs/README.md): repo guidance · Architecture notes, audits, plans, and usage guides that document the multi-process system · `docs/README.md`

## Connections

- Side panel → Background hub: terminal actions · Spawn, attach, detach, kill, paste, and tab changes are routed through the background hub
- New tab → Background hub: launch state · New tab launcher reads shared profile and working-directory state via extension messaging
- Popup → Background hub: commands · Popup actions are relayed to the hub for execution and state updates
- Devtools panel → Background hub: inspect events · Devtools surfaces exchange messages through the background service worker
- Content script → Browser MCP: page actions · Injected page affordances trigger browser automation and context-menu workflows
- Background hub → Backend server: ws + http · Extension connects to the local backend for terminal state, dashboard data, and event streams
- Background hub → Browser MCP: chrome apis · Background layer centralizes browser automation wrappers for extension-controlled features
- Backend server → API routes: serves api · HTTP entrypoint dispatches REST endpoints and static assets
- Backend server → Spawn core: orchestrates · Server delegates terminal lifecycle requests into unified spawn logic
- Spawn core → tmux manager: persist sessions · New terminals are launched into tmux sessions for durability across restarts
- Spawn core → PTY handler: pty stream · Spawned processes connect through PTY plumbing for interactive terminal I/O
- Spawn core → Terminal registry: register sessions · Spawn orchestration records session metadata and recovery state
- PTY handler → Side panel: terminal output · Terminal bytes and status updates flow back to the xterm-based UI over websocket
- Terminal registry → Dashboard: session state · Dashboard surfaces active terminals, orphan sessions, and ghost badge recovery
- API routes → Files & git: file repo ops · Files and git pages consume backend-side filesystem and repository helpers
- Audio engine → Background hub: alerts · Audio and voice events are broadcast to connected clients for notifications
- MCP server → Browser MCP: automation plane · Claude-facing tools drive the same browser-control capabilities exposed by the extension
- MCP server → Backend server: backend url · Companion process is configured to talk to the local backend service
- MCP server → MCP tools: loads tools · Server composes its large toolset from modular domain-specific tool implementations
- Docs & plans → Dashboard: guidance · Documentation describes dashboard sections, settings, and operational workflows
- Docs & plans → Backend server: guidance · Docs capture backend API, terminal lifecycle, and deployment behavior
- Docs & plans → MCP server: guidance · Docs explain Claude Code integration and MCP tool usage
