# prat011/free-cluely architecture

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

- Interactive diagram: https://gitdiagram.com/prat011/free-cluely
- Repository: https://github.com/prat011/free-cluely

## Overview

1. This is an Electron desktop app with a React-based renderer. The architecture is split into three main layers: the Electron main process, a preload bridge, and the UI renderer. The main process owns OS-level capabilities; the renderer owns the visible app UI and user interaction.

2. The Electron side is centered in `electron/`. `main.ts` boots the desktop app, `WindowHelper.ts` manages window creation/behavior, `shortcuts.ts` registers global hotkeys, and `ipcHandlers.ts` connects renderer requests to privileged operations. This is where always-on-top, hide/show, movement, and screenshot-related desktop integration live.

3. `preload.ts` is the security boundary between browser UI and Node/Electron APIs. It exposes a controlled API surface to the renderer instead of letting the React app call system APIs directly. `src/types/electron.d.ts` and related types indicate that the renderer talks to Electron through typed IPC contracts.

4. The app’s core product flow is “capture context, send to AI, show answer.” `ScreenshotHelper.ts` handles screen capture, `ProcessingHelper.ts` appears to manage downstream processing, and `LLMHelper.ts` is the abstraction for calling an AI model provider. The README confirms two provider modes: Gemini in the cloud or Ollama locally.

5. The UI in `src/` is organized around three functional screens: `Queue`, `Solutions`, and `Debug` under `src/_pages/`. This suggests a workflow where screenshots or captured items are queued, then transformed into AI responses, with a separate debugging/diagnostics view for runtime state.

6. Feature components mirror those screens. `src/components/Queue/` contains queue presentation and commands for screenshot items, while `src/components/Solutions/` contains solution/action controls. `src/components/ui/` provides reusable primitives like dialogs, cards, toast notifications, and a model selector.

7. The application likely keeps screenshot items and AI outputs in renderer state, then sends commands back to Electron via IPC. A typical flow is: hotkey or UI action in the renderer requests a capture, Electron captures the screen, the image is processed or queued, the LLM helper generates a response, and the renderer displays the result in the queue/solutions views.

8. There is an audio-related type model in `src/types/audio.ts`, which indicates support for audio file or recording processing alongside screenshots. That implies the app is not only visual-assistance oriented; it also has a path for speech or recording analysis, likely routed through the same AI/processing pipeline.

9. The repo also contains `worker-script/node/index.js`, which looks like a separate Node worker entrypoint for heavier background work. That points to an architectural boundary for offloading processing away from the UI thread, likely to keep the desktop app responsive during analysis.

10. The renderer stack is React with TypeScript and Vite-style entry points in `src/main.tsx`, `src/App.tsx`, and `src/index.css`. Tailwind/PostCSS tooling is present at the repo root, so the UI is styled with utility-first CSS plus a small set of custom components.

11. Environment configuration matters to the architecture because it determines the AI backend. The app can run against Gemini using `GEMINI_API_KEY`, or against a local Ollama instance with `USE_OLLAMA`, `OLLAMA_MODEL`, and `OLLAMA_URL`. This choice affects whether requests leave the machine or stay local.

12. One important repo-level nuance: there is also a separate `renderer/` directory containing its own React app scaffold. The primary desktop architecture, however, appears to be the root `electron/` + `src/` combination; the extra renderer tree looks like an auxiliary or legacy frontend package rather than the core runtime path.

13. From an architecture diagram perspective, the key boundaries are: OS integration in Electron main, trust boundary in preload/IPC, presentation and state in the renderer, and AI/provider access in `LLMHelper` plus the optional worker script. The main external dependencies are the local filesystem/screen APIs, global keyboard hooks, and either Gemini or Ollama as the model backend.

Main entry points: [`electron/main.ts`](https://github.com/prat011/free-cluely/blob/master/electron/main.ts) (Main process), [`src/App.tsx`](https://github.com/prat011/free-cluely/blob/master/src/App.tsx) (App shell), [`electron/preload.ts`](https://github.com/prat011/free-cluely/blob/master/electron/preload.ts) (Preload bridge), [`electron/ipcHandlers.ts`](https://github.com/prat011/free-cluely/blob/master/electron/ipcHandlers.ts) (IPC handlers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_electron["Electron runtime"]
  node_electron_main["Main process<br/>electron entry<br/>[main.ts]"]
  node_window_helper["Window helper<br/>window mgmt<br/>[WindowHelper.ts]"]
  node_shortcuts["Hotkeys<br/>global shortcuts<br/>[shortcuts.ts]"]
  node_ipc_handlers["IPC handlers<br/>bridge handlers<br/>[ipcHandlers.ts]"]
  node_screenshot_helper["Screen capture<br/>capture helper"]
  node_processing_helper["Processor<br/>pipeline helper"]
  node_llm_helper["LLM helper<br/>ai adapter<br/>[LLMHelper.ts]"]
  node_preload["Preload bridge<br/>security bridge<br/>[preload.ts]"]
end

subgraph group_renderer["Renderer app"]
  node_app_shell["App shell<br/>react root<br/>[App.tsx]"]
  node_queue_page["Queue view<br/>screen<br/>[Queue.tsx]"]
  node_solutions_page["Solutions view<br/>screen<br/>[Solutions.tsx]"]
  node_debug_page["Debug view<br/>screen<br/>[Debug.tsx]"]
  node_queue_components["Queue widgets<br/>feature ui"]
  node_solution_components["Solution widgets<br/>feature ui"]
  node_model_selector["Model selector<br/>shared control<br/>[ModelSelector.tsx]"]
  node_electron_types["Electron types<br/>typed IPC contracts<br/>[electron.d.ts]"]
  node_audio_types["Audio types<br/>domain types<br/>[audio.ts]"]
end

subgraph group_worker["Background worker"]
  node_worker_entry["Worker entry<br/>node worker<br/>[index.js]"]
end

subgraph group_external["External services"]
  node_gemini(("Gemini<br/>cloud model"))
  node_ollama(("Ollama<br/>local model"))
end

node_electron_main -->|"creates window"| node_window_helper
node_electron_main -->|"registers"| node_shortcuts
node_electron_main -->|"wires IPC"| node_ipc_handlers
node_ipc_handlers -->|"capture"| node_screenshot_helper
node_ipc_handlers -->|"process"| node_processing_helper
node_processing_helper -->|"analyzes"| node_llm_helper
node_llm_helper -.->|"provider"| node_gemini
node_llm_helper -.->|"provider"| node_ollama
node_electron_main -->|"exposes bridge"| node_preload
node_preload -.->|"types"| node_electron_types
node_app_shell -->|"shows"| node_queue_page
node_app_shell -->|"shows"| node_solutions_page
node_app_shell -->|"shows"| node_debug_page
node_queue_page -->|"uses"| node_queue_components
node_solutions_page -->|"uses"| node_solution_components
node_app_shell -->|"configures"| node_model_selector
node_queue_components -->|"requests capture"| node_preload
node_solution_components -->|"requests actions"| node_preload
node_queue_components -.->|"shares model"| node_audio_types
node_worker_entry -.->|"offloads work"| node_processing_helper

click node_electron_main "https://github.com/prat011/free-cluely/blob/master/electron/main.ts"
click node_window_helper "https://github.com/prat011/free-cluely/blob/master/electron/WindowHelper.ts"
click node_shortcuts "https://github.com/prat011/free-cluely/blob/master/electron/shortcuts.ts"
click node_ipc_handlers "https://github.com/prat011/free-cluely/blob/master/electron/ipcHandlers.ts"
click node_screenshot_helper "https://github.com/prat011/free-cluely/blob/master/electron/ScreenshotHelper.ts"
click node_processing_helper "https://github.com/prat011/free-cluely/blob/master/electron/ProcessingHelper.ts"
click node_llm_helper "https://github.com/prat011/free-cluely/blob/master/electron/LLMHelper.ts"
click node_preload "https://github.com/prat011/free-cluely/blob/master/electron/preload.ts"
click node_app_shell "https://github.com/prat011/free-cluely/blob/master/src/App.tsx"
click node_queue_page "https://github.com/prat011/free-cluely/blob/master/src/_pages/Queue.tsx"
click node_solutions_page "https://github.com/prat011/free-cluely/blob/master/src/_pages/Solutions.tsx"
click node_debug_page "https://github.com/prat011/free-cluely/blob/master/src/_pages/Debug.tsx"
click node_queue_components "https://github.com/prat011/free-cluely/blob/master/src/components/Queue/ScreenshotQueue.tsx"
click node_solution_components "https://github.com/prat011/free-cluely/blob/master/src/components/Solutions/SolutionCommands.tsx"
click node_model_selector "https://github.com/prat011/free-cluely/blob/master/src/components/ui/ModelSelector.tsx"
click node_electron_types "https://github.com/prat011/free-cluely/blob/master/src/types/electron.d.ts"
click node_audio_types "https://github.com/prat011/free-cluely/blob/master/src/types/audio.ts"
click node_worker_entry "https://github.com/prat011/free-cluely/blob/master/worker-script/node/index.js"

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_electron_main,node_window_helper,node_shortcuts,node_ipc_handlers,node_screenshot_helper,node_processing_helper,node_llm_helper,node_preload toneBlue
class node_app_shell,node_queue_page,node_solutions_page,node_debug_page,node_queue_components,node_solution_components,node_model_selector,node_electron_types,node_audio_types toneAmber
class node_worker_entry toneMint
class node_gemini,node_ollama toneRose
```

## Components

### Electron runtime

Desktop shell, system integration, and IPC boundary.

- [Main process](https://github.com/prat011/free-cluely/blob/master/electron/main.ts): electron entry · Bootstraps the desktop app and owns privileged runtime behavior. · `electron/main.ts`
- [Window helper](https://github.com/prat011/free-cluely/blob/master/electron/WindowHelper.ts): window mgmt · Creates and controls the app window and visibility behavior. · `electron/WindowHelper.ts`
- [Hotkeys](https://github.com/prat011/free-cluely/blob/master/electron/shortcuts.ts): global shortcuts · Registers global keyboard shortcuts for capture and control flows. · `electron/shortcuts.ts`
- [IPC handlers](https://github.com/prat011/free-cluely/blob/master/electron/ipcHandlers.ts): bridge handlers · Handles renderer requests for privileged desktop operations. · `electron/ipcHandlers.ts`
- [Screen capture](https://github.com/prat011/free-cluely/blob/master/electron/ScreenshotHelper.ts): capture helper · Captures screenshots and related screen context. · `electron/ScreenshotHelper.ts`
- [Processor](https://github.com/prat011/free-cluely/blob/master/electron/ProcessingHelper.ts): pipeline helper · Coordinates downstream processing after capture. · `electron/ProcessingHelper.ts`
- [LLM helper](https://github.com/prat011/free-cluely/blob/master/electron/LLMHelper.ts): ai adapter · Abstracts calls to Gemini or local Ollama backends. · `electron/LLMHelper.ts`
- [Preload bridge](https://github.com/prat011/free-cluely/blob/master/electron/preload.ts): security bridge · Exposes a controlled API surface from Electron to the renderer. · `electron/preload.ts`

### Renderer app

React UI and in-app state flow.

- [App shell](https://github.com/prat011/free-cluely/blob/master/src/App.tsx): react root · Top-level renderer composition and screen wiring. · `src/App.tsx`
- [Queue view](https://github.com/prat011/free-cluely/blob/master/src/_pages/Queue.tsx): screen · Shows captured items waiting to be processed or reviewed. · `src/_pages/Queue.tsx`
- [Solutions view](https://github.com/prat011/free-cluely/blob/master/src/_pages/Solutions.tsx): screen · Presents generated answers and follow-up actions. · `src/_pages/Solutions.tsx`
- [Debug view](https://github.com/prat011/free-cluely/blob/master/src/_pages/Debug.tsx): screen · Exposes runtime diagnostics and state inspection. · `src/_pages/Debug.tsx`
- [Queue widgets](https://github.com/prat011/free-cluely/blob/master/src/components/Queue/ScreenshotQueue.tsx): feature ui · Queue item rendering and capture-related commands. · `src/components/Queue/ScreenshotQueue.tsx`
- [Solution widgets](https://github.com/prat011/free-cluely/blob/master/src/components/Solutions/SolutionCommands.tsx): feature ui · Solution presentation and action controls. · `src/components/Solutions/SolutionCommands.tsx`
- [Model selector](https://github.com/prat011/free-cluely/blob/master/src/components/ui/ModelSelector.tsx): shared control · Lets the user choose the active AI provider/model. · `src/components/ui/ModelSelector.tsx`
- [Electron types](https://github.com/prat011/free-cluely/blob/master/src/types/electron.d.ts): typed IPC contracts · Type definitions for the renderer's Electron-facing API. · `src/types/electron.d.ts`
- [Audio types](https://github.com/prat011/free-cluely/blob/master/src/types/audio.ts): domain types · Models audio file and recording processing data. · `src/types/audio.ts`

### Background worker

Separate Node entrypoint for heavier processing.

- [Worker entry](https://github.com/prat011/free-cluely/blob/master/worker-script/node/index.js): node worker · Separate Node runtime for heavier background processing. · `worker-script/node/index.js`

### External services

Model backends the app can talk to.

- **Gemini**: cloud model · Cloud AI backend used when configured.
- **Ollama**: local model · Local AI backend used for on-device model inference.

## Connections

- Main process → Window helper: creates window · Main process delegates window lifecycle and behavior.
- Main process → Hotkeys: registers · Main process installs global hotkeys at startup.
- Main process → IPC handlers: wires IPC · Main process connects renderer calls to privileged handlers.
- IPC handlers → Screen capture: capture · IPC requests can trigger screen capture operations.
- IPC handlers → Processor: process · Captured data is forwarded into the processing pipeline.
- Processor → LLM helper: analyzes · Processing delegates model calls to the LLM adapter.
- LLM helper → Gemini: provider · Cloud model path when Gemini is selected.
- LLM helper → Ollama: provider · Local model path when Ollama is selected.
- Main process → Preload bridge: exposes bridge · Preload runs alongside the main app as the renderer boundary.
- Preload bridge → Electron types: types · Typed contracts describe the exposed IPC surface.
- App shell → Queue view: shows · Renderer shell includes the queue workflow screen.
- App shell → Solutions view: shows · Renderer shell includes the solutions workflow screen.
- App shell → Debug view: shows · Renderer shell includes diagnostics and debug tooling.
- Queue view → Queue widgets: uses · Queue screen is built from queue-specific UI components.
- Solutions view → Solution widgets: uses · Solutions screen is built from solution-specific UI components.
- App shell → Model selector: configures · Shared UI controls manage provider/model selection.
- Queue widgets → Preload bridge: requests capture · Queue interactions call back into the Electron bridge.
- Solution widgets → Preload bridge: requests actions · Solution actions are executed through the Electron bridge.
- Queue widgets → Audio types: shares model · Queue domain can include audio or recording items.
- Worker entry → Processor: offloads work · Background worker represents a separate processing boundary.
