# gloom-sh/gloomberb architecture

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

- Interactive diagram: https://gitdiagram.com/gloom-sh/gloomberb
- Repository: https://github.com/gloom-sh/gloomberb

## Overview

#### Purpose and Entry Points
Gloomberb is an open-source, keyboard-driven finance terminal delivered as both a terminal UI and a macOS/Windows desktop application. The primary application roots are `src/index.tsx` and `src/app.tsx`; terminal launch uses `src/renderers/opentui/start.tsx`, while desktop view startup uses `src/renderers/electrobun/view/main.tsx`. The executable/CLI dispatch layer is `src/cli/entry.ts`, with `bin/gloomberb` as the installed command.

#### Shared Application Bootstrap and State
Startup assembles app services, restored session/configuration, plugins, and renderer-specific hosts before rendering the workspace. `src/core/app-services.ts` defines shared service composition and ports; `src/state/app/bootstrap.ts` coordinates application state initialization; `src/app/runtime/startup.ts` handles runtime startup concerns. Persistent layout and session state are boundaries between runtime state and local storage, notably `src/data/config/store/index.ts`, `src/data/session-store.ts`, and `src/core/state/session-persistence.ts`.

#### Renderer and Platform Boundary
Core React UI is renderer-agnostic through shared UI hosts and capabilities. The TUI renderer uses OpenTUI (`src/renderers/opentui/host.tsx`, `src/renderers/opentui/ui-host.tsx`), including terminal-native image/chart surfaces. Desktop runs under Electrobun with separate Bun/backend and webview/view processes: `src/renderers/electrobun/bun/index.ts`, `src/renderers/electrobun/view/app-services.ts`, and `src/renderers/electrobun/shared/protocol.ts`. RPC bridges isolate desktop-native operations such as windows, media, HTTP, updates, and persistence from UI code.

#### Workspace, Panes, and Command Interaction
The workspace is a managed pane layout rather than a conventional page-based app. `src/plugins/pane-manager.ts` and `src/plugins/pane-manager/dock-tree.ts` own docking, floating, focus, and layout mutations; `src/components/layout/shell/index.tsx` renders the interactive shell. Plugin panes are mounted through `src/app/pane-runtime/index.tsx`. The command bar is a central routing/control plane: `src/components/command-bar/panel/index.tsx`, `src/components/command-bar/routing/actions.ts`, and `src/components/command-bar/workflow/coordinator.ts` translate keyboard-driven commands into pane launches, mutations, and multistep workflows.

#### Plugin and Capability Architecture
Features—including portfolio, research, broker connections, and cloud functions—are plugins registered into shared extension slots. Plugin discovery/loading and UI/backend catalogs are centered in `src/plugins/loader.ts`, `src/plugins/catalog.ts`, and `src/plugins/registry/index.ts`. Plugins contribute panes, tabs, commands, widgets, and providers through runtime context (`src/plugins/runtime/index.tsx`). A capability registry provides an invocation boundary used by plugins, desktop bridges, and the headless CLI: `src/capabilities/registry.ts` and `src/capabilities/service-capabilities.ts`.

#### Market Data, Providers, and Time Series
Feature panes request normalized market models through a provider-routing layer rather than calling vendors directly. `src/sources/provider-router/index.ts` selects providers and routes quotes, history, financials, search, streaming, news, and documents; concrete sources include `src/sources/yahoo-finance.ts`, `src/sources/sec-edgar.ts`, and `src/sources/gloomberb-cloud/index.ts`. `src/market-data/coordinator/index.ts` deduplicates and coordinates quote/chart/financial subscriptions, while `src/time-series/resolve.ts` and `src/time-series/transforms.ts` align, transform, and prepare mixed-frequency series for charts.

#### External Services, Storage, and Operations
The project runs on Bun/TypeScript and React, uses OpenTUI for terminals, and Electrobun for desktop packaging (`electrobun.config.ts`). SQLite-backed caching is implemented in `src/data/sqlite/database.ts`; local repositories/config stores retain tickers, layouts, plugins, notes, and session data. External integrations include Yahoo Finance, SEC EDGAR, FRED-derived economic data, Gloom Cloud authentication/chat/data, Interactive Brokers Gateway (`src/plugins/ibkr/gateway/service/index.ts`), and Polymarket/Kalshi adapters (`src/plugins/prediction-markets/services`). Desktop update checks use GitHub Releases through `src/updater/github-releases.ts`.

Main entry points: [`src/app/runtime/startup.ts`](https://github.com/gloom-sh/gloomberb/blob/main/src/app/runtime/startup.ts) (Runtime startup), [`src/plugins/runtime/index.tsx`](https://github.com/gloom-sh/gloomberb/blob/main/src/plugins/runtime/index.tsx) (Plugin runtime), [`src/renderers/opentui/start.tsx`](https://github.com/gloom-sh/gloomberb/blob/main/src/renderers/opentui/start.tsx) (Terminal startup), [`src/market-data/coordinator/index.ts`](https://github.com/gloom-sh/gloomberb/blob/main/src/market-data/coordinator/index.ts) (Market data coordinator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry points"]
  node_cli["CLI dispatch<br/>[entry.ts]"]
  node_terminal_start["Terminal startup<br/>OpenTUI entry<br/>[start.tsx]"]
  node_desktop_view_start["Desktop view startup<br/>Electrobun view entry<br/>[main.tsx]"]
end

subgraph group_core["Shared application"]
  node_app_root["Application root<br/>React app<br/>[app.tsx]"]
  node_startup["Runtime startup<br/>startup orchestration<br/>[startup.ts]"]
  node_app_services["Service composition<br/>service ports<br/>[app-services.ts]"]
  node_state_bootstrap["State bootstrap<br/>state initialization<br/>[bootstrap.ts]"]
  node_session_persistence[("Session persistence<br/>persistence boundary")]
end

subgraph group_ui["Workspace and interaction"]
  node_workspace_shell["Workspace shell<br/>interactive layout UI<br/>[index.tsx]"]
  node_pane_manager["Pane manager<br/>dock layout engine<br/>[pane-manager.ts]"]
  node_pane_runtime["Pane runtime<br/>plugin pane host<br/>[index.tsx]"]
  node_command_workflow["Command workflows<br/>keyboard command router<br/>[coordinator.ts]"]
end

subgraph group_platforms["Renderer platforms"]
  node_opentui_host["OpenTUI host<br/>terminal UI host<br/>[host.tsx]"]
  node_desktop_backend["Desktop backend<br/>Electrobun Bun process<br/>[index.ts]"]
  node_desktop_protocol["Desktop RPC protocol<br/>native bridge contract<br/>[protocol.ts]"]
end

subgraph group_extensions["Plugins and capabilities"]
  node_plugin_loader["Plugin loader<br/>extension discovery<br/>[loader.ts]"]
  node_plugin_runtime["Plugin runtime<br/>extension context<br/>[index.tsx]"]
  node_capability_registry["Capability registry<br/>invocation boundary<br/>[registry.ts]"]
end

subgraph group_data["Market data and storage"]
  node_provider_router["Provider router<br/>market source routing<br/>[index.ts]"]
  node_market_coordinator["Market data coordinator<br/>subscription coordinator<br/>[index.ts]"]
  node_time_series["Time-series resolver<br/>series transformation<br/>[resolve.ts]"]
  node_sqlite[("SQLite cache<br/>local database<br/>[database.ts]")]
end

node_cli -->|"launches"| node_terminal_start
node_terminal_start -->|"starts"| node_startup
node_desktop_view_start -->|"starts"| node_startup
node_startup -->|"composes"| node_app_services
node_startup -->|"initializes"| node_state_bootstrap
node_state_bootstrap -->|"restores and saves"| node_session_persistence
node_startup -->|"renders"| node_app_root
node_app_root -->|"hosts"| node_workspace_shell
node_workspace_shell -->|"uses layout"| node_pane_manager
node_pane_manager -->|"mounts panes"| node_pane_runtime
node_command_workflow -->|"mutates layout"| node_pane_manager
node_plugin_loader -->|"loads extensions into"| node_plugin_runtime
node_plugin_runtime -->|"contributes panes"| node_pane_runtime
node_plugin_runtime -->|"invokes"| node_capability_registry
node_terminal_start -->|"uses"| node_opentui_host
node_desktop_view_start -->|"uses RPC"| node_desktop_protocol
node_desktop_protocol -->|"bridges to"| node_desktop_backend
node_capability_registry -.->|"calls native capabilities"| node_desktop_protocol
node_plugin_runtime -->|"requests market models"| node_provider_router
node_provider_router -->|"routes subscriptions"| node_market_coordinator
node_market_coordinator -->|"prepares chart series"| node_time_series
node_market_coordinator -->|"caches data"| node_sqlite
node_session_persistence -->|"uses local storage"| node_sqlite

click node_cli "https://github.com/gloom-sh/gloomberb/blob/main/src/cli/entry.ts"
click node_terminal_start "https://github.com/gloom-sh/gloomberb/blob/main/src/renderers/opentui/start.tsx"
click node_desktop_view_start "https://github.com/gloom-sh/gloomberb/blob/main/src/renderers/electrobun/view/main.tsx"
click node_app_root "https://github.com/gloom-sh/gloomberb/blob/main/src/app.tsx"
click node_startup "https://github.com/gloom-sh/gloomberb/blob/main/src/app/runtime/startup.ts"
click node_app_services "https://github.com/gloom-sh/gloomberb/blob/main/src/core/app-services.ts"
click node_state_bootstrap "https://github.com/gloom-sh/gloomberb/blob/main/src/state/app/bootstrap.ts"
click node_session_persistence "https://github.com/gloom-sh/gloomberb/blob/main/src/core/state/session-persistence.ts"
click node_workspace_shell "https://github.com/gloom-sh/gloomberb/blob/main/src/components/layout/shell/index.tsx"
click node_pane_manager "https://github.com/gloom-sh/gloomberb/blob/main/src/plugins/pane-manager.ts"
click node_pane_runtime "https://github.com/gloom-sh/gloomberb/blob/main/src/app/pane-runtime/index.tsx"
click node_command_workflow "https://github.com/gloom-sh/gloomberb/blob/main/src/components/command-bar/workflow/coordinator.ts"
click node_opentui_host "https://github.com/gloom-sh/gloomberb/blob/main/src/renderers/opentui/host.tsx"
click node_desktop_backend "https://github.com/gloom-sh/gloomberb/blob/main/src/renderers/electrobun/bun/index.ts"
click node_desktop_protocol "https://github.com/gloom-sh/gloomberb/blob/main/src/renderers/electrobun/shared/protocol.ts"
click node_plugin_loader "https://github.com/gloom-sh/gloomberb/blob/main/src/plugins/loader.ts"
click node_plugin_runtime "https://github.com/gloom-sh/gloomberb/blob/main/src/plugins/runtime/index.tsx"
click node_capability_registry "https://github.com/gloom-sh/gloomberb/blob/main/src/capabilities/registry.ts"
click node_provider_router "https://github.com/gloom-sh/gloomberb/blob/main/src/sources/provider-router/index.ts"
click node_market_coordinator "https://github.com/gloom-sh/gloomberb/blob/main/src/market-data/coordinator/index.ts"
click node_time_series "https://github.com/gloom-sh/gloomberb/blob/main/src/time-series/resolve.ts"
click node_sqlite "https://github.com/gloom-sh/gloomberb/blob/main/src/data/sqlite/database.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_terminal_start,node_desktop_view_start toneBlue
class node_app_root,node_startup,node_app_services,node_state_bootstrap,node_session_persistence toneAmber
class node_workspace_shell,node_pane_manager,node_pane_runtime,node_command_workflow toneMint
class node_opentui_host,node_desktop_backend,node_desktop_protocol toneRose
class node_plugin_loader,node_plugin_runtime,node_capability_registry toneIndigo
class node_provider_router,node_market_coordinator,node_time_series,node_sqlite toneTeal
```

## Components

### Entry points

- [CLI dispatch](https://github.com/gloom-sh/gloomberb/blob/main/src/cli/entry.ts): CLI · `src/cli/entry.ts`
- [Terminal startup](https://github.com/gloom-sh/gloomberb/blob/main/src/renderers/opentui/start.tsx): OpenTUI entry · `src/renderers/opentui/start.tsx`
- [Desktop view startup](https://github.com/gloom-sh/gloomberb/blob/main/src/renderers/electrobun/view/main.tsx): Electrobun view entry · `src/renderers/electrobun/view/main.tsx`

### Shared application

- [Application root](https://github.com/gloom-sh/gloomberb/blob/main/src/app.tsx): React app · `src/app.tsx`
- [Runtime startup](https://github.com/gloom-sh/gloomberb/blob/main/src/app/runtime/startup.ts): startup orchestration · `src/app/runtime/startup.ts`
- [Service composition](https://github.com/gloom-sh/gloomberb/blob/main/src/core/app-services.ts): service ports · Composes shared services and renderer-facing ports. · `src/core/app-services.ts`
- [State bootstrap](https://github.com/gloom-sh/gloomberb/blob/main/src/state/app/bootstrap.ts): state initialization · `src/state/app/bootstrap.ts`
- [Session persistence](https://github.com/gloom-sh/gloomberb/blob/main/src/core/state/session-persistence.ts): persistence boundary · `src/core/state/session-persistence.ts`

### Workspace and interaction

- [Workspace shell](https://github.com/gloom-sh/gloomberb/blob/main/src/components/layout/shell/index.tsx): interactive layout UI · `src/components/layout/shell/index.tsx`
- [Pane manager](https://github.com/gloom-sh/gloomberb/blob/main/src/plugins/pane-manager.ts): dock layout engine · Owns docking, floating panes, focus, and layout mutations. · `src/plugins/pane-manager.ts`
- [Pane runtime](https://github.com/gloom-sh/gloomberb/blob/main/src/app/pane-runtime/index.tsx): plugin pane host · `src/app/pane-runtime/index.tsx`
- [Command workflows](https://github.com/gloom-sh/gloomberb/blob/main/src/components/command-bar/workflow/coordinator.ts): keyboard command router · Routes commands into pane actions and multistep workflows. · `src/components/command-bar/workflow/coordinator.ts`

### Renderer platforms

- [OpenTUI host](https://github.com/gloom-sh/gloomberb/blob/main/src/renderers/opentui/host.tsx): terminal UI host · `src/renderers/opentui/host.tsx`
- [Desktop backend](https://github.com/gloom-sh/gloomberb/blob/main/src/renderers/electrobun/bun/index.ts): Electrobun Bun process · `src/renderers/electrobun/bun/index.ts`
- [Desktop RPC protocol](https://github.com/gloom-sh/gloomberb/blob/main/src/renderers/electrobun/shared/protocol.ts): native bridge contract · Isolates native windows, media, HTTP, updates, and persistence. · `src/renderers/electrobun/shared/protocol.ts`

### Plugins and capabilities

- [Plugin loader](https://github.com/gloom-sh/gloomberb/blob/main/src/plugins/loader.ts): extension discovery · `src/plugins/loader.ts`
- [Plugin runtime](https://github.com/gloom-sh/gloomberb/blob/main/src/plugins/runtime/index.tsx): extension context · Mounts plugin panes and exposes extension slots. · `src/plugins/runtime/index.tsx`
- [Capability registry](https://github.com/gloom-sh/gloomberb/blob/main/src/capabilities/registry.ts): invocation boundary · Shared capability boundary for plugins, desktop bridges, and CLI. · `src/capabilities/registry.ts`

### Market data and storage

- [Provider router](https://github.com/gloom-sh/gloomberb/blob/main/src/sources/provider-router/index.ts): market source routing · Selects sources for quotes, history, search, streaming, news, and documents. · `src/sources/provider-router/index.ts`
- [Market data coordinator](https://github.com/gloom-sh/gloomberb/blob/main/src/market-data/coordinator/index.ts): subscription coordinator · Deduplicates quote, chart, and financial-data subscriptions. · `src/market-data/coordinator/index.ts`
- [Time-series resolver](https://github.com/gloom-sh/gloomberb/blob/main/src/time-series/resolve.ts): series transformation · Aligns and transforms mixed-frequency series for charts. · `src/time-series/resolve.ts`
- [SQLite cache](https://github.com/gloom-sh/gloomberb/blob/main/src/data/sqlite/database.ts): local database · `src/data/sqlite/database.ts`

## Connections

- CLI dispatch → Terminal startup: launches
- Terminal startup → Runtime startup: starts
- Desktop view startup → Runtime startup: starts
- Runtime startup → Service composition: composes
- Runtime startup → State bootstrap: initializes
- State bootstrap → Session persistence: restores and saves
- Runtime startup → Application root: renders
- Application root → Workspace shell: hosts
- Workspace shell → Pane manager: uses layout
- Pane manager → Pane runtime: mounts panes
- Command workflows → Pane manager: mutates layout
- Plugin loader → Plugin runtime: loads extensions into
- Plugin runtime → Pane runtime: contributes panes
- Plugin runtime → Capability registry: invokes
- Terminal startup → OpenTUI host: uses
- Desktop view startup → Desktop RPC protocol: uses RPC
- Desktop RPC protocol → Desktop backend: bridges to
- Capability registry → Desktop RPC protocol: calls native capabilities
- Plugin runtime → Provider router: requests market models
- Provider router → Market data coordinator: routes subscriptions
- Market data coordinator → Time-series resolver: prepares chart series
- Market data coordinator → SQLite cache: caches data
- Session persistence → SQLite cache: uses local storage
