Modular Tauri 2 desktop app (React + TypeScript) with a pluggable AI layer wired for Cloudflare Workers AI.
UI (React features)
→ modules (video, ai, …)
→ Tauri plugins / Rust commands
→ optional Cloudflare Worker (Workers AI)
| Layer | Path | Role |
|---|---|---|
| UI features | src/features/* |
Screens (video player, …) |
| Video module | src/modules/video |
File picker + playable source URLs |
| AI module (TS) | src/modules/ai |
Provider interface + facade |
| Commands | src-tauri/src/commands |
Tauri IPC surface |
| AI module (Rust) | src-tauri/src/modules/ai |
Provider trait + Workers AI client |
| Config | src-tauri/src/modules/config |
Endpoint / model / optional API key |
| Worker | worker/ |
Workers AI binding, CORS, /api/chat |
Secrets stay off the frontend: the Worker uses the AI binding. Optionally protect the Worker with AI_API_KEY.
- Node.js 20+
- Rust (stable) + Tauri prerequisites
- Cloudflare account (for Worker deploy / remote AI binding)
# Desktop app
npm install
npm run tauri dev
# AI Worker (separate terminal)
cd worker
npm install
npx wrangler login # once
npm run dev # http://127.0.0.1:8787Default AI endpoint: http://127.0.0.1:8787 (override with AI_ENDPOINT).
cd worker
npm run deploy
# optional: npx wrangler secret put AI_API_KEYThen set AI_ENDPOINT to your *.workers.dev URL before starting Tauri.
Desktop accounts live in D1 database nodes-users (binding DB) — separate from the website’s qubrain-users. On each OAuth login the Worker upserts the user and keeps their plan (free | pro | supporter | champion). Sessions stay in KV Nodes Users.
cd worker
npx wrangler d1 migrations apply nodes-users --remoteDesktop login opens the system browser and polls the Worker for a one-time session (no deep link). Register redirect URIs on your existing OAuth apps:
{AUTH_BASE_URL}/auth/callback/google{AUTH_BASE_URL}/auth/callback/github
Set Worker secrets (production) or worker/.dev.vars (local — see worker/.dev.vars.example):
cd worker
npx wrangler secret put GOOGLE_CLIENT_ID
npx wrangler secret put GOOGLE_CLIENT_SECRET
npx wrangler secret put GITHUB_CLIENT_ID
npx wrangler secret put GITHUB_CLIENT_SECRET
npx wrangler secret put AUTH_SECRET
npx wrangler secret put AUTH_BASE_URL # e.g. https://experiment-ai.<account>.workers.devAlso documented in .env.example. The app uses the same base URL as AI_ENDPOINT.
| Script | Description |
|---|---|
npm run dev |
Vite frontend only |
npm run tauri dev |
Full Tauri desktop app |
npm run tauri build |
Production bundle |
npm run worker:dev |
Wrangler local Worker |
npm run worker:deploy |
Deploy Worker |
Processor nodes declare their HTTP target in src/features/canvas/nodes/definitions/nodes.json via a backend block — no settings UI.
backend.kind |
Behavior |
|---|---|
omit / workers-ai |
Default Cloudflare Worker (AI_ENDPOINT + /api/subgen) |
http-subgen |
Same SubGen JSON body/response, POST to url + path |
Example (also shipped as Local SubGen):
"backend": {
"kind": "http-subgen",
"url": "http://127.0.0.1:8000",
"path": "/api/subgen",
"apiKeyEnv": "MY_LOCAL_SUBGEN_KEY"
}Point url at any local Python/Ollama-gateway/etc. server that implements the Worker’s /api/subgen contract. Optional Bearer secrets come from process env names (apiKeyEnv), not the catalog.
- Implement
AiProviderin Rust (src-tauri/src/modules/ai) and/or TypeScript (src/modules/ai/providers). - Register in the factory /
AppState. - Keep UI on
AiClientso features stay provider-agnostic.