Skip to content

Architecture

revil-O edited this page Oct 21, 2026 · 2 revisions

Architecture

VulKara is an Electron app with three Python engines. The app itself holds no model code: it plans, queues, checks and shows; the engines compute.

flowchart LR
    subgraph App["VulKara (Electron)"]
        R["Pages (Vue 3, renderer)"] -- "typed API (preload, invoke only)" --> M["Main process (TypeScript)"]
        M --> Q["Job queue · one job at a time"]
        M --> I["Import queue"]
        M --> F["File access · settings · keychain"]
    end
    Q -- "JSON lines (protocol v2)" --> D["Diffusers engine (PyTorch, Metal)"]
    Q -- "JSON lines" --> X["MLX engine (mflux)"]
    Q -- "JSON lines" --> C["ComfyUI engine"]
    C -- "HTTP + key" --> CU["ComfyUI (background process)"]
    D --> CF["Content filter"]
    I --> D
Loading
Part Where What it does
Pages src/renderer (Vue 3, Pinia, vue-router) Forms, galleries, the canvas, the editors. They talk only through window.vk.
Preload src/preload The typed API (contextBridge, ipcRenderer.invoke); file paths only from the File object of a drop.
Main process src/main Windows, settings, the job and import queues, runtimes, engines, the history, file access, the content guard.
Diffusers engine engines/diffusers Most models, the importer, LoRAs, ControlNet, Restore, the photo tools, the content filter, training.
MLX engine engines/mlx FLUX, Z-Image, Krea 2 and Ideogram 4 via mflux.
ComfyUI engine engines/comfy Video (Wan 2.2), Anima, upscaling; builds ComfyUI graphs and talks to a locked ComfyUI.
Remote web UI src/main/remote_server.ts + src/renderer Optional: serves the same pages to a browser on the local network, behind a token. No extra dependency — Node's built-in http.

A job

  1. A page builds a job (prompt, model, size, steps, …) and adds it to the queue in the main process. Jobs keep running when you switch pages, and run one at a time because all engines share the unified memory.
  2. The prompt check and the consent question run first.
  3. The main process picks the engine for the model (or the runtime the user prefers), starts it if needed and sends the job as one JSON line.
  4. The engine plans the memory, loads or reuses the model, computes, and reports progress and the result as JSON lines.
  5. The content filter checks the result; only then the page shows it, the history keeps it and the EU label is put in when asked.

The pipelines of every page, with diagrams: How the pipelines work.

Models on disk

Every model is a folder with a model.json manifest: its architecture, family, layout (a diffusers repository, a single checkpoint, a GGUF denoiser, ComfyUI files), its parts and their sizes, the memory plan, defaults and licence. LoRAs have a lora.json with their family, sub-base and trigger words. The importer writes them when a model comes from Hugging Face, Civitai, a file or a folder.

Remote access (optional)

Settings → Remote access serves the same renderer to a browser on the local network, so jobs can be started and watched from a phone or tablet. A browser has no preload bridge, so a tiny HTTP server mirrors it: the renderer's generic call() becomes POST /ipc, its on() becomes a Server-Sent-Events stream (/events), and the pictures the app may show come from /file. Everything carries a random access token.

  • No new dependency. The server is Node's built-in http — no framework, no package. In the browser, remote_vk.ts swaps window.vk for the same calls over HTTP and EventSource.
  • Allowlist, not denylist. Only the window-independent channels for generating and watching are reachable (src/main/remote_channels.ts). Native things — changing settings, file dialogs, installing models and runtimes, training, the logs — stay on the Mac.
  • File access. /file hands out only paths the app already granted (allowedMedia: absolute, a media type, resolved through symlinks with realpath, and on the file-access allowlist).
  • Off by default, bound to the local network, HTTPS with a certificate authority of the Mac's own. More in Privacy and safety.

Building and testing

Developer guide has the stack, the layout of the repository, the engine protocol, the manifests, the test instance, migrations, adding an architecture, security, the release and the clean check. Tests: npm run typecheck, npx vitest run, and python -m pytest in engines/diffusers.

Clone this wiki locally