Skip to main content

Browser-Based llm IDE Architecture

Overview​

A VS Code-like web IDE with integrated dual-llm support (LM Studio + Claude Code), built with WASM/Rust, React/TypeScript, Chakra UI, Monaco editor, and xterm.js terminal.

System Architecture​

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Browser IDE (React + Chakra UI) β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚ β”‚ File Explorerβ”‚ β”‚Monaco editor β”‚ β”‚ llm Chat Panel β”‚ β”‚
β”‚ β”‚ (OPFS) β”‚ β”‚ (Code/Text) β”‚ β”‚ - LM Studio β”‚ β”‚
β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ - Claude Code β”‚ β”‚
β”‚ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”‚ - Parallel/Consensus β”‚ β”‚
β”‚ β”‚ terminal β”‚ β”‚ File Tabs β”‚ β”‚ - Model Selector β”‚ β”‚
β”‚ β”‚ (xterm.js) β”‚ β”‚ β”‚ β”‚ β”‚ β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β–²
β”‚ (WASM Bridge)
β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ WASM Core (Rust + wasm-bindgen) β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚ β”‚ LM Studio API β”‚ β”‚ File System Manager (OPFS) β”‚β”‚
β”‚ β”‚ Client (async) β”‚ β”‚ - CRUD operations β”‚β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ - Directory tree β”‚β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ - Persistence β”‚β”‚
β”‚ β”‚ Claude Code β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β”‚ β”‚ Integration β”‚ β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚ β”‚
β–Ό β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ LM Studio β”‚ β”‚ Claude Code β”‚
β”‚ (Windows Host) β”‚ β”‚ (Docker/WSL) β”‚
β”‚ :1234/v1 β”‚ β”‚ (subprocess/MCP) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Core Components​

1. WASM/Rust Core (wasm/)​

Purpose: High-performance API client, file system operations, computation

// Exposed to JavaScript via wasm-bindgen
#[wasm_bindgen]
pub struct LMStudioClient {
// Async HTTP client for LM Studio API
}

#[wasm_bindgen]
pub struct FileSystemManager {
// OPFS wrapper for file/folder operations
}

#[wasm_bindgen]
pub async fn chat_completion(prompt: String, model: String) -> Result<String, JsValue>

#[wasm_bindgen]
pub async fn stream_completion(prompt: String) -> Result<JsValue, JsValue>

Key Features:

  • Async HTTP requests to LM Studio API
  • OPFS (Origin Private File System) integration
  • JSON parsing and serialization
  • Streaming response handling
  • Zero-copy data transfer to JS

2. React Frontend (src/)​

Tech Stack:

  • React 18 (TypeScript strict mode)
  • Chakra UI (components, theming, responsiveness)
  • Monaco editor (code editing)
  • xterm.js + xterm-addon-fit (terminal)
  • Zustand (state management)
  • React Query (async state)

layout (Split Pane):

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ β”‚ β”‚ β”‚
β”‚ File β”‚ Monaco editor β”‚ llm Chat β”‚
β”‚ Tree β”‚ (Tabs) β”‚ Panel β”‚
β”‚ (OPFS) β”‚ β”‚ β”‚
β”‚ β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”‚ β”‚Model Select β”‚ β”‚
β”‚ β”‚ β”‚ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”‚
β”‚ terminal β”‚ β”‚ β”‚Chat History β”‚ β”‚
β”‚ (xterm.js) β”‚ β”‚ β”‚ β”‚ β”‚
β”‚ β”‚ β”‚ β”‚[User input] β”‚ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

3. File System (OPFS)​

Browser-based file storage:

  • Create/Read/Update/Delete files and folders
  • Persist across sessions
  • Navigate directory tree
  • Open files in Monaco editor
  • Export/Import projects

4. Monaco editor Integration​

Features:

  • Syntax highlighting (multi-language)
  • IntelliSense (basic)
  • Multi-tab support
  • File type detection
  • Keyboard shortcuts (VS Code-like)

5. terminal (xterm.js)​

Capabilities:

  • Shell-like interface
  • Execute commands via WASM or backend
  • Display llm responses
  • File operations (ls, cat, mkdir, etc.)
  • Integration with Claude Code

6. llm Integration​

Modes:

  1. Single Mode: Use one llm
  2. Parallel Mode: Side-by-side responses
    Prompt β†’ β”Œβ†’ LM Studio  β†’ Response A ─┐
    β”‚ β”œβ†’ Display
    β””β†’ Claude Code β†’ Response B β”€β”˜
  3. Sequential Mode: Chain responses
    Prompt β†’ LM Studio β†’ Context β†’ Claude Code β†’ Final
  4. Consensus Mode: Synthesize answers
    Prompt β†’ Both llms β†’ Synthesizer β†’ Final Answer

llm Panel Features:

  • Model selector (16+ LM Studio models)
  • Temperature/max_tokens controls
  • Streaming responses
  • Copy/export responses
  • Insert response into editor

Technology Stack​

Frontend​

  • Framework: React 18 + TypeScript (strict)
  • UI Library: Chakra UI
  • editor: Monaco editor (@monaco-editor/react)
  • terminal: xterm.js + addons
  • State: Zustand + React Query
  • Build: Vite + vite-plugin-wasm
  • Icons: React Icons

WASM/Rust​

  • Runtime: wasm-bindgen + wasm-pack
  • HTTP: reqwest-wasm or gloo-net
  • Async: wasm-bindgen-futures
  • Serialization: serde + serde-wasm-bindgen
  • File System: web-sys (File System Access API)

Backend (Optional/Minimal)​

  • Node.js + Express (proxy for Claude Code)
  • Or: Direct subprocess from WASM (if possible)

File Structure​

/workspace/PROJECTS/t2/
β”œβ”€β”€ README.md
β”œβ”€β”€ architecture.md
β”œβ”€β”€ package.json
β”œβ”€β”€ tsconfig.json
β”œβ”€β”€ vite.config.ts
β”œβ”€β”€ wasm/ # Rust WASM project
β”‚ β”œβ”€β”€ cargo.toml
β”‚ β”œβ”€β”€ src/
β”‚ β”‚ β”œβ”€β”€ lib.rs # Main WASM exports
β”‚ β”‚ β”œβ”€β”€ lmstudio.rs # LM Studio API client
β”‚ β”‚ β”œβ”€β”€ filesystem.rs # OPFS operations
β”‚ β”‚ └── claude.rs # Claude Code integration
β”‚ └── pkg/ # Built WASM output
β”œβ”€β”€ src/ # React frontend
β”‚ β”œβ”€β”€ main.tsx
β”‚ β”œβ”€β”€ app.tsx
β”‚ β”œβ”€β”€ components/
β”‚ β”‚ β”œβ”€β”€ layout/
β”‚ β”‚ β”‚ β”œβ”€β”€ IDElayout.tsx
β”‚ β”‚ β”‚ β”œβ”€β”€ SplitPane.tsx
β”‚ β”‚ β”‚ └── ResizablePanels.tsx
β”‚ β”‚ β”œβ”€β”€ file-explorer/
β”‚ β”‚ β”‚ β”œβ”€β”€ file-tree.tsx
β”‚ β”‚ β”‚ β”œβ”€β”€ FileNode.tsx
β”‚ β”‚ β”‚ └── ContextMenu.tsx
β”‚ β”‚ β”œβ”€β”€ editor/
β”‚ β”‚ β”‚ β”œβ”€β”€ Monacoeditor.tsx
β”‚ β”‚ β”‚ β”œβ”€β”€ editorTabs.tsx
β”‚ β”‚ β”‚ └── editorToolbar.tsx
β”‚ β”‚ β”œβ”€β”€ terminal/
β”‚ β”‚ β”‚ β”œβ”€β”€ Xterminal.tsx
β”‚ β”‚ β”‚ └── terminalControls.tsx
β”‚ β”‚ └── llm/
β”‚ β”‚ β”œβ”€β”€ chat-panel.tsx
β”‚ β”‚ β”œβ”€β”€ model-selector.tsx
β”‚ β”‚ β”œβ”€β”€ mode-selector.tsx
β”‚ β”‚ β”œβ”€β”€ message-list.tsx
β”‚ β”‚ └── InputBar.tsx
β”‚ β”œβ”€β”€ hooks/
β”‚ β”‚ β”œβ”€β”€ useWasm.ts # WASM initialization
β”‚ β”‚ β”œβ”€β”€ useFileSystem.ts # OPFS operations
β”‚ β”‚ β”œβ”€β”€ usellm.ts # llm interactions
β”‚ β”‚ └── useterminal.ts # terminal state
β”‚ β”œβ”€β”€ store/
β”‚ β”‚ β”œβ”€β”€ editor-store.ts
β”‚ β”‚ β”œβ”€β”€ fileStore.ts
β”‚ β”‚ β”œβ”€β”€ llm-store.ts
β”‚ β”‚ └── terminal-store.ts
β”‚ β”œβ”€β”€ services/
β”‚ β”‚ β”œβ”€β”€ wasm-bridge.ts # JS ↔ WASM interface
β”‚ β”‚ └── api.ts
β”‚ β”œβ”€β”€ types/
β”‚ β”‚ β”œβ”€β”€ wasm.d.ts
β”‚ β”‚ └── index.ts
β”‚ └── theme/
β”‚ └── chakra-theme.ts
└── public/

WASM Integration Flow​

  1. Initialization:

    import init, { LMStudioClient } from '../wasm/pkg';

    await init();
    const client = new LMStudioClient('host.docker.internal:1234');
  2. File Operations (WASM ↔ OPFS):

    const fs = new FileSystemManager();
    await fs.create_file('/project/main.rs', content);
    const files = await fs.list_directory('/project');
  3. llm Chat (WASM ↔ LM Studio):

    const response = await client.chat_completion(
    'Explain Rust ownership',
    'qwen/qwq-32b'
    );
  4. Streaming:

    const stream = await client.stream_completion(prompt);
    for await (const chunk of stream) {
    console.log(chunk);
    }

Environment Configuration​

# .env
VITE_LM_STUDIO_HOST=host.docker.internal
VITE_LM_STUDIO_PORT=1234
VITE_WASM_PATH=/wasm/pkg

Development Workflow​

Setup​

# Install Rust and wasm-pack
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
cargo install wasm-pack

# Install Node dependencies
npm install

# Build WASM module
cd wasm && wasm-pack build --target web && cd ..

# Start dev server
npm run dev

Development​

# Watch WASM changes
npm run wasm:watch

# Watch React changes
npm run dev

# Run both concurrently
npm run dev:all

Key Features​

File Management​

  • βœ… Create/edit/delete files and folders
  • βœ… File tree navigation
  • βœ… Context menu (right-click)
  • βœ… Drag-and-drop
  • βœ… Import/export projects

editor​

  • βœ… Monaco editor (VS Code engine)
  • βœ… Multi-language syntax highlighting
  • βœ… Multi-tab support
  • βœ… IntelliSense (basic)
  • βœ… Keyboard shortcuts

terminal​

  • βœ… xterm.js with shell emulation
  • βœ… Command execution
  • βœ… File operations
  • βœ… llm command integration

llm Integration​

  • βœ… Dual llm support (LM Studio + Claude Code)
  • βœ… 4 modes (Single, Parallel, Sequential, Consensus)
  • βœ… Model selection (16+ models)
  • βœ… Streaming responses
  • βœ… Insert into editor
  • βœ… Export conversations

Performance​

  • πŸš€ WASM for compute-heavy operations
  • πŸš€ Zero-copy data transfer
  • πŸš€ Web Workers for background tasks
  • πŸš€ OPFS for fast file access
  • πŸš€ Lazy loading components

Benefits​

  1. Privacy: All computation local (Windows + Docker + Browser)
  2. Performance: WASM near-native speed
  3. Offline: Works without internet (after initial load)
  4. Familiar UX: VS Code-like interface
  5. Powerful: Dual llm + code editing + terminal
  6. Extensible: Plugin architecture (future)

Roadmap​

  • Phase 1: WASM setup + basic LM Studio integration
  • Phase 2: File system + Monaco editor
  • Phase 3: terminal + Claude Code
  • Phase 4: Dual llm modes
  • Phase 5: Polish + advanced features