Architecture

Vektory follows Electron’s three-process model with a strict security boundary: the renderer is sandboxed — it has no access to Node, the file system, or raw IPC. All capabilities are exposed through a single typed bridge.


Containers

Vektory architecture — Designer interacts with the Renderer process; the Preload script is the only bridge between Renderer and Main; Main owns Sharp, Potrace, and all file system access

See ADR 0002 · ADR 0001


Conversion flow

sequenceDiagram
    actor User
    participant UI as Renderer (React)
    participant Store as Zustand Store
    participant Bridge as Preload
    participant Main as Main Process
    participant Sharp
    participant Potrace

    User->>UI: Drop PNG / select file
    UI->>Store: setSelectedFiles()
    Store-->>UI: currentFile updated
    Note over UI: 500 ms debounce
    UI->>Bridge: electronAPI.convertPngToSvg(path, options)
    Bridge->>Main: ipcRenderer.invoke('convert-png-to-svg')
    Main->>Sharp: flatten → greyscale → threshold
    Sharp-->>Main: Buffer
    Main->>Potrace: trace(buffer, options)
    Potrace-->>Main: SVG path data
    Main->>Main: pathBounds() — cubic Bezier extrema
    Main-->>Bridge: svgContent
    Bridge-->>UI: svgContent
    UI->>UI: sanitizeSvg() — DOMPurify
    UI->>Store: setCurrentSvg(sanitized)
    Note over Store: cache[path] = { svg, options }
    UI->>UI: svgContainer.innerHTML = svg

See ADR 0008 · ADR 0010


Batch export

sequenceDiagram
    actor User
    participant UI as Renderer
    participant Bridge as Preload
    participant Main as Main Process
    participant FS as File System

    User->>UI: Export All SVGs
    UI->>Bridge: electronAPI.batchConvertAndSave(paths, optionsArray)
    Bridge->>Main: ipcRenderer.invoke('batch-convert-and-save')
    loop groups of 5
        Main->>Main: Promise.all(group.map(convertPngToSvg))
        Main->>FS: write SVG files
    end
    Main-->>Bridge: BatchConversionResult[]
    Bridge-->>UI: results
    UI->>UI: show summary

See ADR 0009


State model

useAppStore — conversion options, file list, SVG cache, theme, editor visibility.

usePreviewStore — independent ViewState (zoom, pan) for the SVG view and the Original view.

See ADR 0007 · ADR 0011


Build pipeline

Process Tool Output
Main process tsc dist/main/
Renderer Vite dist/renderer/
Dev orchestration concurrently + wait-on Electron starts after Vite server is ready

Main process changes require a full Electron restart. Renderer-only changes benefit from Vite HMR.

See ADR 0004