Architecture & Crates

Veyak is architected as a modern, high-performance desktop application leveraging Tauri 2, a modular Rust Cargo workspace, and React 19.


Architectural Overview

┌─────────────────────────────────────────────────────────────┐
│                      React 19 Frontend                      │
│   (Vite + Tailwind CSS 4 + Zustand Stores + Monaco Editor)   │
└──────────────────────────────┬──────────────────────────────┘
                               │  Tauri 2 IPC (invoke / events)
┌──────────────────────────────▼──────────────────────────────┐
│                    Tauri 2 Core (src-tauri)                 │
│         Command Handlers, Lifecycle & Window Management     │
└──────────┬─────────────┬─────────────┬─────────────┬────────┘
           │             │             │             │
┌──────────▼────┐ ┌──────▼─────┐ ┌─────▼─────┐ ┌─────▼───────┐
│   veyak-grpc  │ │  veyak-auth│ │  veyak-db │ │ veyak-models│
│  Reflection   │ │ PKCE OAuth │ │ YAML Store│ │ ts-rs Types │
│  & Streaming  │ │  & Loopback│ │Persistence│ │ & Schemas   │
└───────────────┘ └────────────┘ └───────────┘ └─────────────┘

                                                veyak-error
                                             (Centralized Errors)

Modular Rust Crates

The backend is decomposed into 5 specialized crates located in the crates/ directory:

1. crates/veyak-models

The source of truth for all domain data structures.

  • Defines models for ApiRequest, ApiResponse, Collection, Workspace, Environment, HistoryEntry, AppSettings, GrpcRequest, and GrpcService.
  • Uses ts-rs to automatically generate synchronized TypeScript interface bindings (models.ts) directly from Rust structs during compilation.

2. crates/veyak-grpc

The engine powering gRPC communication.

  • Implements Server Reflection (grpc_reflect) using dynamic protobuf descriptors.
  • Handles compilation of offline .proto files and import search paths.
  • Provides dynamic message encoding and decoding between JSON and binary Protobuf formats.
  • Executes Unary, Server Streaming, Client Streaming, and Bidirectional Streaming calls over Tokio and HTTP/2 transport.

3. crates/veyak-auth

Authentication & PKCE OAuth 2.0 flow:

  • Generates cryptographically secure PKCE verifiers, challenges, and state parameters.
  • Integrates with tauri-plugin-oauth to launch a temporary local loopback web server for capturing OAuth redirects.
  • Securely stores authentication tokens and user profile information.

4. crates/veyak-db

The zero-dependency persistence layer:

  • Stores workspaces, collections, requests, environments, settings, and history as structured YAML files inside the platform-specific application data directory (~/.local/share/veyak, ~/Library/Application Support/veyak, or %APPDATA%\veyak).
  • Fast, human-readable, and version-control friendly.

5. crates/veyak-error

Centralized error handling:

  • Built with thiserror.
  • Provides a unified AppError and AppResult<T> type mapped directly across the Tauri boundary with friendly user-facing messages.

Desktop Core (src-tauri)

The src-tauri package orchestrates the desktop experience:

  • HTTP Engine (src-tauri/src/http.rs) — Uses reqwest with Tokio async runtime. Requests originate directly from the Rust process, bypassing browser CORS restrictions entirely.
  • WebSocket Engine (src-tauri/src/ws.rs) — Manages long-lived WebSocket connections with tokio-tungstenite, routing sent and received frames to frontend event listeners.
  • System Fonts (src-tauri/src/commands/fonts.rs) — Scans installed OS fonts with font-kit for seamless UI customisation.
  • Plugins & Updaters — Includes tauri-plugin-updater, tauri-plugin-dialog, and tauri-plugin-process.

Frontend Architecture (src)

The user interface is built with:

  • React 19 & Vite — Blazing-fast hot module reloading and rendering.
  • Tailwind CSS 4 — Modern token-based styling.
  • Monaco Editor — The code editor powering VS Code, used for JSON and GraphQL payloads.
  • Zustand State Stores:
    • workspaceStore — Manages workspaces, nested collection trees, folders, and environments.
    • vartaStore — Controls active tabs, in-flight requests, WebSocket streams, and gRPC status.
    • settingStore — Manages user preferences, font sizes, proxies, and typography.
    • authStore — Handles user profile state and login sessions.

Building & Type Generation

When updating backend models, TypeScript types can be exported automatically:

# Generate TypeScript definitions from Rust structs
cargo test -p veyak-models

This ensures full compile-time type safety across both Rust and React layers.