diff --git a/.github/workflows/desktop-windows.yml b/.github/workflows/desktop-windows.yml
new file mode 100644
index 0000000..a3daf6a
--- /dev/null
+++ b/.github/workflows/desktop-windows.yml
@@ -0,0 +1,80 @@
+name: DroidUI Desktop Windows Installer
+
+on:
+ workflow_dispatch:
+ pull_request:
+ paths:
+ - "desktop/**"
+ - ".github/workflows/desktop-windows.yml"
+ push:
+ branches:
+ - feat/desktop-foundation
+ paths:
+ - "desktop/**"
+ - ".github/workflows/desktop-windows.yml"
+
+permissions:
+ contents: read
+
+jobs:
+ windows-installer:
+ name: Build Windows NSIS installer
+ runs-on: windows-latest
+ defaults:
+ run:
+ working-directory: desktop
+ steps:
+ - uses: actions/checkout@v4
+ - uses: actions/setup-node@v4
+ with:
+ node-version: "20"
+ - uses: dtolnay/rust-toolchain@stable
+ with:
+ targets: x86_64-pc-windows-msvc
+ - name: Generate required Tauri icons
+ shell: pwsh
+ run: |
+ python -m pip install --disable-pip-version-check pillow
+ @'
+ from PIL import Image, ImageDraw
+ from pathlib import Path
+ p=Path("src-tauri/icons")
+ p.mkdir(parents=True, exist_ok=True)
+ im=Image.new("RGBA",(512,512),(21,29,42,255))
+ d=ImageDraw.Draw(im)
+ d.rounded_rectangle((65,65,447,447),radius=85,fill=(50,105,232,255))
+ d.polygon([(256,115),(390,256),(256,397),(122,256)],fill=(240,246,255,255))
+ im.save(p/"icon.png")
+ im.save(p/"icon.ico",sizes=[(16,16),(32,32),(48,48),(64,64),(128,128),(256,256)])
+ '@ | python -
+ - name: Install desktop dependencies
+ run: npm install --no-audit --no-fund
+ - name: Build desktop web frontend
+ run: npm run build
+ - name: Build Tauri Windows installer
+ id: installer
+ continue-on-error: true
+ run: npm run desktop:build
+ - name: Upload compiled portable executable
+ if: always()
+ uses: actions/upload-artifact@v4
+ with:
+ name: droidui-desktop-windows-portable
+ path: desktop/src-tauri/target/release/droidui-desktop.exe
+ if-no-files-found: error
+ retention-days: 14
+ - name: Retry installer packaging after transient network failure
+ if: steps.installer.outcome == 'failure'
+ run: npm run desktop:build
+ - name: Verify installer exists
+ shell: pwsh
+ run: |
+ $files = @(Get-ChildItem -Path src-tauri/target/release/bundle/nsis -Filter "*.exe" -File -ErrorAction SilentlyContinue)
+ if ($files.Count -eq 0) { throw "No Windows NSIS installer generated" }
+ $files | ForEach-Object { Write-Host "$($_.Name) $($_.Length) bytes" }
+ - uses: actions/upload-artifact@v4
+ with:
+ name: droidui-desktop-windows-installer
+ path: desktop/src-tauri/target/release/bundle/nsis/*.exe
+ if-no-files-found: error
+ retention-days: 14
diff --git a/desktop/README.md b/desktop/README.md
new file mode 100644
index 0000000..6004919
--- /dev/null
+++ b/desktop/README.md
@@ -0,0 +1,19 @@
+# DroidUI Desktop — Phase D1
+
+Windows-first Tauri 2 + React/TypeScript desktop studio. This first scaffold supports a draggable canvas, layer selection, property editing, and saving/loading a **desktop prototype** project.
+
+## Run
+
+Prerequisites: Node 20+, Rust stable, Windows C++ build tools, WebView2.
+
+```bash
+cd desktop
+npm install
+npm run desktop
+```
+
+Build an installer with `npm run desktop:build`.
+
+## Known limitations
+
+The current desktop JSON document is a **prototype**, NOT the existing DroidUI mobile `.dui` schema. Loading a mobile project is intentionally rejected until the shared project adapter and schema validation are implemented. File dialogs and disk access require the Tauri runtime (not a plain browser). No Windows installer has been verified yet. Drag positions are not yet constrained to canvas bounds. Additional production features (undo/redo, device presets, export, shared compiler, icons, animation timeline) remain future phases.
diff --git a/desktop/index.html b/desktop/index.html
new file mode 100644
index 0000000..bb22575
--- /dev/null
+++ b/desktop/index.html
@@ -0,0 +1 @@
+
DroidUI Desktop
diff --git a/desktop/package.json b/desktop/package.json
new file mode 100644
index 0000000..be608d1
--- /dev/null
+++ b/desktop/package.json
@@ -0,0 +1,26 @@
+{
+ "name": "droidui-desktop",
+ "version": "0.1.0",
+ "private": true,
+ "type": "module",
+ "scripts": {
+ "dev": "vite",
+ "build": "tsc -b && vite build",
+ "desktop": "tauri dev",
+ "desktop:build": "tauri build"
+ },
+ "dependencies": {
+ "@tauri-apps/api": "^2.0.0",
+ "@tauri-apps/plugin-dialog": "^2.0.0",
+ "@tauri-apps/plugin-fs": "^2.0.0",
+ "react": "^18.3.1",
+ "react-dom": "^18.3.1"
+ },
+ "devDependencies": {
+ "@tauri-apps/cli": "^2.0.0",
+ "@types/react": "^18.3.0",
+ "@types/react-dom": "^18.3.0",
+ "typescript": "^5.6.0",
+ "vite": "^5.4.0"
+ }
+}
diff --git a/desktop/src-tauri/Cargo.toml b/desktop/src-tauri/Cargo.toml
new file mode 100644
index 0000000..062f218
--- /dev/null
+++ b/desktop/src-tauri/Cargo.toml
@@ -0,0 +1,12 @@
+[package]
+name = "droidui-desktop"
+version = "0.1.0"
+edition = "2021"
+
+[build-dependencies]
+tauri-build = { version = "2", features = [] }
+
+[dependencies]
+tauri = { version = "2", features = [] }
+tauri-plugin-dialog = "2"
+tauri-plugin-fs = "2"
diff --git a/desktop/src-tauri/build.rs b/desktop/src-tauri/build.rs
new file mode 100644
index 0000000..2846c57
--- /dev/null
+++ b/desktop/src-tauri/build.rs
@@ -0,0 +1 @@
+fn main() { tauri_build::build() }
diff --git a/desktop/src-tauri/capabilities/default.json b/desktop/src-tauri/capabilities/default.json
new file mode 100644
index 0000000..65bf777
--- /dev/null
+++ b/desktop/src-tauri/capabilities/default.json
@@ -0,0 +1,17 @@
+{
+ "identifier": "default",
+ "description": "Project file open and save",
+ "windows": [
+ "main"
+ ],
+ "permissions": [
+ "core:default",
+ "dialog:allow-open",
+ "dialog:allow-save",
+ "fs:allow-read-text-file",
+ "fs:allow-write-text-file",
+ "fs:scope-home",
+ "fs:scope-document",
+ "fs:scope-download"
+ ]
+}
diff --git a/desktop/src-tauri/src/main.rs b/desktop/src-tauri/src/main.rs
new file mode 100644
index 0000000..48e268f
--- /dev/null
+++ b/desktop/src-tauri/src/main.rs
@@ -0,0 +1,2 @@
+#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
+fn main() { tauri::Builder::default().plugin(tauri_plugin_dialog::init()).plugin(tauri_plugin_fs::init()).run(tauri::generate_context!()).expect("failed to run DroidUI Desktop"); }
diff --git a/desktop/src-tauri/tauri.conf.json b/desktop/src-tauri/tauri.conf.json
new file mode 100644
index 0000000..d77a92e
--- /dev/null
+++ b/desktop/src-tauri/tauri.conf.json
@@ -0,0 +1,32 @@
+{
+ "$schema": "https://schema.tauri.app/config/2",
+ "productName": "DroidUI Desktop",
+ "version": "0.1.0",
+ "identifier": "com.codephrex.droidui.desktop",
+ "build": {
+ "beforeDevCommand": "npm run dev",
+ "devUrl": "http://localhost:1420",
+ "beforeBuildCommand": "npm run build",
+ "frontendDist": "../dist"
+ },
+ "app": {
+ "windows": [
+ {
+ "title": "DroidUI Desktop",
+ "width": 1440,
+ "height": 900,
+ "minWidth": 1024,
+ "minHeight": 700
+ }
+ ],
+ "security": {
+ "csp": null
+ }
+ },
+ "bundle": {
+ "active": true,
+ "targets": [
+ "nsis"
+ ]
+ }
+}
diff --git a/desktop/src/main.tsx b/desktop/src/main.tsx
new file mode 100644
index 0000000..560dec9
--- /dev/null
+++ b/desktop/src/main.tsx
@@ -0,0 +1,26 @@
+import React, { useState } from "react";
+import { createRoot } from "react-dom/client";
+import { open, save } from "@tauri-apps/plugin-dialog";
+import { readTextFile, writeTextFile } from "@tauri-apps/plugin-fs";
+import "./style.css";
+
+type Node = { id: string; type: "Text" | "Button" | "Card"; label: string; x: number; y: number };
+type Document = { name: string; nodes: Node[] };
+const initial: Document = { name: "Untitled Project", nodes: [{ id: "welcome", type: "Text", label: "Welcome to DroidUI", x: 64, y: 72 }] };
+function App() {
+ const [doc, setDoc] = useState(initial);
+ const [selected, setSelected] = useState("welcome");
+ const [path, setPath] = useState(null);
+ const [message, setMessage] = useState("Ready");
+ const node = doc.nodes.find(n => n.id === selected);
+ function updateNode(id: string, patch: Partial) { setDoc(d => ({ ...d, nodes: d.nodes.map(n => n.id === id ? { ...n, ...patch } : n) })); }
+ function add(type: Node["type"]) { const id = crypto.randomUUID(); setDoc(d => ({ ...d, nodes: [...d.nodes, { id, type, label: type === "Text" ? "Text label" : type, x: 48, y: 48 }] })); setSelected(id); }
+ async function load() { try { const file = await open({ multiple: false, filters: [{ name: "DroidUI project", extensions: ["dui", "json"] }] }); if (typeof file !== "string") return; const raw = JSON.parse(await readTextFile(file)); if (!raw || typeof raw !== "object" || !Array.isArray(raw.nodes) || typeof raw.name !== "string") throw Error("Unsupported project format"); setDoc(raw as Document); setPath(file); setSelected(null); setMessage("Project opened"); } catch (e) { setMessage(String(e)); } }
+ async function persist() { try { const file = path ?? await save({ defaultPath: doc.name.replace(/[^a-z0-9-_]/gi, "_") + ".dui", filters: [{ name: "DroidUI project", extensions: ["dui"] }] }); if (!file) return; await writeTextFile(file, JSON.stringify(doc, null, 2)); setPath(file); setMessage("Project saved"); } catch (e) { setMessage(String(e)); } }
+ return
+
+
+
{doc.name}Canvas · 390 × 844
setSelected(null)}>{doc.nodes.map(n =>
{e.stopPropagation();setSelected(n.id);}} onPointerDown={e => { if(e.button!==0) return; const startX=e.clientX,startY=e.clientY,ox=n.x,oy=n.y; const move=(ev:PointerEvent)=>updateNode(n.id,{x:Math.max(0,ox+ev.clientX-startX),y:Math.max(0,oy+ev.clientY-startY)}); const stop=()=>{window.removeEventListener("pointermove",move);window.removeEventListener("pointerup",stop);};window.addEventListener("pointermove",move);window.addEventListener("pointerup",stop); }}>{n.label}
)}
+
;
+}
+createRoot(document.getElementById("root")!).render();
diff --git a/desktop/src/style.css b/desktop/src/style.css
new file mode 100644
index 0000000..8721ca4
--- /dev/null
+++ b/desktop/src/style.css
@@ -0,0 +1 @@
+:root{font-family:Inter,Segoe UI,Arial,sans-serif;color:#e9edf7;background:#10141c}*{box-sizing:border-box}body{margin:0}button,input{font:inherit}button{background:#252d3d;color:#e9edf7;border:1px solid #354053;border-radius:7px;padding:9px 12px;cursor:pointer;text-align:left}button:hover,.active{background:#334768!important}header{height:64px;border-bottom:1px solid #2b3445;display:flex;align-items:center;justify-content:space-between;padding:0 22px;background:#171d28}.brand{font-size:20px;font-weight:800}.brand small{font-size:10px;letter-spacing:2px;color:#8ea3c7;margin-left:8px}.mark{color:#73a7ff;font-size:26px}.actions{display:flex;gap:9px}.workspace{display:grid;grid-template-columns:230px minmax(400px,1fr) 260px;height:calc(100vh - 94px)}aside{padding:18px;background:#171d28;overflow:auto}aside h3{font-size:12px;text-transform:uppercase;letter-spacing:1.3px;color:#9faec5;margin:12px 0}aside button{display:block;width:100%;margin:7px 0}main{background:#10141c;overflow:auto;padding:20px}.canvasbar{display:flex;justify-content:space-between;color:#aebbd0;margin:0 auto 20px;max-width:700px}.canvasbar strong{color:#fff}.canvas{position:relative;margin:auto;background:#f7f9fd;color:#222;width:390px;height:844px;box-shadow:0 15px 65px #0008;border-radius:12px;overflow:hidden}.element{position:absolute;cursor:move;touch-action:none;user-select:none;padding:9px;border:1px solid transparent}.element.selected{outline:2px solid #4e92ff}.element.text{font-size:18px;font-weight:600}.element.button{background:#376fe7;color:white;border-radius:8px;padding:12px 20px}.element.card{background:#e3e9f3;border-radius:12px;padding:28px;min-width:160px}.inspector label{display:block;color:#b4c2d9;font-size:13px;margin:18px 0}.inspector input{display:block;width:100%;margin-top:7px;background:#10141c;color:white;border:1px solid #354053;padding:9px;border-radius:7px}footer{height:30px;border-top:1px solid #2b3445;padding:6px 18px;color:#a7b4ca;font-size:12px;display:flex;justify-content:space-between}@media(max-width:850px){.workspace{grid-template-columns:170px minmax(390px,1fr) 190px}}
diff --git a/desktop/tsconfig.json b/desktop/tsconfig.json
new file mode 100644
index 0000000..dd8cd16
--- /dev/null
+++ b/desktop/tsconfig.json
@@ -0,0 +1,20 @@
+{
+ "compilerOptions": {
+ "target": "ES2022",
+ "lib": [
+ "ES2022",
+ "DOM",
+ "DOM.Iterable"
+ ],
+ "module": "ESNext",
+ "moduleResolution": "Bundler",
+ "jsx": "react-jsx",
+ "strict": true,
+ "skipLibCheck": true,
+ "noEmit": true,
+ "allowImportingTsExtensions": true
+ },
+ "include": [
+ "src"
+ ]
+}
diff --git a/desktop/vite.config.ts b/desktop/vite.config.ts
new file mode 100644
index 0000000..57b0456
--- /dev/null
+++ b/desktop/vite.config.ts
@@ -0,0 +1,2 @@
+import { defineConfig } from "vite";
+export default defineConfig({ server: { port: 1420, strictPort: true }, clearScreen: false });
diff --git a/docs/DESKTOP_ARCHITECTURE.md b/docs/DESKTOP_ARCHITECTURE.md
new file mode 100644
index 0000000..c14c5ad
--- /dev/null
+++ b/docs/DESKTOP_ARCHITECTURE.md
@@ -0,0 +1,37 @@
+# DroidUI Desktop — Architecture
+
+## Current implementation
+- Desktop shell: Tauri 2 / Rust / WebView2 on Windows.
+- UI: React 18 + TypeScript + Vite.
+- File dialogs: `@tauri-apps/plugin-dialog`.
+- Local persistence: `@tauri-apps/plugin-fs`.
+- CI: GitHub Actions Windows NSIS packaging with a portable executable fallback.
+
+## Target architecture
+```text
+desktop-ui (React)
+ ├── editor shell (panels, commands, shortcuts)
+ ├── canvas renderer (viewport, transforms, selection)
+ ├── property inspector / component catalog
+ └── preview
+ │
+shared-editor-core (framework-neutral TypeScript)
+ ├── document schema and migrations
+ ├── commands + undo/redo
+ ├── selection, layout, snapping
+ ├── validation and serializers
+ └── import/export adapters
+ │
+Tauri desktop services (filesystem, dialogs, OS integration)
+ │
+Android DroidUI app (existing Expo/React Native implementation)
+```
+
+## Compatibility contract
+Do not treat the D1 prototype's `{name,nodes}` JSON as the production Android project schema. Introduce a shared versioned model with explicit adapters for Android signature `DROID_STUDIO_PROJECT_V30` and schema versions 29/30. Preserve unknown fields when practical; reject invalid or unsafe inputs. Test round trips with real sanitized Android fixtures before enabling cross-platform project open/save.
+
+## Security
+Limit filesystem scope to user-approved project paths; validate imported JSON; never execute project-authored scripts. Release builds should be signed before public distribution.
+
+## Engineering workflow
+Use feature branches, pull requests, required Windows build/typecheck/tests, release tags, changelogs, and reproducible dependency locks. Keep Android CI independent from desktop CI.
diff --git a/docs/DESKTOP_CONTRIBUTING.md b/docs/DESKTOP_CONTRIBUTING.md
new file mode 100644
index 0000000..effe07c
--- /dev/null
+++ b/docs/DESKTOP_CONTRIBUTING.md
@@ -0,0 +1,27 @@
+# Contributing to DroidUI Desktop
+
+## Local Windows setup
+Install Node.js 20+, Rust stable, Microsoft C++ Build Tools and WebView2. From the repository root:
+
+```powershell
+cd desktop
+npm install
+npm run build
+npm run desktop
+```
+
+Build a Windows installer with `npm run desktop:build`.
+
+## Development conventions
+- TypeScript strict mode; explicit types for document and command boundaries.
+- Separate UI components from document mutations; commands must be undoable.
+- Validate imported project files; use fixtures for migration tests.
+- Keep each pull request focused, include screenshots for UI changes and explain manual tests.
+- Do not merge failing Windows builds or claim a packaged installer exists without an uploaded artifact.
+- Avoid breaking Android project compatibility; keep existing mobile application isolated.
+
+## Proposed issue labels
+`desktop`, `phase-d2`, `ux`, `interop`, `bug`, `testing`, `documentation`.
+
+## Release checklist
+Typecheck; tests; Windows installer and portable executable artifacts; smoke test on Windows 10/11; verify open/save; check antivirus false positives; version/changelog; code signing for public distribution.
diff --git a/docs/DESKTOP_PRODUCT_SPEC.md b/docs/DESKTOP_PRODUCT_SPEC.md
new file mode 100644
index 0000000..015db5e
--- /dev/null
+++ b/docs/DESKTOP_PRODUCT_SPEC.md
@@ -0,0 +1,24 @@
+# DroidUI Desktop — Product Specification
+
+**Status:** Phase D1 prototype complete; Phase D2 planned. **Target:** commercial-quality Windows-first visual UI studio.
+
+## Product principles
+- Desktop-first, keyboard-accessible professional workflow; Android project interoperability.
+- Non-destructive editing, explicit save state, responsive inspector, predictable shortcuts.
+- Offline-first project editing; no cloud account required for core features.
+
+## Phase D2 acceptance criteria
+1. **Canvas:** zoom 25–400%, pan, optional grid/snap, multi-select, drag, resize handles, alignment guides, visible device bounds.
+2. **Workspace:** resizable/dockable toolbox, Layers, Properties, Assets and History panels; restore layout between sessions.
+3. **Editing:** undo/redo for mutations, duplicate/delete, grouping, z-order, context menu, keyboard shortcuts.
+4. **Components:** searchable categorized library with thumbnails and presets; editable text, layout, colors, spacing, typography, events.
+5. **Preview:** interactive device-size preview with selectable device presets and clear edit/preview modes.
+6. **Persistence:** atomic save, unsaved-change prompt, schema validation, safe error messages, backups, recent projects.
+7. **Interoperability:** a versioned adapter that reads/writes the existing Android `.dui` schema without losing unsupported fields; round-trip regression fixtures.
+8. **Quality:** Windows CI installer, UI regression tests, accessibility and keyboard checks, release notes, signed releases before commercial distribution.
+
+## Non-goals for D2
+Cloud collaboration, marketplace, and full cross-platform packaging are later phases.
+
+## Current limitations
+The Phase D1 desktop prototype uses a separate project JSON format and is **not yet interoperable** with Android `.dui` projects. Windows executable has been built in GitHub Actions; no code signing or commercial release readiness is claimed.