# onlook-dev/onlook architecture

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

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

## Overview

Onlook is an open-source visual-first editor for Next.js and Tailwind projects. A user starts or imports a project, edits it visually or through AI, and sees the running app in a preview; code changes are synchronized with the sandbox. The README documents this workflow, while sampled source confirms the editor engine, branch/sandbox setup, file synchronization, chat endpoint, and publishing manager. Several capabilities are documented but their implementation was not sampled, so those links are identified as README-supported rather than inferred from module names.

Main entry points: [`apps/web/client/src/components/store/editor/engine.ts`](https://github.com/onlook-dev/onlook/blob/main/apps/web/client/src/components/store/editor/engine.ts) (Editor engine), [`apps/web/client/src/app/api/chat/route.ts`](https://github.com/onlook-dev/onlook/blob/main/apps/web/client/src/app/api/chat/route.ts) (Chat endpoint), [`apps/web/client/src/components/store/editor/sandbox/session.ts`](https://github.com/onlook-dev/onlook/blob/main/apps/web/client/src/components/store/editor/sandbox/session.ts) (Sandbox session), [`apps/web/client/src/components/store/create/manager.ts`](https://github.com/onlook-dev/onlook/blob/main/apps/web/client/src/components/store/create/manager.ts) (Create or import)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_project["Project setup"]
  node_creation["Create or import<br/>[manager.ts]"]
  node_projectdb[("Project data<br/>[client.ts]")]
end

subgraph group_editing["Visual editing"]
  node_projectpage["Project workspace<br/>[main.tsx]"]
  node_engine["Editor engine<br/>[engine.ts]"]
  node_visual["Canvas and controls<br/>[index.tsx]"]
  node_designpanels["Design panels<br/>[index.tsx]"]
  node_branches["Branch management<br/>[manager.ts]"]
end

subgraph group_runtime["Code and preview"]
  node_codeeditor["Code editor<br/>[code-editor.tsx]"]
  node_codechanges["Code requests<br/>[requests.ts]"]
  node_sandbox["Sandbox session<br/>[session.ts]"]
  node_sync["File synchronization<br/>[sync-engine.ts]"]
  node_provider["Code provider<br/>[index.ts]"]
  node_preview["App preview<br/>[view.tsx]"]
end

subgraph group_ai["AI and services"]
  node_chatstate["Chat context<br/>[context.ts]"]
  node_conversation["Chat conversations<br/>[conversation.ts]"]
  node_chatroute["Chat endpoint<br/>[route.ts]"]
  node_aiagent["AI agent and tools<br/>[client.ts]"]
end

subgraph group_delivery["Publishing"]
  node_publish["Publish manager<br/>[manager.ts]"]
  node_hosting["Hosting service"]
end

node_designer(("Designer"))

node_designer -->|"starts project"| node_creation
node_creation -.->|"stores project"| node_projectdb
node_designer -->|"opens editor"| node_projectpage
node_projectpage -.->|"uses engine"| node_engine
node_engine -->|"initializes branches"| node_branches
node_engine -.->|"coordinates editing"| node_visual
node_designer -->|"edits visually"| node_visual
node_designer -->|"manages design"| node_designpanels
node_designer -->|"edits code"| node_codeeditor
node_codeeditor -.->|"submits changes"| node_codechanges
node_designer -->|"sends prompt"| node_chatroute
node_chatroute -->|"creates agent stream"| node_aiagent
node_chatroute -.->|"uses context"| node_chatstate
node_chatroute -.->|"stores messages"| node_conversation
node_engine -.->|"manages sandbox"| node_sandbox
node_sandbox -->|"initializes sync"| node_sync
node_sync -->|"syncs files"| node_provider
node_sandbox -.->|"serves app"| node_preview
node_designer -->|"views running app"| node_preview
node_engine -.->|"coordinates code edits"| node_codechanges
node_designer -->|"deploys app"| node_publish
node_publish -.->|"publishes build"| node_hosting

click node_creation "https://github.com/onlook-dev/onlook/blob/main/apps/web/client/src/components/store/create/manager.ts"
click node_projectdb "https://github.com/onlook-dev/onlook/blob/main/packages/db/src/client.ts"
click node_projectpage "https://github.com/onlook-dev/onlook/blob/main/apps/web/client/src/app/project/%5Bid%5D/_components/main.tsx"
click node_engine "https://github.com/onlook-dev/onlook/blob/main/apps/web/client/src/components/store/editor/engine.ts"
click node_visual "https://github.com/onlook-dev/onlook/blob/main/apps/web/client/src/app/project/%5Bid%5D/_components/canvas/index.tsx"
click node_designpanels "https://github.com/onlook-dev/onlook/blob/main/apps/web/client/src/app/project/%5Bid%5D/_components/left-panel/design-panel/index.tsx"
click node_branches "https://github.com/onlook-dev/onlook/blob/main/apps/web/client/src/components/store/editor/branch/manager.ts"
click node_chatstate "https://github.com/onlook-dev/onlook/blob/main/apps/web/client/src/components/store/editor/chat/context.ts"
click node_conversation "https://github.com/onlook-dev/onlook/blob/main/apps/web/client/src/components/store/editor/chat/conversation.ts"
click node_chatroute "https://github.com/onlook-dev/onlook/blob/main/apps/web/client/src/app/api/chat/route.ts"
click node_aiagent "https://github.com/onlook-dev/onlook/blob/main/packages/ai/src/apply/client.ts"
click node_codeeditor "https://github.com/onlook-dev/onlook/blob/main/apps/web/client/src/app/project/%5Bid%5D/_components/left-panel/code-panel/code-tab/file-content/code-editor.tsx"
click node_codechanges "https://github.com/onlook-dev/onlook/blob/main/apps/web/client/src/components/store/editor/code/requests.ts"
click node_sandbox "https://github.com/onlook-dev/onlook/blob/main/apps/web/client/src/components/store/editor/sandbox/session.ts"
click node_sync "https://github.com/onlook-dev/onlook/blob/main/apps/web/client/src/services/sync-engine/sync-engine.ts"
click node_provider "https://github.com/onlook-dev/onlook/blob/main/packages/code-provider/src/index.ts"
click node_preview "https://github.com/onlook-dev/onlook/blob/main/apps/web/client/src/app/project/%5Bid%5D/_components/canvas/frame/view.tsx"
click node_publish "https://github.com/onlook-dev/onlook/blob/main/apps/web/client/src/server/api/routers/publish/manager.ts"

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_creation,node_projectdb toneBlue
class node_projectpage,node_engine,node_visual,node_designpanels,node_branches toneAmber
class node_codeeditor,node_codechanges,node_sandbox,node_sync,node_provider,node_preview toneMint
class node_chatstate,node_conversation,node_chatroute,node_aiagent toneRose
class node_publish,node_hosting,node_designer toneIndigo
```

## Components

### Project setup

- [Create or import](https://github.com/onlook-dev/onlook/blob/main/apps/web/client/src/components/store/create/manager.ts): `apps/web/client/src/components/store/create/manager.ts`
- [Project data](https://github.com/onlook-dev/onlook/blob/main/packages/db/src/client.ts): `packages/db/src/client.ts`

### Visual editing

- [Project workspace](https://github.com/onlook-dev/onlook/blob/main/apps/web/client/src/app/project/%5Bid%5D/_components/main.tsx): `apps/web/client/src/app/project/[id]/_components/main.tsx`
- [Editor engine](https://github.com/onlook-dev/onlook/blob/main/apps/web/client/src/components/store/editor/engine.ts): `apps/web/client/src/components/store/editor/engine.ts`
- [Canvas and controls](https://github.com/onlook-dev/onlook/blob/main/apps/web/client/src/app/project/%5Bid%5D/_components/canvas/index.tsx): `apps/web/client/src/app/project/[id]/_components/canvas/index.tsx`
- [Design panels](https://github.com/onlook-dev/onlook/blob/main/apps/web/client/src/app/project/%5Bid%5D/_components/left-panel/design-panel/index.tsx): `apps/web/client/src/app/project/[id]/_components/left-panel/design-panel/index.tsx`
- [Branch management](https://github.com/onlook-dev/onlook/blob/main/apps/web/client/src/components/store/editor/branch/manager.ts): `apps/web/client/src/components/store/editor/branch/manager.ts`

### Code and preview

- [Code editor](https://github.com/onlook-dev/onlook/blob/main/apps/web/client/src/app/project/%5Bid%5D/_components/left-panel/code-panel/code-tab/file-content/code-editor.tsx): `apps/web/client/src/app/project/[id]/_components/left-panel/code-panel/code-tab/file-content/code-editor.tsx`
- [Code requests](https://github.com/onlook-dev/onlook/blob/main/apps/web/client/src/components/store/editor/code/requests.ts): `apps/web/client/src/components/store/editor/code/requests.ts`
- [Sandbox session](https://github.com/onlook-dev/onlook/blob/main/apps/web/client/src/components/store/editor/sandbox/session.ts): `apps/web/client/src/components/store/editor/sandbox/session.ts`
- [File synchronization](https://github.com/onlook-dev/onlook/blob/main/apps/web/client/src/services/sync-engine/sync-engine.ts): `apps/web/client/src/services/sync-engine/sync-engine.ts`
- [Code provider](https://github.com/onlook-dev/onlook/blob/main/packages/code-provider/src/index.ts): `packages/code-provider/src/index.ts`
- [App preview](https://github.com/onlook-dev/onlook/blob/main/apps/web/client/src/app/project/%5Bid%5D/_components/canvas/frame/view.tsx): `apps/web/client/src/app/project/[id]/_components/canvas/frame/view.tsx`

### AI and services

- [Chat context](https://github.com/onlook-dev/onlook/blob/main/apps/web/client/src/components/store/editor/chat/context.ts): `apps/web/client/src/components/store/editor/chat/context.ts`
- [Chat conversations](https://github.com/onlook-dev/onlook/blob/main/apps/web/client/src/components/store/editor/chat/conversation.ts): `apps/web/client/src/components/store/editor/chat/conversation.ts`
- [Chat endpoint](https://github.com/onlook-dev/onlook/blob/main/apps/web/client/src/app/api/chat/route.ts): `apps/web/client/src/app/api/chat/route.ts`
- [AI agent and tools](https://github.com/onlook-dev/onlook/blob/main/packages/ai/src/apply/client.ts): `packages/ai/src/apply/client.ts`

### Publishing

- [Publish manager](https://github.com/onlook-dev/onlook/blob/main/apps/web/client/src/server/api/routers/publish/manager.ts): `apps/web/client/src/server/api/routers/publish/manager.ts`
- **Hosting service**

### Other components

- **Designer**

## Connections

- Designer → Create or import: starts project
- Create or import → Project data: stores project
- Designer → Project workspace: opens editor
- Project workspace → Editor engine: uses engine
- Editor engine → Branch management: initializes branches (evidence: `apps/web/client/src/components/store/editor/engine.ts`)
- Editor engine → Canvas and controls: coordinates editing
- Designer → Canvas and controls: edits visually
- Designer → Design panels: manages design
- Designer → Code editor: edits code
- Code editor → Code requests: submits changes
- Designer → Chat endpoint: sends prompt
- Chat endpoint → AI agent and tools: creates agent stream (evidence: `apps/web/client/src/app/api/chat/route.ts`)
- Chat endpoint → Chat context: uses context
- Chat endpoint → Chat conversations: stores messages
- Editor engine → Sandbox session: manages sandbox
- Sandbox session → File synchronization: initializes sync
- File synchronization → Code provider: syncs files (evidence: `apps/web/client/src/services/sync-engine/sync-engine.ts`)
- Sandbox session → App preview: serves app
- Designer → App preview: views running app
- Editor engine → Code requests: coordinates code edits
- Designer → Publish manager: deploys app
- Publish manager → Hosting service: publishes build
