How gloom-sh/gloomberb works
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: startup.ts Runtime startup · index.tsx Plugin runtime · start.tsx Terminal startup · index.ts Market data coordinator
Components 22
Entry points
- CLI dispatch
src/cli/entry.ts - Terminal startup
src/renderers/opentui/start.tsx - Desktop view startup
src/renderers/electrobun/view/main.tsx
Shared application
- Application root
src/app.tsx - Runtime startup
src/app/runtime/startup.ts - Service composition · Composes shared services and renderer-facing ports.
src/core/app-services.ts - State bootstrap
src/state/app/bootstrap.ts - Session persistence
src/core/state/session-persistence.ts
Workspace and interaction
- Workspace shell
src/components/layout/shell/index.tsx - Pane manager · Owns docking, floating panes, focus, and layout mutations.
src/plugins/pane-manager.ts - Pane runtime
src/app/pane-runtime/index.tsx - Command workflows · Routes commands into pane actions and multistep workflows.
src/components/command-bar/workflow/coordinator.ts
Renderer platforms
- OpenTUI host
src/renderers/opentui/host.tsx - Desktop backend
src/renderers/electrobun/bun/index.ts - Desktop RPC protocol · Isolates native windows, media, HTTP, updates, and persistence.
src/renderers/electrobun/shared/protocol.ts
Plugins and capabilities
- Plugin loader
src/plugins/loader.ts - Plugin runtime · Mounts plugin panes and exposes extension slots.
src/plugins/runtime/index.tsx - Capability registry · Shared capability boundary for plugins, desktop bridges, and CLI.
src/capabilities/registry.ts
Market data and storage
- Provider router · Selects sources for quotes, history, search, streaming, news, and documents.
src/sources/provider-router/index.ts - Market data coordinator · Deduplicates quote, chart, and financial-data subscriptions.
src/market-data/coordinator/index.ts - Time-series resolver · Aligns and transforms mixed-frequency series for charts.
src/time-series/resolve.ts - SQLite cache
src/data/sqlite/database.ts
Connections 23
- 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