How chathub-dev/chathub works
Purpose and delivery model
ChatHub is a Chromium browser extension that provides one chat workspace for multiple AI providers, including concurrent answer comparison, local history, prompts, exports, web access, and premium features. Extension packaging is defined by manifest.config.ts; Vite application entry HTML files are app.html and sidepanel.html.
Extension entry points and execution contexts
The primary React UI starts at src/app/main.tsx, routing through src/app/router.tsx into single- and multi-bot chat, settings, and premium pages. A dedicated browser side-panel runtime starts at src/app/sidepanel.tsx and renders src/app/pages/SidePanelPage.tsx. Background extension logic resides in src/background/index.ts; page-context bridging for ChatGPT is in src/content-script/chatgpt-inpage-proxy.ts.
Chat orchestration and UI
src/app/pages/SingleBotChatPanel.tsx and src/app/pages/MultiBotChatPanel.tsx are the primary interaction surfaces. src/app/hooks/use-chat.ts coordinates user messages, selected bots, streamed responses, and UI state, while src/app/components/Chat/ConversationPanel.tsx and src/app/components/Chat/ChatMessageList.tsx render conversations. This separates provider execution from presentation and enables a single prompt to fan out to several adapters.
Provider adapter boundary
src/app/bots/abstract-bot.ts defines the common bot abstraction, and src/app/bots/index.ts aggregates supported implementations. Provider-specific adapters encapsulate authentication and protocol differences, e.g. src/app/bots/chatgpt-api/index.ts, src/app/bots/bing/index.ts, and src/app/bots/poe/index.ts. Integrations span direct APIs, provider web apps, GraphQL (Poe), Azure/OpenRouter-compatible endpoints, and open-model/Gradio services.
Services, persistence, and streaming
Application services own durable and remote-facing concerns: src/services/chat-history.ts handles local conversation persistence, src/services/user-config.ts handles user/provider configuration, and src/services/proxy-fetch.ts centralizes proxied network requests. Streaming transport utilities in src/utils/sse.ts and src/utils/stream-async-iterable.ts convert provider output into incrementally rendered responses. User data remains primarily extension-local, with import/export support surfaced by src/app/utils/export.ts.
Agent and web-search pipeline
Optional web-enabled assistance is organized under src/services/agent/index.ts, with prompt construction in src/services/agent/prompts.ts. Search providers implement a shared boundary under src/services/agent/web-search/base.ts; current backends include DuckDuckGo and Bing News at src/services/agent/web-search/duckduckgo.ts and src/services/agent/web-search/bing-news.ts. Site-specific rules in src/rules/bing.json and peers support browser-based/provider interactions.
Monetization, telemetry, and platform dependencies
Premium entitlement and purchase flow are separated from chat via src/services/premium.ts, src/services/lemonsqueezy.ts, and premium UI under src/app/pages/PremiumPage.tsx. External operational services include Lemon Squeezy payments, Sentry error reporting (src/services/sentry.ts), and Plausible analytics (src/app/plausible.ts). Chrome extension APIs provide runtime messaging, storage, permissions, shortcuts, and side-panel capability.
Localization and presentation state
Chrome extension locale bundles are under _locales/en/messages.json; in-app localization is initialized in src/app/i18n/index.ts. Shared application state is centralized in src/app/state/index.ts, while theme persistence and application are split between src/services/theme.ts and src/app/theme.ts. This supports consistent settings across the main app and side-panel runtimes.
Main entry points: use-chat.ts Chat orchestration · manifest.config.ts Extension packaging · router.tsx App routes · index.ts Bot registry
Components 24
Extension runtimes
- Extension packaging · Declares extension entry points and capabilities.
manifest.config.ts - Background runtime
src/background/index.ts - ChatGPT page bridge
src/content-script/chatgpt-inpage-proxy.ts
React workspace
- Main app runtime
src/app/main.tsx - App routes
src/app/router.tsx - Side panel runtime
src/app/sidepanel.tsx - Side panel page
src/app/pages/SidePanelPage.tsx - Single and multi-bot chat · Primary prompt and concurrent-comparison surfaces.
src/app/pages/MultiBotChatPanel.tsx - Chat orchestration · Coordinates selected bots, messages, streaming, and UI state.
src/app/hooks/use-chat.ts - Conversation renderer
src/app/components/Chat/ConversationPanel.tsx - Shared app state
src/app/state/index.ts
Provider execution
- Bot abstraction
src/app/bots/abstract-bot.ts - Bot registry
src/app/bots/index.ts - Provider adapters · ChatGPT, Bing, Poe, and other provider protocol integrations.
src/app/bots/chatgpt-api/index.ts
Services and agent
- Streaming transport · Turns provider streams into incrementally consumable responses.
src/utils/sse.ts - Chat history
src/services/chat-history.ts - User configuration · Stores user and provider settings.
src/services/user-config.ts - Web-enabled agent · Builds assisted prompts and invokes web search.
src/services/agent/index.ts - Web search backends · Shared search boundary with DuckDuckGo and Bing News implementations.
src/services/agent/web-search/base.ts - Premium service
src/services/premium.ts
External platform
- Chrome extension APIs · Messaging, storage, permissions, shortcuts, and side-panel APIs.
- AI providers
- Search services
- Lemon Squeezy
Connections 25
- Extension packaging → Background runtime: packages
- Extension packaging → Main app runtime: packages
- Extension packaging → Side panel runtime: packages
- Background runtime → Chrome extension APIs: uses
- ChatGPT page bridge → Chrome extension APIs: bridges through
- Main app runtime → App routes: routes through
- App routes → Single and multi-bot chat: renders
- Side panel runtime → Side panel page: renders
- Single and multi-bot chat → Chat orchestration: drives
- Chat orchestration → Conversation renderer: updates
- Chat orchestration → Shared app state: uses
- Chat orchestration → Bot registry: selects bots
- Bot registry → Bot abstraction: implements
- Bot registry → Provider adapters: loads
- Provider adapters → Streaming transport: streams via
- Provider adapters → AI providers: calls
- Chat orchestration → Chat history: persists conversations
- Shared app state → User configuration: reads settings
- Chat orchestration → Web-enabled agent: optionally invokes
- Web-enabled agent → Web search backends: queries through
- Web search backends → Search services: searches
- App routes → Premium service: opens premium flow
- Premium service → Lemon Squeezy: manages purchase
- Chat history → Chrome extension APIs: stores in
- User configuration → Chrome extension APIs: stores in