# onlook-dev/desktop architecture

> Architecture diagram of the GitHub repository onlook-dev/desktop, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/onlook-dev/desktop
- Repository: https://github.com/onlook-dev/desktop

## Overview

##### Project type and purpose
- This is a monorepo for “Onlook,” an Electron-based desktop application (“Cursor for Designers”) built with React, Vite, TailwindCSS, and leveraging several internal packages (ai, models, supabase, ui, etc.).
- It provides a live “design cursor” overlay in a browser-like WebView, integrates with code (project files, IDE launch), and uses AI chat, Supabase for auth/data, plus local file I/O.

##### File structure
- Top-level directories:
- apps/studio – Electron app source (main process under electron/main, preload scripts under electron/preload, renderer React app under src).
- packages – shared libraries:
– ai (LLM chat, code helpers),
– models (typed data models & IPC constants),
– supabase (remote DB client & queries),
– ui (reusable UI components),
– foundation, git, growth, types, utility (misc tooling).
- plugins – transform plugins for frameworks (babel, next).
- scripts, tooling – build & release automation, TypeScript presets.
- Build scripts & configs: bun.lock, package.json at root, .github/workflows/build.yml, Vite/Electron configs in apps/studio.

##### README for additional insights
- Confirms Electron + React + Tailwind + Vite stack.
- Core features: Browser preview, Editor overlay, write-to-code, AI chat, domain hosting roadmap.
- Usage flows: local project load/create, live DOM editing, chat commands, right-click jump to code.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Renderer Layer
    subgraph "Renderer Layer"
        R["Renderer<br/>(React + Vite UI)"]:::frontend
        click R "https://github.com/onlook-dev/desktop/tree/main/apps/studio/src"
    end

    %% Preload Layer
    subgraph "Preload Layer"
        P["Preload<br/>(IPC Bridge)"]:::bridge
        click P "https://github.com/onlook-dev/desktop/tree/main/apps/studio/electron/preload"
    end

    %% Main Process
    subgraph "Main Process"
        M["Main Process<br/>(Services & Orchestration)"]:::backend
        click M "https://github.com/onlook-dev/desktop/tree/main/apps/studio/electron/main"
    end

    %% Core Services
    subgraph "Core Services"
        AI["AI Service"]:::service
        click AI "https://github.com/onlook-dev/desktop/tree/main/packages/ai"
        SBClient["Supabase Client"]:::service
        click SBClient "https://github.com/onlook-dev/desktop/tree/main/packages/supabase"
        FS["File System I/O"]:::service
        subgraph "Plugins"
            PB["Babel Plugin"]:::plugin
            click PB "https://github.com/onlook-dev/desktop/tree/main/plugins/babel"
            PN["Next.js Plugin"]:::plugin
            click PN "https://github.com/onlook-dev/desktop/tree/main/plugins/next"
        end
    end

    %% External Services
    LLM["LLM HTTP API"]:::external
    SupExt["Supabase Server"]:::external

    %% Shared Monorepo Packages
    subgraph "Shared Packages"
        Mod["models"]:::shared
        click Mod "https://github.com/onlook-dev/desktop/tree/main/packages/models"
        UIComp["ui"]:::shared
        click UIComp "https://github.com/onlook-dev/desktop/tree/main/packages/ui"
        Fnd["foundation"]:::shared
        click Fnd "https://github.com/onlook-dev/desktop/tree/main/packages/foundation"
        Git["git"]:::shared
        click Git "https://github.com/onlook-dev/desktop/tree/main/packages/git"
        Growth["growth"]:::shared
        click Growth "https://github.com/onlook-dev/desktop/tree/main/packages/growth"
        Types["types"]:::shared
        click Types "https://github.com/onlook-dev/desktop/tree/main/packages/types"
        Util["utility"]:::shared
        click Util "https://github.com/onlook-dev/desktop/tree/main/packages/utility"
    end

    %% Build & Config
    subgraph "Build & Config"
        BC["builder-config"]:::config
        click BC "https://github.com/onlook-dev/desktop/tree/main/apps/studio/builder-config"
        VC["vite.config.ts"]:::config
        click VC "https://github.com/onlook-dev/desktop/blob/main/apps/studio/vite.config.ts"
    end

    %% Connections
    R -->|"IPC send"| P
    P -->|"IPC messages"| M
    R -->|"imports"| UIComp
    R -->|"imports"| Mod
    R -->|"imports"| Types
    R -->|"imports"| Util

    M -->|"imports"| AI
    M -->|"imports"| SBClient
    M -->|"imports"| Mod
    M -->|"imports"| Types
    M -->|"imports"| Util
    M -->|"imports"| Fnd
    M -->|"imports"| Git
    M -->|"imports"| Growth

    M -->|"calls"| FS
    M -->|"uses"| PB
    M -->|"uses"| PN

    M -->|"HTTP RPC"| SupExt
    M -->|"LLM API"| LLM

    BC --> R
    VC --> R
    BC --> M
    VC --> M

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#009,stroke-width:1px
    classDef bridge fill:#E0F7FA,stroke:#006,stroke-width:1px
    classDef backend fill:#E6F4EA,stroke:#070,stroke-width:1px
    classDef service fill:#FFE0B2,stroke:#D95,stroke-width:1px
    classDef plugin fill:#F5F5F5,stroke:#999,stroke-width:1px
    classDef external fill:#FFF3CD,stroke:#CC9,stroke-width:1px
    classDef shared fill:#EEEEEE,stroke:#888,stroke-width:1px
    classDef config fill:#F3E5F5,stroke:#A85,stroke-width:1px
```
