# princeomonu/open-lovable architecture

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

- Interactive diagram: https://gitdiagram.com/princeomonu/open-lovable
- Repository: https://github.com/princeomonu/open-lovable

## Overview

Open Lovable is a browser-facing AI app builder: users describe or request edits to a React app, AI generates code, and an E2B sandbox runs the project for preview and iteration. The graph preserves the documented chat-to-app workflow and the repository’s sandbox, package, file-analysis, and Vite-error capabilities. Source excerpts confirm generation’s context-selection and search calls, plus code-application and package-install behavior; UI wiring and several route internals were not sampled, so those links are omitted.

Main entry points: [`app/api/generate-ai-code-stream/route.ts`](https://github.com/princeomonu/open-lovable/blob/main/app/api/generate-ai-code-stream/route.ts) (Code Generation), [`app/api/get-sandbox-files/route.ts`](https://github.com/princeomonu/open-lovable/blob/main/app/api/get-sandbox-files/route.ts) (Fetch Sandbox Files), [`lib/context-selector.ts`](https://github.com/princeomonu/open-lovable/blob/main/lib/context-selector.ts) (File Context), [`lib/file-search-executor.ts`](https://github.com/princeomonu/open-lovable/blob/main/lib/file-search-executor.ts) (Code Search)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Builder UI"]
  node_page["Builder Page<br/>[page.tsx]"]
  node_preview["Sandbox Preview<br/>[SandboxPreview.tsx]"]
  node_progress["Apply Progress"]
end

subgraph group_ai["AI Code Workflow"]
  node_analyze["Edit Intent<br/>[route.ts]"]
  node_generate["Code Generation<br/>[route.ts]"]
  node_context["File Context"]
  node_search["Code Search"]
  node_apply["Apply Code<br/>[route.ts]"]
  node_apply_basic["Apply Code<br/>[route.ts]"]
  node_conversation[("Conversation State<br/>[route.ts]")]
end

subgraph group_sandbox["Sandbox Runtime"]
  node_sandbox_create["Create Sandbox<br/>[route.ts]"]
  node_sandbox_state["Sandbox State<br/>[sandbox.ts]"]
  node_install["Install Packages<br/>[route.ts]"]
  node_detect_packages["Detect Packages<br/>[route.ts]"]
end

subgraph group_project["Project Inspection"]
  node_files["Fetch Sandbox Files<br/>[route.ts]"]
  node_parser["File Parser<br/>[file-parser.ts]"]
  node_manifest["File Manifest<br/>[file-manifest.ts]"]
  node_scrape["URL Scraping<br/>[route.ts]"]
end

subgraph group_repair["Runtime Repair"]
  node_vite_monitor["Monitor Vite Logs<br/>[route.ts]"]
  node_vite_restart["Restart Vite<br/>[route.ts]"]
  node_vite_errors["Vite Error Check<br/>[route.ts]"]
end

node_user(("Builder"))
node_firecrawl(("Firecrawl"))

node_generate -->|"selects files"| node_context
node_generate -->|"reads contents"| node_context
node_generate -->|"executes plan"| node_search
node_generate -->|"formats results"| node_search
node_apply -->|"requests install"| node_install
node_apply_basic -->|"requests install"| node_install
node_files -->|"parses files"| node_parser
node_files -->|"builds tree"| node_parser
node_files -->|"updates cache"| node_manifest
node_vite_restart -->|"records errors"| node_vite_monitor
node_scrape -.->|"scrapes URL"| node_firecrawl

click node_page "https://github.com/princeomonu/open-lovable/blob/main/app/page.tsx"
click node_preview "https://github.com/princeomonu/open-lovable/blob/main/components/SandboxPreview.tsx"
click node_progress "https://github.com/princeomonu/open-lovable/blob/main/components/CodeApplicationProgress.tsx"
click node_analyze "https://github.com/princeomonu/open-lovable/blob/main/app/api/analyze-edit-intent/route.ts"
click node_generate "https://github.com/princeomonu/open-lovable/blob/main/app/api/generate-ai-code-stream/route.ts"
click node_context "https://github.com/princeomonu/open-lovable/blob/main/lib/context-selector.ts"
click node_search "https://github.com/princeomonu/open-lovable/blob/main/lib/file-search-executor.ts"
click node_apply "https://github.com/princeomonu/open-lovable/blob/main/app/api/apply-ai-code-stream/route.ts"
click node_apply_basic "https://github.com/princeomonu/open-lovable/blob/main/app/api/apply-ai-code/route.ts"
click node_conversation "https://github.com/princeomonu/open-lovable/blob/main/app/api/conversation-state/route.ts"
click node_sandbox_create "https://github.com/princeomonu/open-lovable/blob/main/app/api/create-ai-sandbox/route.ts"
click node_sandbox_state "https://github.com/princeomonu/open-lovable/blob/main/types/sandbox.ts"
click node_install "https://github.com/princeomonu/open-lovable/blob/main/app/api/install-packages/route.ts"
click node_detect_packages "https://github.com/princeomonu/open-lovable/blob/main/app/api/detect-and-install-packages/route.ts"
click node_files "https://github.com/princeomonu/open-lovable/blob/main/app/api/get-sandbox-files/route.ts"
click node_parser "https://github.com/princeomonu/open-lovable/blob/main/lib/file-parser.ts"
click node_manifest "https://github.com/princeomonu/open-lovable/blob/main/types/file-manifest.ts"
click node_scrape "https://github.com/princeomonu/open-lovable/blob/main/app/api/scrape-url-enhanced/route.ts"
click node_vite_monitor "https://github.com/princeomonu/open-lovable/blob/main/app/api/monitor-vite-logs/route.ts"
click node_vite_restart "https://github.com/princeomonu/open-lovable/blob/main/app/api/restart-vite/route.ts"
click node_vite_errors "https://github.com/princeomonu/open-lovable/blob/main/app/api/check-vite-errors/route.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_page,node_preview,node_progress toneBlue
class node_analyze,node_generate,node_context,node_search,node_apply,node_apply_basic,node_conversation toneAmber
class node_sandbox_create,node_sandbox_state,node_install,node_detect_packages toneMint
class node_files,node_parser,node_manifest,node_scrape toneRose
class node_vite_monitor,node_vite_restart,node_vite_errors,node_user,node_firecrawl toneIndigo
```

## Components

### Builder UI

- [Builder Page](https://github.com/princeomonu/open-lovable/blob/main/app/page.tsx): `app/page.tsx`
- [Sandbox Preview](https://github.com/princeomonu/open-lovable/blob/main/components/SandboxPreview.tsx): `components/SandboxPreview.tsx`
- [Apply Progress](https://github.com/princeomonu/open-lovable/blob/main/components/CodeApplicationProgress.tsx): `components/CodeApplicationProgress.tsx`

### AI Code Workflow

- [Edit Intent](https://github.com/princeomonu/open-lovable/blob/main/app/api/analyze-edit-intent/route.ts): `app/api/analyze-edit-intent/route.ts`
- [Code Generation](https://github.com/princeomonu/open-lovable/blob/main/app/api/generate-ai-code-stream/route.ts): `app/api/generate-ai-code-stream/route.ts`
- [File Context](https://github.com/princeomonu/open-lovable/blob/main/lib/context-selector.ts): `lib/context-selector.ts`
- [Code Search](https://github.com/princeomonu/open-lovable/blob/main/lib/file-search-executor.ts): `lib/file-search-executor.ts`
- [Apply Code](https://github.com/princeomonu/open-lovable/blob/main/app/api/apply-ai-code-stream/route.ts): `app/api/apply-ai-code-stream/route.ts`
- [Apply Code](https://github.com/princeomonu/open-lovable/blob/main/app/api/apply-ai-code/route.ts): `app/api/apply-ai-code/route.ts`
- [Conversation State](https://github.com/princeomonu/open-lovable/blob/main/app/api/conversation-state/route.ts): `app/api/conversation-state/route.ts`

### Sandbox Runtime

- [Create Sandbox](https://github.com/princeomonu/open-lovable/blob/main/app/api/create-ai-sandbox/route.ts): `app/api/create-ai-sandbox/route.ts`
- [Sandbox State](https://github.com/princeomonu/open-lovable/blob/main/types/sandbox.ts): `types/sandbox.ts`
- [Install Packages](https://github.com/princeomonu/open-lovable/blob/main/app/api/install-packages/route.ts): `app/api/install-packages/route.ts`
- [Detect Packages](https://github.com/princeomonu/open-lovable/blob/main/app/api/detect-and-install-packages/route.ts): `app/api/detect-and-install-packages/route.ts`

### Project Inspection

- [Fetch Sandbox Files](https://github.com/princeomonu/open-lovable/blob/main/app/api/get-sandbox-files/route.ts): `app/api/get-sandbox-files/route.ts`
- [File Parser](https://github.com/princeomonu/open-lovable/blob/main/lib/file-parser.ts): `lib/file-parser.ts`
- [File Manifest](https://github.com/princeomonu/open-lovable/blob/main/types/file-manifest.ts): `types/file-manifest.ts`
- [URL Scraping](https://github.com/princeomonu/open-lovable/blob/main/app/api/scrape-url-enhanced/route.ts): `app/api/scrape-url-enhanced/route.ts`

### Runtime Repair

- [Monitor Vite Logs](https://github.com/princeomonu/open-lovable/blob/main/app/api/monitor-vite-logs/route.ts): `app/api/monitor-vite-logs/route.ts`
- [Restart Vite](https://github.com/princeomonu/open-lovable/blob/main/app/api/restart-vite/route.ts): `app/api/restart-vite/route.ts`
- [Vite Error Check](https://github.com/princeomonu/open-lovable/blob/main/app/api/check-vite-errors/route.ts): `app/api/check-vite-errors/route.ts`

### Other components

- **Builder**
- **Firecrawl**

## Connections

- Code Generation → File Context: selects files
- Code Generation → File Context: reads contents
- Code Generation → Code Search: executes plan
- Code Generation → Code Search: formats results
- Apply Code → Install Packages: requests install
- Apply Code → Install Packages: requests install
- Fetch Sandbox Files → File Parser: parses files
- Fetch Sandbox Files → File Parser: builds tree
- Fetch Sandbox Files → File Manifest: updates cache
- Restart Vite → Monitor Vite Logs: records errors
- URL Scraping → Firecrawl: scrapes URL
