Skip to content

Repository files navigation

Experiment

Modular Tauri 2 desktop app (React + TypeScript) with a pluggable AI layer wired for Cloudflare Workers AI.

Architecture

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.

Prerequisites

  • Node.js 20+
  • Rust (stable) + Tauri prerequisites
  • Cloudflare account (for Worker deploy / remote AI binding)

Quick start

# 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:8787

Default AI endpoint: http://127.0.0.1:8787 (override with AI_ENDPOINT).

Deploy the Worker

cd worker
npm run deploy
# optional: npx wrangler secret put AI_API_KEY

Then set AI_ENDPOINT to your *.workers.dev URL before starting Tauri.

Nodes users (D1)

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 --remote

Google / GitHub login (Worker OAuth)

Desktop 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.dev

Also documented in .env.example. The app uses the same base URL as AI_ENDPOINT.

Scripts

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

JSON node backends (external / local servers)

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.

Extending AI providers

  1. Implement AiProvider in Rust (src-tauri/src/modules/ai) and/or TypeScript (src/modules/ai/providers).
  2. Register in the factory / AppState.
  3. Keep UI on AiClient so features stay provider-agnostic.

About

QuBrain node canvas — Tauri 2 desktop app with Cloudflare Workers AI

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages