Skip to content

Project Setup and Build

Relevant source files

The following files were used as context for generating this wiki page:

This page documents the development environment setup, dependency management, build configuration, and development workflow for KanStack. It covers installation of dependencies, running the application in development mode, building for production, and running tests.

For information about the overall architecture and how the build artifacts integrate, see Architecture Overview. For information about the main application entry points and initialization, see Main Application Component and Main Entry Point and Menu System.


Prerequisites

KanStack requires the following tools to be installed:

ToolPurposeMinimum Version
Node.jsFrontend build tooling and package management18.x or higher
npmJavaScript package managerIncluded with Node.js
RustBackend compilation1.70+
CargoRust package manager and build toolIncluded with Rust

The project uses Tauri 2 as the desktop application framework, which bridges the Vue.js frontend with the Rust backend. Tauri's prerequisites (system dependencies for native windowing) are automatically handled by the Tauri CLI during setup.

Sources: package.json:1-29, src-tauri/Cargo.toml:1-27


Dependency Structure

Frontend Dependencies

The frontend is built with Vue 3 and TypeScript, using Vite as the build tool. The dependency structure is defined in package.json.

Key Frontend Dependencies:

PackageVersionPurpose
vue^3.5.13Core UI framework, Composition API
@tauri-apps/api^2IPC bridge for invoking Rust commands
@tauri-apps/plugin-dialog^2Native file/folder picker dialogs
yaml^2.8.1YAML parsing for settings blocks
vite^5.4.14Fast development server and build tool
typescript^5.7.2Static type checking
vue-tsc^2.1.10Vue-aware TypeScript compiler
vitest^3.2.4Unit testing framework

Sources: package.json:15-28


Backend Dependencies

The backend is written in Rust and uses the Tauri 2 framework. Dependencies are managed by Cargo in Cargo.toml.

Key Backend Dependencies:

CrateVersionPurpose
tauri2Desktop application framework
tauri-plugin-dialog2Native folder picker integration
serde1Serialization/deserialization framework
serde_json1JSON parsing for settings blocks
serde_yaml0.9YAML parsing for frontmatter
notify6File system change notifications
trash5Cross-platform file deletion to trash
tauri-build2Build-time code generation

Sources: src-tauri/Cargo.toml:8-18


Build Scripts and Commands

KanStack provides several npm scripts for different development and build tasks. All commands are defined in package.json and should be executed from the project root.

Available Commands

Command Reference:

CommandDescriptionUse Case
npm run devStart Vite development server onlyFrontend development without Tauri
npm run tauri:devStart full Tauri development environmentFull application development
npm run buildType-check and build frontend to dist/Frontend build only
npm run tauri:buildBuild complete application binaryProduction release
npm testRun Vitest test suiteExecute unit tests
npm run previewPreview production build locallyTest production build
npm run tauriDirect access to Tauri CLIAdvanced Tauri operations

Sources: package.json:6-13


Development Workflow

Starting Development Mode

The primary development workflow uses the tauri:dev command:

bash
npm run tauri:dev

This command orchestrates the following sequence:

What Happens During tauri:dev:

  1. Tauri CLI reads configuration from src-tauri/tauri.conf.json
  2. Frontend dev server starts via beforeDevCommand (src-tauri/tauri.conf.json:7)
  3. Rust backend compiles using development profile (src-tauri/Cargo.toml:20-21)
    • Incremental compilation enabled for faster rebuilds
  4. Application window launches with dimensions from config (src-tauri/tauri.conf.json:17-18)
  5. File watchers activate:
    • Vite watches for frontend changes (HMR)
    • Cargo watches for backend changes (automatic rebuild)

Sources: src-tauri/tauri.conf.json:6-11, src-tauri/Cargo.toml:20-21, package.json:12


Frontend-Only Development

For rapid frontend iteration without the Tauri backend:

bash
npm run dev

This starts only the Vite development server. Tauri API calls will fail, but this is useful for:

  • UI component development
  • Layout adjustments
  • CSS styling
  • Testing mock data flows

The dev server runs at http://localhost:1420 by default and provides:

  • Hot Module Replacement (HMR)
  • Fast refresh for Vue components
  • Source maps for debugging
  • TypeScript error reporting

Sources: package.json:7


Testing

KanStack uses Vitest for unit testing. Tests are primarily located in the frontend codebase for parsing and serialization utilities.

Running Tests

bash
npm test

This executes vitest run, which runs all test files matching the pattern **/*.test.ts.

Test Organization:

Vitest provides:

  • Fast execution with intelligent test filtering
  • TypeScript support without additional configuration
  • Compatible API with Jest
  • Watch mode available during development

For watch mode during development:

bash
npx vitest

Sources: package.json:9, package.json:26


Production Build Pipeline

Building for production creates optimized, standalone application binaries for distribution.

Building the Application

bash
npm run tauri:build

This command executes a multi-stage build process:

Build Pipeline Stages:

  1. Frontend Type Checking

    • vue-tsc --noEmit validates TypeScript types (package.json:8)
    • Build fails if type errors are found
    • No output generated (--noEmit flag)
  2. Frontend Build

  3. Backend Compilation

    • cargo build --release compiles Rust with optimizations (src-tauri/Cargo.toml:23-26)
    • Optimization level 3: Maximum performance optimization
    • Link-Time Optimization (LTO): Cross-crate optimization
    • Symbol stripping: Reduces binary size
  4. Application Bundling

    • Tauri packages the frontend and backend together
    • Platform-specific installers created (DMG for macOS, MSI for Windows, etc.)
    • Resources bundled according to config (src-tauri/tauri.conf.json:32-34)

Build Configuration:

SettingValuePurpose
beforeBuildCommandnpm run buildFrontend build before bundling
frontendDist../distLocation of built frontend assets
opt-level3Maximum Rust optimization
ltotrueLink-time optimization enabled
striptrueRemove debug symbols

Sources: package.json:8,13, src-tauri/tauri.conf.json:6-10, src-tauri/Cargo.toml:23-26


Project Entry Points

Understanding where execution begins helps navigate the codebase and debug issues.

Frontend Entry Points

Frontend Initialization Flow:

  1. HTML Entry Point (index.html:1-12)

    • Defines <div id="app"></div> mount target
    • Loads TypeScript module at /src/main.ts
  2. TypeScript Entry Point (src/main.ts:1-6)

    • Imports Vue's createApp function
    • Imports root App.vue component
    • Creates Vue application instance
    • Mounts to #app DOM element
  3. Root Component (App.vue)

    • Initializes all composables (see Composables Overview)
    • Sets up keyboard shortcuts and event handlers
    • Renders main application UI

Sources: index.html:1-12, src/main.ts:1-6


Backend Entry Point

Backend Initialization Flow:

  1. Main Function (src-tauri/src/main.rs)

    • Creates Tauri application builder
    • Registers command handlers for IPC
    • Sets up application menu
    • Starts event loop
  2. Command Registration

    • Workspace commands: load_workspace, save_board_file, etc.
    • Card commands: create_card, save_card_file, etc.
    • Board commands: create_board, delete_board, etc.
    • Watcher commands: watch_workspace, unwatch_workspace
  3. Event Loop

    • Handles IPC invoke calls from frontend
    • Processes menu action events
    • Manages window lifecycle

Sources: src-tauri/src/main.rs (referenced from context)


Configuration Files

The project's behavior is controlled by several configuration files:

FilePurposeKey Settings
package.jsonFrontend dependencies and scriptsScripts, dependency versions
src-tauri/Cargo.tomlBackend dependencies and build configRust dependencies, optimization profile
src-tauri/tauri.conf.jsonTauri application configurationWindow settings, build commands, bundle config
vite.config.tsVite build configurationBuild options, plugins (not shown in provided files)
tsconfig.jsonTypeScript compiler optionsType checking rules (not shown in provided files)

Sources: package.json:1-29, src-tauri/Cargo.toml:1-27, src-tauri/tauri.conf.json:1-36


Common Development Tasks

Adding a New Frontend Dependency

bash
npm install <package-name>
npm install -D <dev-package-name>  # For dev dependencies

Dependencies are automatically added to package.json.

Adding a New Backend Dependency

Edit src-tauri/Cargo.toml and add to the [dependencies] section:

toml
[dependencies]
new-crate = "version"

Run npm run tauri:dev to fetch and compile the new dependency.

Updating Dependencies

bash
# Update frontend dependencies
npm update

# Update backend dependencies
cd src-tauri
cargo update
cd ..

Clearing Build Cache

bash
# Clear Vite cache
rm -rf node_modules/.vite

# Clear Rust build cache
rm -rf src-tauri/target

# Clear Node modules (full reinstall)
rm -rf node_modules
npm install

Sources: package.json:1-29, src-tauri/Cargo.toml:1-27