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:
- Single Mode: Use one llm
- Parallel Mode: Side-by-side responses
Prompt β ββ LM Studio β Response A ββ
β ββ Display
ββ Claude Code β Response B ββ - Sequential Mode: Chain responses
Prompt β LM Studio β Context β Claude Code β Final - 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β
-
Initialization:
import init, { LMStudioClient } from '../wasm/pkg';
await init();
const client = new LMStudioClient('host.docker.internal:1234'); -
File Operations (WASM β OPFS):
const fs = new FileSystemManager();
await fs.create_file('/project/main.rs', content);
const files = await fs.list_directory('/project'); -
llm Chat (WASM β LM Studio):
const response = await client.chat_completion(
'Explain Rust ownership',
'qwen/qwq-32b'
); -
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β
- Privacy: All computation local (Windows + Docker + Browser)
- Performance: WASM near-native speed
- Offline: Works without internet (after initial load)
- Familiar UX: VS Code-like interface
- Powerful: Dual llm + code editing + terminal
- 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