How smol-ai/godmode works
1. Overall shape
- This is an Electron desktop app: a native shell with a React-based renderer, packaged for macOS/Windows/Linux.
- The app’s core product idea is a secondary chat browser: it does not call LLM APIs directly for most providers; it embeds the providers’ full web apps in webviews.
2. Main process boundary
- src/main/* is the Electron main process.
- It owns app lifecycle, window creation, native menu, global shortcut behavior, and any IPC-facing desktop concerns.
- main.ts, menu.ts, preload.ts, and util.ts are the key bridge points between the OS and the UI.
3. Renderer/UI boundary
- src/renderer/* is the primary user interface built with React.
- This side contains the visible chrome: title bar, layout, sidebars, settings UI, prompt critic UI, and the browser-pane container.
- The renderer is where user actions like typing prompts, resizing panes, reordering panes, and toggling modes happen.
4. Webview/pane model
- The central interaction model is multiple browser panes shown side by side.
- Each pane is effectively an embedded provider web app, allowing independent navigation after the shared prompt is sent.
- browserPane.tsx, components/pane.tsx, and components/sidebar.tsx suggest the layout is pane-driven rather than a single chat transcript.
5. Provider layer
- src/providers/* is the provider abstraction layer.
- Each file represents a specific chat service or model host: ChatGPT/OpenAI, Claude, Bing, Bard, Perplexity, Poe, HuggingChat, Vercel, OpenRouter, local Oobabooga, etc.
- This is the main domain boundary: each provider encapsulates provider-specific URLs, page behavior, and any special handling required to make the web app usable inside the shell.
6. Prompt distribution flow
- The user enters a prompt in the renderer.
- That prompt is then propagated to the selected/enabled provider panes, which submit it into each embedded web app.
- The app’s distinguishing feature is that the same input can be sent to multiple providers simultaneously, while still allowing each pane to diverge afterward.
7. State and settings
- Settings are split out into src/settings/*, implying a distinct settings experience or window.
- The app persists user preferences such as enabled providers, hotkeys, startup behavior, theme, and pane arrangement.
- src/lib/constants.ts, types.ts, and utils.ts provide shared configuration and type definitions used across main and renderer code.
8. PromptCritic feature
- src/renderer/promptCritic.tsx is a specialized feature for improving prompts.
- Architecturally, this is a side feature layered into the renderer, not a separate service.
- It likely interacts with one of the provider panes or a model-backed workflow, but it remains UI-driven inside the Electron app.
9. Desktop integration
- The README and file layout indicate native desktop behaviors are important: global shortcut open/dismiss, always-on-top pinning, zoom controls, and start-on-login.
- Those behaviors are typically owned by the main process and surfaced to the renderer via IPC/preload.
- The preload boundary (src/main/preload.ts) is important because it safely exposes desktop capabilities to the browser-like UI.
10. Build and packaging pipeline
- The project uses an Electron/Webpack toolchain under scripts/configs/* and scripts/scripts/*.
- There are separate build targets for main, preload, and renderer, which matches the app’s process separation.
- release/app/* indicates packaging/release logic is isolated from source, supporting distributable binaries rather than a pure dev server model.
11. Assets and platform-specific resources
- assets/* and src/images/* hold app icons, entitlements, and platform packaging resources.
- These matter because the app is distributed as native installers/binaries, especially for macOS signing/notarization and cross-platform builds.
12. Tests and quality gates
- There is at least a renderer test (src/__tests__/App.test.tsx) and GitHub Actions formatting workflow.
- This suggests the highest-risk logic is in the UI and process coordination rather than in a large backend.
13. Key architectural takeaway
- The repo is best diagrammed as: Electron shell + React renderer + provider-specific webview adapters.
- The main process handles OS integration, the renderer handles the multi-pane chat UI, and the provider modules define how each external AI web app is embedded and controlled.
Main entry points: provider.js Provider base · main.ts Main process · layout.tsx Layout · webpack.config.base.ts Webpack configs
Components 23
Electron main
OS integration, app lifecycle, and IPC bridge.
- Main process · Owns lifecycle, windows, menu, shortcuts, and desktop integration.
src/main/main.ts - Menu · Builds native application menus and related actions.
src/main/menu.ts - Preload bridge · Safely exposes desktop capabilities to the renderer.
src/main/preload.ts - Main utils · Shared main-process helpers used across OS-facing code.
src/main/util.ts - Apify hooks · Auxiliary integration used by the main process.
src/main/apify.ts
Renderer UI
React interface for the multi-pane browser workflow.
- App shell · Top-level renderer entry and application composition.
src/renderer/App.tsx - Layout · Coordinates the overall pane/sidebar arrangement.
src/renderer/layout.tsx - Title bar · Native-feeling window chrome and top controls.
src/renderer/TitleBar.tsx - Browser panes · Hosts the embedded provider panes and shared prompt distribution.
src/renderer/browserPane.tsx - Pane component · Individual pane container and its local interactions.
src/components/pane.tsx - Sidebar · Provider selection, pane controls, and app navigation.
src/components/sidebar.tsx - Settings UI · Settings experience for hotkeys, startup, theme, and providers.
src/settings/settings.tsx - PromptCritic · Renderer-side prompt improvement feature layered into the app.
src/renderer/promptCritic.tsx
Provider adapters
Provider-specific web app control and embed behavior.
- Provider base · Common provider abstraction shared by the service-specific adapters.
src/providers/provider.js - OpenAI · Provider-specific control for ChatGPT/OpenAI web flows.
src/providers/openai.js - Claude · Provider-specific control for Claude web flows.
src/providers/claude.js - Bard · Provider-specific control for Google Bard flows.
src/providers/bard.js - Bing · Provider-specific control for Bing chat flows.
src/providers/bing.js - Other providers · Remaining provider integrations such as Perplexity, Poe, HuggingChat, OpenRouter, Vercel, and local models.
Build & release
Webpack, scripts, packaging, and release tooling.
- Build scripts · Repo scripts for environment checks, packaging, rebuilds, and release prep.
scripts/scripts/check-node-env.js - Webpack configs · Separate build pipelines for main, preload, and renderer targets.
scripts/configs/webpack.config.base.ts - Release app · Isolated release packaging configuration and metadata.
release/app/package.json - Assets · App icons, entitlements, and platform packaging resources.
assets/icon.icns
Connections 24
- Main process → Menu: uses · Main process builds and reacts to native menu actions.
- Main process → Preload bridge: injects · Main process loads the preload bridge into renderer windows.
- Main process → Main utils: shares helpers · Main lifecycle and window logic use common desktop helpers.
- Main process → Apify hooks: integrates · Main process includes auxiliary external integration.
- Preload bridge → App shell: exposes IPC · Preload exposes desktop capabilities to the React UI.
- App shell → Layout: composes · App shell assembles the main layout.
- Layout → Title bar: includes · Layout places the window chrome.
- Layout → Sidebar: includes · Layout places navigation and pane controls.
- Layout → Browser panes: hosts · Layout centers the multi-pane browser surface.
- Browser panes → Pane component: renders · Browser surface is made of individual panes.
- Sidebar → Settings UI: opens · Sidebar provides access to preferences and configuration.
- App shell → PromptCritic: includes · PromptCritic is part of the renderer feature set.
- Browser panes → Provider base: adapts · Pane orchestration is driven by provider abstraction.
- Provider base → OpenAI: specializes · OpenAI is one of the provider-specific adapters.
- Provider base → Claude: specializes · Claude is one of the provider-specific adapters.
- Provider base → Bard: specializes · Bard is one of the provider-specific adapters.
- Provider base → Bing: specializes · Bing is one of the provider-specific adapters.
- Provider base → Other providers: specializes · Additional providers follow the same adapter pattern.
- Build scripts → Webpack configs: drives · Scripts orchestrate the separate Electron build pipelines.
- Webpack configs → Main process: builds · Bundler config targets the main process.
- Webpack configs → Preload bridge: builds · Bundler config targets the preload bridge.
- Webpack configs → App shell: builds · Bundler config targets the renderer app.
- Release app → Assets: packages · Release packaging bundles platform assets and signing resources.
- Release app → Build scripts: uses · Release packaging is supported by repo scripts.