Tech Stack
Frontend
- React 18 with TypeScript
- Vite for fast development
- TailwindCSS for styling
- Radix UI for accessible components
Desktop Runtime
- Electron 33 for native capabilities
- IPC for process communication
- Global shortcuts and window management
- System tray integration
AI & Processing
- Google Gemini (cloud AI)
- Ollama (local AI models)
- Tesseract.js (OCR)
- Screenshot-desktop for captures
Build & Development
- TypeScript 5.6 for type safety
- electron-builder for packaging
- concurrently for dev workflow
- Sharp for image processing
Electron Architecture
Cluely follows the standard Electron multi-process architecture with a main process and renderer process communicating via IPC.Main Process
The main process (electron/main.ts) orchestrates the entire application through a singleton AppState class:
- Window lifecycle management
- Screenshot capture and storage
- Global keyboard shortcuts
- AI processing coordination
- System tray integration
Helper Classes
The main process delegates functionality to specialized helper classes:WindowHelper (electron/WindowHelper.ts)
WindowHelper (electron/WindowHelper.ts)
Manages the main application window with advanced positioning and visibility controls.Features:
- Always-on-top floating window
- Frameless, transparent design
- Dynamic resizing based on content
- Keyboard-based window movement
- Cross-platform full-screen compatibility
ScreenshotHelper (electron/ScreenshotHelper.ts)
ScreenshotHelper (electron/ScreenshotHelper.ts)
Handles screenshot capture, storage, and queue management.Features:
- Dual queue system (main queue and extra screenshots)
- Automatic cleanup (max 5 screenshots per queue)
- Base64 preview generation
- Screenshot metadata tracking
- Main queue:
{userData}/screenshots/ - Extra queue:
{userData}/extra_screenshots/
LLMHelper (electron/LLMHelper.ts)
LLMHelper (electron/LLMHelper.ts)
Manages AI model integrations and provides a unified interface for multiple LLM providers.Supported Providers:
- Google Gemini (gemini-2.5-flash)
- Ollama (local models like llama3.2, codellama, mistral)
- OpenRouter (various models)
- K2 Think V2 (high-reasoning AI)
- Vision API for screenshot analysis
- Audio transcription and analysis
- Rate limit handling with fallback API keys
- Retry logic with exponential backoff
- Local OCR with Tesseract.js for privacy
ShortcutsHelper (electron/shortcuts.ts)
ShortcutsHelper (electron/shortcuts.ts)
Registers and manages global keyboard shortcuts that work across the entire system.Default Shortcuts:
Cmd/Ctrl + Shift + Space- Toggle window visibilityCmd/Ctrl + H- Take screenshotCmd/Ctrl + R- Reset/clear queuesCmd/Ctrl + Arrow Keys- Move window
ProcessingHelper (electron/ProcessingHelper.ts)
ProcessingHelper (electron/ProcessingHelper.ts)
Orchestrates the AI processing pipeline from screenshot to solution.Processing Events:
UNAUTHORIZED- API key issuesNO_SCREENSHOTS- No screenshots in queueINITIAL_START- Starting problem extractionPROBLEM_EXTRACTED- Problem successfully parsedSOLUTION_SUCCESS- Solution generatedDEBUG_START/SUCCESS/ERROR- Debugging workflow
IPC Communication
The main and renderer processes communicate via IPC handlers defined inelectron/ipcHandlers.ts:
React Architecture
The renderer process is a React application built with modern patterns.Component Structure
State Management
Cluely uses React Query for server state and React Context for UI state, avoiding Redux complexity.
Dynamic Window Sizing
The window automatically resizes based on content:File Structure
Key Design Patterns
Singleton Pattern
TheAppState class uses a singleton pattern to maintain global state:
Dependency Injection
Helper classes receiveAppState reference for coordinated state management:
Event-Driven Communication
Renderer receives events from main process for real-time updates:Platform-Specific Code
Environment Configuration
Cluely supports multiple AI providers configured via.env:
Performance Optimizations
Efficient Screenshot Storage
- Max 5 screenshots per queue
- Automatic cleanup of old screenshots
- UUID-based filenames prevent collisions
Security Considerations
Context Isolation: Enabled by default to prevent renderer from accessing Node.js APIs directly.
Next Steps
Building the App
Learn how to build and run Cluely locally
Contributing
Guidelines for contributing to Cluely