### Bundle Windows installer Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/02-repo-tooling.md Run `pnpm win:bundle` to produce `EatSeeTira_0.1.0_x64-setup.exe` in Windows Downloads. Then run the installer on Windows; the installed app starts from the Start menu and shows the heading. ```sh pnpm win:bundle # EatSeeTira_0.1.0_x64-setup.exe appears in Windows Downloads ``` -------------------------------- ### Build Windows installer Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/00-conventions.md Builds the Windows installer in WSL for installation on Windows. ```bash pnpm win:bundle ``` -------------------------------- ### Setup overview diagram: WSL and Windows workflow Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/01-prerequisites.md ASCII diagram showing the development workflow between WSL and Windows. WSL handles editing, building, and testing, while Windows runs the app and installer. The diagram maps commands like pnpm dev, cargo test, pnpm win:dev, and pnpm win:bundle to their targets on Windows. ```text WSL (Debian/Ubuntu) Windows ─────────────────────────────────────────── ──────────────────────────────────── editor, git, pnpm, cargo WebView2 (built into Windows 10/11) pnpm dev → Vite on 127.0.0.1:1420 ◄───────── browser (mock data), or the cargo test / clippy (Linux build) Windows debug app (real Rust + SQLite) pnpm win:dev → builds eatseetira-app.exe ───────► %LOCALAPPDATA%\EatSeeTira-dev\ and starts it pnpm win:bundle → builds the NSIS installer ───────► %USERPROFILE%\Downloads\, install and test git push → GitHub Actions on windows-latest: every test, built and run on Windows ``` -------------------------------- ### Install fnm, Node 26.13.0, and pnpm Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/01-prerequisites.md Install fnm if missing, install Node 26.13.0, and install pnpm globally if missing. The repo pins Node via .node-version and pnpm via packageManager; no global change to other projects. ```sh curl -fsSL https://fnm.vercel.app/install | bash # only if fnm is missing; then open a new terminal fnm install 26.13.0 # adds 26 next to your other versions; the default is unchanged npm install -g pnpm # only if pnpm is missing (any 10+) ``` -------------------------------- ### src/test/setup.ts - Testing setup for jest-dom Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/02-repo-tooling.md Setup file for Vitest that imports jest-dom matchers. ```ts import '@testing-library/jest-dom/vitest'; ``` -------------------------------- ### Run frontend dev server with mock data Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/00-conventions.md Starts the frontend dev server in WSL, accessible from a Windows browser at http://127.0.0.1:1420. ```bash pnpm dev ``` -------------------------------- ### Install Rust and cargo-xwin Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/01-prerequisites.md Install Rust with no default toolchain, load the environment, and install cargo-xwin 0.23.1. The repo's rust-toolchain.toml will download Rust 1.99.1 and the x86_64-pc-windows-msvc target automatically on first build. ```sh curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain none . "$HOME/.cargo/env" cargo install --locked cargo-xwin@0.23.1 ``` -------------------------------- ### Install system packages for Tauri and Windows cross-compilation Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/01-prerequisites.md Install build-essential, Tauri dependencies, and Windows cross-compiler tools. Line 2 lets the Tauri crate compile for Linux; line 3 provides clang-cl, lld-link, llvm-lib, llvm-rc, and NSIS installer builder. ```sh sudo apt update sudo apt install -y build-essential curl wget file git pkg-config libssl-dev \ libwebkit2gtk-4.1-dev libxdo-dev libayatana-appindicator3-dev librsvg2-dev \ clang clang-tools lld llvm nsis rsync ``` -------------------------------- ### Install Rust via winget and set default toolchain Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/01-prerequisites.md Run in PowerShell on a Windows-only development machine. Installs Rustup and sets the stable MSVC toolchain as default. ```powershell winget install --id Rustlang.Rustup -e ``` ```powershell rustup default stable-x86_64-pc-windows-msvc ``` -------------------------------- ### Verify Part A setup in new WSL terminal Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/01-prerequisites.md Run these commands in a new WSL terminal to confirm all prerequisites: pwd, rustup, cargo xwin, clang-cl, lld-link, makensis, node, pnpm, git config, and cmd.exe /c ver. ```sh pwd # /home//code/EatSeeTira (not /mnt/c/...) rustup --version cargo xwin --version # 0.23.1 clang-cl --version lld-link --version makensis -VERSION cd ~/code/EatSeeTira node --version # v26.13.0 (from .node-version), and `command -v node` is not under /mnt/c pnpm --version # 12.17.0 (from packageManager) git config core.autocrlf # false cmd.exe /c ver # prints the Windows version (WSL can start Windows programs) ``` -------------------------------- ### Build Windows NSIS installer from WSL (scripts/win-bundle.sh) Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/02-repo-tooling.md Builds the Windows release installer with pnpm tauri build using cargo-xwin and copies the resulting -setup.exe to the Windows Downloads folder. Runs only in WSL; cross-compiling supports NSIS only, not MSI. ```bash #!/usr/bin/env bash # WSL only. Build the Windows NSIS installer and copy it to %USERPROFILE%\Downloads. set -euo pipefail TARGET=x86_64-pc-windows-msvc if ! command -v cmd.exe >/dev/null 2>&1; then echo "win:bundle runs only in WSL. On Windows use: pnpm tauri build" >&2 exit 1 fi # Cross-compiling can only make NSIS installers (MSI needs WiX, which runs only on Windows). pnpm tauri build --runner cargo-xwin --target "$TARGET" --bundles nsis WIN_PROFILE=$(cd /mnt/c && cmd.exe /c "echo %USERPROFILE%" | tr -d '\r') DOWNLOADS="$(wslpath "$WIN_PROFILE")/Downloads" for f in target/"$TARGET"/release/bundle/nsis/*-setup.exe; do cp "$f" "$DOWNLOADS/" echo "Copied $(wslpath -w "$DOWNLOADS/$(basename "$f")")" done ``` -------------------------------- ### Pattern for every command (complete_sale example) Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/05-tauri-app.md Template for all Tauri commands. Uses eatseetira_core, eatseetira_db, tauri::State, and crate error/guard/state. Guards with Feature::PosCore, acquires a DB connection, and calls the repository without awaiting while holding the connection. ```rust use eatseetira_core::{Feature, SaleRequest}; use eatseetira_db::sale_repo::{self, SaleReceipt}; use tauri::State; use crate::{error::AppError, guard, state::AppState}; #[tauri::command] #[specta::specta] pub async fn complete_sale( state: State<'_, AppState>, request: SaleRequest, ) -> Result { guard::require(&state.features, Feature::PosCore)?; let mut conn = state.db()?; // No `.await` anywhere in a command while `conn` is held. Ok(sale_repo::complete_sale(&mut conn, &state.ctx, &request, chrono::Utc::now())?) } ``` -------------------------------- ### Install Node.js 26.13.0 via fnm and pnpm Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/01-prerequisites.md Run in PowerShell on a Windows-only development machine. Installs fnm, then Node.js 26.13.0 (selected by the repo's .node-version), then pnpm globally. pnpm switches itself to the packageManager version. ```powershell winget install --id Schniz.fnm -e ``` ```powershell fnm install 26.13.0 ``` ```powershell npm install -g pnpm ``` -------------------------------- ### Install exact dependency versions with pnpm Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/02-repo-tooling.md Installs runtime and development dependencies with exact versions (no caret ranges) as required by ADR-0019. The first command adds React and Tauri API; the second adds development tools. After installation, verify that package.json contains no '^' prefixes. ```sh pnpm add react@19.3.1 react-dom@19.3.1 @tauri-apps/api@2.12.4 ``` ```sh pnpm add -D @tauri-apps/cli@2.12.4 vite@8.3.5 @vitejs/plugin-react@6.1.2 typescript@6.0.3 @types/react@19.3.0 @types/react-dom@19.3.0 @types/node@26.6.6 tailwindcss@4.3.3 @tailwindcss/vite@4.3.3 vitest@5.0.5 jsdom@30.1.3 @testing-library/react@16.3.3 @testing-library/jest-dom@7.0.1 @testing-library/user-event@14.6.8 eslint@10.14.0 @eslint/js@10.0.1 typescript-eslint@8.72.1 eslint-plugin-react-hooks@7.1.1 globals@17.14.0 prettier@3.9.10 ``` -------------------------------- ### Start temporary HTTP server for networking check Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/01-prerequisites.md Run a temporary Python HTTP server on port 1420 bound to 127.0.0.1. Stop with Ctrl+C. A Windows browser should show a directory listing at http://127.0.0.1:1420. ```sh cd ~ && python3 -m http.server 1420 --bind 127.0.0.1 # temporary test server; stop with Ctrl+C ``` -------------------------------- ### GitHub Actions workflow ci.yml Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/08-ci.md Copy this workflow exactly into .github/workflows/ci.yml. It runs checks on Windows for every push/PR and builds a Windows installer from main. The 'installer' job runs only on non-PR events and uploads the NSIS installer artifact. ```yaml name: CI on: push: branches: [main] pull_request: workflow_dispatch: concurrency: group: ci-${{ github.ref }} cancel-in-progress: true jobs: check: runs-on: windows-latest steps: - uses: actions/checkout@v4 - uses: pnpm/action-setup@v4 # reads the version from package.json "packageManager" - uses: actions/setup-node@v4 with: node-version-file: .node-version cache: pnpm - name: Install Rust (version from rust-toolchain.toml) run: rustup show - uses: Swatinem/rust-cache@v2 - name: Install JS dependencies run: pnpm install --frozen-lockfile - name: Web checks (format, lint, types, tests, build) run: pnpm check:web - name: Rust checks (fmt, clippy, tests) run: pnpm check:rust - name: Generated bindings are up to date run: pnpm check:bindings installer: needs: check if: github.event_name != 'pull_request' runs-on: windows-latest steps: - uses: actions/checkout@v4 - uses: pnpm/action-setup@v4 - uses: actions/setup-node@v4 with: node-version-file: .node-version cache: pnpm - name: Install Rust (version from rust-toolchain.toml) run: rustup show - uses: Swatinem/rust-cache@v2 - name: Install JS dependencies run: pnpm install --frozen-lockfile - name: Build Windows installer (NSIS) run: pnpm tauri build --bundles nsis - uses: actions/upload-artifact@v4 with: name: eatseetira-windows-installer path: target/release/bundle/nsis/*-setup.exe retention-days: 14 ``` -------------------------------- ### Start Windows dev server and hot reload Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/02-repo-tooling.md Run `pnpm dev` in WSL Terminal 1, then in Terminal 2 run `pnpm win:dev` to open a Windows window titled 'EatSeeTira'. Edit the heading in `src/App.tsx` and save; the Windows window updates without restart. Undo the edit afterward. ```sh pnpm win:dev # a Windows window titled "EatSeeTira" shows the heading ``` -------------------------------- ### Build and run Windows debug app from WSL (scripts/win-dev.sh) Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/02-repo-tooling.md Builds the Windows debug app with cargo xwin and starts it on Windows. Requires the Vite dev server on 127.0.0.1:1420 and runs only in WSL. Stops any running instance before copying the executable to %LOCALAPPDATA%\EatSeeTira-dev. ```bash #!/usr/bin/env bash # WSL only. Build the Windows debug app and start it on Windows. # Needs the Vite dev server: run `pnpm dev` in another WSL terminal first. set -euo pipefail TARGET=x86_64-pc-windows-msvc EXE=eatseetira-app.exe if ! command -v cmd.exe >/dev/null 2>&1; then echo "win:dev runs only in WSL. On Windows use: pnpm tauri dev" >&2 exit 1 fi if ! curl -fsS -o /dev/null http://127.0.0.1:1420; then echo "Vite is not running on 127.0.0.1:1420. Run 'pnpm dev' in another terminal." >&2 exit 1 fi [ -d dist ] || pnpm build # tauri::generate_context! needs dist/ to exist cargo xwin build -p eatseetira-app --target "$TARGET" WIN_LOCALAPPDATA=$(cd /mnt/c && cmd.exe /c "echo %LOCALAPPDATA%" | tr -d '\r') DEST_DIR="$(wslpath "$WIN_LOCALAPPDATA")/EatSeeTira-dev" mkdir -p "$DEST_DIR" taskkill.exe /IM "$EXE" /F >/dev/null 2>&1 || true # a running exe is locked; stop it first sleep 1 cp "target/$TARGET/debug/$EXE" "$DEST_DIR/$EXE" WIN_EXE=$(wslpath -w "$DEST_DIR/$EXE") # Start-Process detaches cleanly. `cmd.exe /c start "title" "path"` fails through # WSL interop: bash strips the quotes, so `start` treats the title as the program. powershell.exe -NoProfile -Command "Start-Process -FilePath '$WIN_EXE'" echo "Started $WIN_EXE (logs are in its console window)" ``` -------------------------------- ### Keyboard shortcut API in src/lib/shortcuts.ts Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/06-frontend-foundation.md Defines the public API for the keyboard layer. Includes the Shortcut type, useShortcuts hook, useRegisteredShortcuts hook, comboOf normalizer, and installKeyboardLayer installer. Screens register shortcuts via useShortcuts; installKeyboardLayer is called once in main.tsx. ```ts export type Shortcut = { /** Key combo, e.g. 'F9', 'Ctrl+Enter', 'Ctrl+1', 'Escape', '?'. Modifier order: Ctrl+Alt+Shift+Key. */ keys: string; /** What it does, shown in the shortcut list (F1). */ label: string; run: () => void; /** Default false: a combo without Ctrl/Alt, or an F-key, does not fire while focus is in a text field. */ allowInInput?: boolean; }; /** Register shortcuts while the component is mounted. Later registrations win for the same keys. */ export function useShortcuts(shortcuts: Shortcut[]): void; /** Every currently registered shortcut (for the F1 list). */ export function useRegisteredShortcuts(): Shortcut[]; /** Normalise a KeyboardEvent to the `keys` format: Ctrl+Shift+N → 'Ctrl+Shift+N', F9 → 'F9', '?' → '?'. */ export function comboOf(e: KeyboardEvent): string; /** Installs the single window listener. Called once in main.tsx. */ export function installKeyboardLayer(): void; ``` -------------------------------- ### Initial schema migration 0001_init.sql Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/04-db-crate.md Creates the initial database schema for the skeleton and POS slice. Tables marked 'not synced' (settings, stock_balances, outbox, sync_state) never get outbox rows; all other tables have id TEXT PRIMARY KEY and do. This file must never be edited after merging to main; add 0002_*.sql instead. Money is stored as INTEGER centavos (_cents), quantity as INTEGER milli-units (_milli), unit cost as INTEGER micro-centavos per milli-unit (_ucpm), and time as TEXT RFC 3339 UTC. ```sql -- 0001_init.sql — initial schema for the skeleton + POS slice. -- NEVER edit this file after it is merged to main. Add 0002_*.sql instead. -- Conventions: docs/data-model.md and docs/spec/00-conventions.md. -- Money = INTEGER centavos (_cents). Quantity = INTEGER milli-units (_milli). -- Unit cost = INTEGER micro-centavos per milli-unit (_ucpm). Time = TEXT RFC 3339 UTC. -- ───────────── Organization ───────────── CREATE TABLE branches ( id TEXT PRIMARY KEY NOT NULL, code TEXT NOT NULL UNIQUE, name TEXT NOT NULL, created_at TEXT NOT NULL, updated_at TEXT NOT NULL, deleted_at TEXT, version INTEGER NOT NULL DEFAULT 1 ) STRICT; CREATE TABLE devices ( id TEXT PRIMARY KEY NOT NULL, branch_id TEXT NOT NULL REFERENCES branches(id), code TEXT NOT NULL, name TEXT NOT NULL, last_receipt_seq INTEGER NOT NULL DEFAULT 0 CHECK (last_receipt_seq >= 0), created_at TEXT NOT NULL, updated_at TEXT NOT NULL, deleted_at TEXT, version INTEGER NOT NULL DEFAULT 1, UNIQUE (branch_id, code) ) STRICT; CREATE TABLE users ( id TEXT PRIMARY KEY NOT NULL, name TEXT NOT NULL, role TEXT NOT NULL CHECK (role IN ('owner', 'cashier')), pin_hash TEXT, active INTEGER NOT NULL DEFAULT 1 CHECK (active IN (0, 1)), created_at TEXT NOT NULL, updated_at TEXT NOT NULL, deleted_at TEXT, version INTEGER NOT NULL DEFAULT 1 ) STRICT; -- Local key/value settings (JSON values). Not synced. CREATE TABLE settings ( key TEXT PRIMARY KEY NOT NULL, value TEXT NOT NULL, updated_at TEXT NOT NULL ) STRICT; -- ───────────── Catalog ───────────── CREATE TABLE categories ( id TEXT PRIMARY KEY NOT NULL, name TEXT NOT NULL, sort INTEGER NOT NULL DEFAULT 0, active INTEGER NOT NULL DEFAULT 1 CHECK (active IN (0, 1)), -- owner hides a used category; never deleted (BR-14) created_at TEXT NOT NULL, updated_at TEXT NOT NULL, deleted_at TEXT, version INTEGER NOT NULL DEFAULT 1 ) STRICT; CREATE TABLE items ( id TEXT PRIMARY KEY NOT NULL, name TEXT NOT NULL, category TEXT NOT NULL CHECK (category IN ('ingredient', 'addon', 'packaging')), base_unit TEXT NOT NULL CHECK (base_unit IN ('g', 'ml', 'pcs')), low_milli INTEGER NOT NULL DEFAULT 0 CHECK (low_milli >= 0), unit_cost_ucpm INTEGER NOT NULL DEFAULT 0 CHECK (unit_cost_ucpm >= 0), active INTEGER NOT NULL DEFAULT 1 CHECK (active IN (0, 1)), created_at TEXT NOT NULL, updated_at TEXT NOT NULL, deleted_at TEXT, version INTEGER NOT NULL DEFAULT 1 ) STRICT; CREATE TABLE products ( id TEXT PRIMARY KEY NOT NULL, category_id TEXT NOT NULL REFERENCES categories(id), name TEXT NOT NULL, price_cents INTEGER NOT NULL CHECK (price_cents >= 0), active INTEGER NOT NULL DEFAULT 1 CHECK (active IN (0, 1)), -- NULL only for the moment between inserting the product and its first recipe version. current_recipe_version_id TEXT REFERENCES recipe_versions(id), created_at TEXT NOT NULL, updated_at TEXT NOT NULL, deleted_at TEXT, version INTEGER NOT NULL DEFAULT 1 ) STRICT; -- Immutable. Changing a recipe = insert a new version and point products.current_recipe_version_id at it. CREATE TABLE recipe_versions ( id TEXT PRIMARY KEY NOT NULL, product_id TEXT NOT NULL REFERENCES products(id), version_no INTEGER NOT NULL CHECK (version_no >= 1), note TEXT NOT NULL DEFAULT '', created_by TEXT REFERENCES users(id), created_at TEXT NOT NULL, UNIQUE (product_id, version_no) ) STRICT; CREATE TABLE recipe_items ( id TEXT PRIMARY KEY NOT NULL, recipe_version_id TEXT NOT NULL REFERENCES recipe_versions(id), item_id TEXT NOT NULL REFERENCES items(id), qty_milli INTEGER NOT NULL CHECK (qty_milli > 0), UNIQUE (recipe_version_id, item_id) ) STRICT; CREATE TABLE addons ( id TEXT PRIMARY KEY NOT NULL, name TEXT NOT NULL, price_cents INTEGER NOT NULL CHECK (price_cents >= 0), active INTEGER NOT NULL DEFAULT 1 CHECK (active IN (0, 1)), created_at TEXT NOT NULL, updated_at TEXT NOT NULL, deleted_at TEXT, version INTEGER NOT NULL DEFAULT 1 ) STRICT; ``` -------------------------------- ### Edit src-tauri/tauri.conf.json with exact configuration Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/02-repo-tooling.md Edit the generated tauri.conf.json to match exactly. The identifier determines where the database lives on the client's PC (%APPDATA%\com.eatseetira.pos\) and must never be changed after the first install. The offlineInstaller bundles WebView2, adding about 130 MB, so no internet is needed on the client. maximized fills the 1366x768 screen. ```json { "$schema": "https://schema.tauri.app/config/2", "productName": "EatSeeTira", "version": "0.1.0", "identifier": "com.eatseetira.pos", "build": { "frontendDist": "../dist", "devUrl": "http://127.0.0.1:1420", "beforeDevCommand": "pnpm dev", "beforeBuildCommand": "pnpm build" }, "app": { "windows": [ { "label": "main", "title": "EatSeeTira", "width": 1366, "height": 768, "minWidth": 1024, "minHeight": 600, "maximized": true, "resizable": true } ], "security": { "csp": "default-src 'self'; connect-src ipc: http://ipc.localhost; img-src 'self' data:; style-src 'self' 'unsafe-inline'; font-src 'self'", "devCsp": null } }, "bundle": { "active": true, "targets": ["nsis", "msi"], "windows": { "webviewInstallMode": { "type": "offlineInstaller" } }, "icon": [ "icons/32x32.png", "icons/128x128.png", "icons/128x128@2x.png", "icons/icon.icns", "icons/icon.ico" ], "android": { "debugApplicationIdSuffix": ".debug" } } } ``` -------------------------------- ### Run all verification commands Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/02-repo-tooling.md Run these commands in order to verify the repository tooling. The final command launches a quick preview window titled 'EatSeeTira' (WSLg in WSL); close it after checking. ```sh pnpm install pnpm format:check pnpm lint pnpm typecheck pnpm build cargo fmt --all --check cargo clippy --workspace --all-targets -- -D warnings pnpm tauri dev # quick preview: a maximized window titled "EatSeeTira" (WSLg in WSL); close it ``` -------------------------------- ### App component with providers (src/App.tsx) Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/06-frontend-foundation.md Composes AppInfoProvider, SessionProvider, and Shell. In src/main.tsx, call installKeyboardLayer() once before createRoot(...). ```tsx import { AppInfoProvider } from './app/AppInfoContext'; import { SessionProvider } from './app/session'; import { Shell } from './app/Shell'; export function App() { return ( ); } ``` -------------------------------- ### vitest.config.ts - Test configuration merging Vite config Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/02-repo-tooling.md Vitest configuration that merges the base Vite config. Sets jsdom environment, setup file, and test file pattern. ```ts import { defineConfig, mergeConfig } from 'vitest/config'; import viteConfig from './vite.config'; export default mergeConfig( viteConfig, defineConfig({ test: { environment: 'jsdom', setupFiles: ['./src/test/setup.ts'], include: ['src/**/*.test.{ts,tsx}'], }, }), ); ``` -------------------------------- ### Run lint, typecheck, test, build, and Tauri dev Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/07-pos-slice.md Commands to verify the POS slice: lint, typecheck, test, build, and launch the Tauri development app. Run them in order from the project root. ```sh pnpm lint pnpm typecheck pnpm test pnpm build pnpm tauri dev ``` -------------------------------- ### Copy repo from /mnt/c to Linux filesystem Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/01-prerequisites.md Use rsync to copy the repo from /mnt/c to ~/code, excluding node_modules, target, and dist. Then verify git status shows the same branch and changes. ```sh mkdir -p ~/code rsync -a --exclude node_modules --exclude target --exclude dist \ /mnt/c/Users//Documents/Programs/EatSeeTira/ ~/code/EatSeeTira/ cd ~/code/EatSeeTira && git status # same branch and changes as before ``` -------------------------------- ### Run real Windows app in debug mode Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/00-conventions.md Builds in WSL and runs on Windows with hot reload. Requires both commands in sequence. ```bash pnpm dev ``` ```bash pnpm win:dev ``` -------------------------------- ### src/main.tsx - React entry point Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/02-repo-tooling.md Mounts the React app into the #root element. Throws an error if #root is missing. ```tsx import { StrictMode } from 'react'; import { createRoot } from 'react-dom/client'; import { App } from './App'; const root = document.getElementById('root'); if (!root) throw new Error('#root element missing from index.html'); createRoot(root).render( , ); ``` -------------------------------- ### Run Tauri dev preview in WSL Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/00-conventions.md Runs the WSLg preview, not the Windows app. Use only when explicitly targeting the WSL preview. ```bash pnpm tauri dev ``` -------------------------------- ### Run pnpm build and pnpm bindings Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/05-tauri-app.md Commands to build the frontend (dist must exist for the Rust build) and then generate the bindings. ```sh pnpm build # dist/ must exist for the Rust build pnpm bindings ``` -------------------------------- ### Run verification commands for frontend foundation Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/06-frontend-foundation.md Commands to verify the frontend foundation. Run format:check, lint, typecheck, test, build, dev, and optionally tauri dev if task 05 is merged. ```sh pnpm format:check pnpm lint pnpm typecheck pnpm test pnpm build pnpm dev # http://127.0.0.1:1420 in a browser: shell + Stock screen work on mock data pnpm tauri dev # (if task 05 is merged) same, with real data from SQLite ``` -------------------------------- ### lib.rs: Tauri application entry point with Specta bindings Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/05-tauri-app.md Defines the Tauri application's main entry point, registering commands and plugins. Includes a test that regenerates TypeScript bindings; run with `pnpm bindings` and CI fails if the file changes. ```rust mod commands; mod error; mod guard; mod state; use tauri::Manager; use tauri_specta::{Builder, collect_commands}; /// Where generated TypeScript bindings are written (absolute, so the working directory does not matter). pub const BINDINGS_PATH: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../src/api/bindings.ts"); /// Register every command here. Add new commands to this list. pub fn specta_builder() -> Builder { Builder::::new() .commands(collect_commands![ commands::app_info::get_app_info, commands::catalog::get_catalog, commands::stock::get_stock, commands::sale::complete_sale, ]) // Cents/Milli are i64. Values stay far below 2^53, so exporting them as `number` is safe. .dangerously_cast_bigints_to_number() } #[cfg_attr(mobile, tauri::mobile_entry_point)] pub fn run() { let builder = specta_builder(); tauri::Builder::default() // Must be the first plugin: a second launch focuses this window instead of opening the same database twice. .plugin(tauri_plugin_single_instance::init(|app, _args, _cwd| { if let Some(w) = app.get_webview_window("main") { let _ = w.unminimize(); let _ = w.set_focus(); } })) .invoke_handler(builder.invoke_handler()) .setup(move |app| { if cfg!(debug_assertions) { app.handle().plugin( tauri_plugin_log::Builder::default() .level(log::LevelFilter::Info) .build(), )?; } let app_state = state::AppState::init(app.handle())?; app.manage(app_state); Ok(()) }) .run(tauri::generate_context!()) .expect("error while running EatSeeTira"); } #[cfg(test)] mod tests { /// Regenerates src/api/bindings.ts. Run: `pnpm bindings`. CI fails if the file changes. #[test] fn export_bindings() { super::specta_builder() .export( specta_typescript::Typescript::default().header("// @ts-nocheck"), super::BINDINGS_PATH, ) .expect("failed to export TypeScript bindings"); } } ``` -------------------------------- ### Make clang-cl available (Debian versioned name) Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/01-prerequisites.md Debian ships clang-cl only under a versioned name. Create a symlink to the latest version and verify with clang-cl --version. ```sh command -v clang-cl || sudo ln -sf "$(ls /usr/lib/llvm-*/bin/clang-cl | sort -V | tail -1)" /usr/local/bin/clang-cl clang-cl --version ``` -------------------------------- ### Run tests, clippy, and formatting for eatseetira-db Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/04-db-crate.md Commands to verify the eatseetira-db crate: run its tests, run core tests, run clippy with warnings as errors (requires `pnpm build` first if dist/ is missing), and check formatting. ```sh cargo test -p eatseetira-db cargo test -p eatseetira-core cargo clippy --workspace --all-targets -- -D warnings # run `pnpm build` first if dist/ is missing cargo fmt --all --check ``` -------------------------------- ### Initialize Tauri shell with pnpm tauri init Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/02-repo-tooling.md Run from the repo root to generate the src-tauri directory with the specified app name, window title, frontend dist, dev URL, and dev/build commands. If a src-tauri/Cargo.lock is created, delete it because the workspace lockfile is at the root. ```sh pnpm tauri init --ci -A eatseetira -W EatSeeTira -D ../dist -P http://127.0.0.1:1420 --before-dev-command "pnpm dev" --before-build-command "pnpm build" ``` -------------------------------- ### .gitattributes - Normalize line endings and binary files Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/02-repo-tooling.md Sets all text files to LF line endings and marks PNG, ICO, and ICNIS files as binary to prevent corruption. ```gitattributes * text=auto eol=lf *.png binary *.ico binary *.icns binary ``` -------------------------------- ### Register single-instance plugin in src-tauri/src/lib.rs Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/02-repo-tooling.md Add this as the first plugin in the generated lib.rs builder so a second launch focuses the open window instead of opening a second app on the same database. The generated .plugin(...) and .run(...) calls remain unchanged. Task 05 keeps this as the first plugin when it replaces lib.rs. ```rust tauri::Builder::default() .plugin(tauri_plugin_single_instance::init(|app, _args, _cwd| { use tauri::Manager; if let Some(w) = app.get_webview_window("main") { let _ = w.unminimize(); let _ = w.set_focus(); } })) // ...the generated .plugin(...) / .run(...) calls stay as they are ``` -------------------------------- ### AppState struct and init method (state.rs) Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/05-tauri-app.md Defines the Tauri application state with a database connection, device context, license, features, and demo-data flag. The init method initializes the state by creating the app data directory, opening the database, ensuring initialization, optionally seeding demo data in debug builds, loading the license, and resolving features. An invalid license stops the app with an error. ```rust pub struct AppState { db: std::sync::Mutex, pub ctx: eatseetira_db::DeviceContext, pub license: eatseetira_core::License, pub features: eatseetira_core::FeatureSet, pub is_demo_data: bool, } impl AppState { pub fn init(app: &tauri::AppHandle) -> Result>; /// Lock the database. A poisoned lock → AppError Internal. pub fn db(&self) -> Result, AppError>; } ``` -------------------------------- ### Build and Test Commands Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/05-tauri-app.md Run these commands to build the project, run tests, lint, format, and check bindings. The bindings command should produce no diff after a second run. ```sh pnpm build cargo test --workspace cargo clippy --workspace --all-targets -- -D warnings cargo fmt --all --check pnpm bindings; git diff --exit-code src/api/bindings.ts # no diff after a second run pnpm dev # terminal 1 (keep running) pnpm win:dev # terminal 2: the real Windows app (Windows-only machine: pnpm tauri dev) ``` -------------------------------- ### Create package.json for EatSeetira Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/02-repo-tooling.md Defines the Node project metadata, scripts, and package manager for the EatSeetira application. Uses pnpm 12.17.0 and sets the module type to ESM. Includes scripts for development, building, testing, linting, formatting, and Windows-specific tasks. ```json { "name": "eatseetira", "private": true, "version": "0.1.0", "type": "module", "packageManager": "pnpm@12.17.0", "scripts": { "dev": "vite", "build": "vite build", "preview": "vite preview", "tauri": "tauri", "typecheck": "tsc --noEmit", "lint": "eslint .", "format": "prettier --write .", "format:check": "prettier --check .", "test": "vitest run", "test:watch": "vitest", "win:dev": "bash scripts/win-dev.sh", "win:bundle": "bash scripts/win-bundle.sh" } } ``` -------------------------------- ### index.html - Frontend entry HTML Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/02-repo-tooling.md The root HTML file for the Vite frontend. Contains the #root div and loads the main TypeScript module. ```html EatSeeTira
``` -------------------------------- ### rust-toolchain.toml - Pin Rust toolchain and targets Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/02-repo-tooling.md Pins Rust 1.99.1 with rustfmt and clippy components. Adds the Windows MSVC target for cargo xwin in WSL; on Windows this line is a no-op. ```toml [toolchain] channel = "1.99.1" components = ["rustfmt", "clippy"] targets = ["x86_64-pc-windows-msvc"] profile = "minimal" ``` -------------------------------- ### catalog_repo.rs: load_catalog function signature Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/04-db-crate.md Loads all non-deleted categories, products (with current recipe), add-ons (with recipe) and items. Sorted by category sort then name; add-ons and items by name. Applies deleted_at IS NULL filter on every table, only active categories, and returns DbError::Invariant for missing current recipe or unknown text enums. ```rust /// All non-deleted categories, products (with current recipe), add-ons (with recipe) and items. /// Sorted: categories by sort then name; products by category sort then name; add-ons and items by name. pub fn load_catalog(conn: &Connection) -> Result; ``` -------------------------------- ### Import index.css in src/main.tsx Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/06-frontend-foundation.md Add this import as the first import in src/main.tsx to load the global styles and design tokens. ```tsx import './index.css'; ``` -------------------------------- ### Runtime Invocation Checks Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/05-tauri-app.md Use these commands in the running Windows app's devtools console to verify app info and catalog data. Expect package "basic" and is_demo_data true for get_app_info, and 12 products for get_catalog. ```js await window.__TAURI_INTERNALS__.invoke('get_app_info') // package "basic", is_demo_data true await window.__TAURI_INTERNALS__.invoke('get_catalog') // 12 products ``` -------------------------------- ### License struct Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/03-core-crate.md Represents a license with a package and a list of addon features. Stored in settings key `license` as JSON. ```APIDOC ## License struct ### Description Represents a license with a package and a list of addon features. Stored in settings key `license` as JSON. ### Fields - `package` (Package) - The base package tier. - `addons` (Vec) - Additional features beyond the package. ### Methods - `resolve(&self) -> Result` - Resolves the license to a FeatureSet. Includes all features of the package (every feature whose min_package <= package) plus addons. Then checks every enabled feature's `requires()`; the first missing one returns `Err(CoreError::MissingDependency { feature, requires })`. ### Example JSON ```json {"package":"basic","addons":["pos.qr"]} ``` ``` -------------------------------- ### src/connection.rs — open, open_in_memory, and pragmas Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/04-db-crate.md Provides open() to open or create a database file, apply pragmas, and run migrations; open_in_memory() for tests. The caller must back up first if migrations::has_pending. apply_pragmas sets WAL journal mode, FULL synchronous, foreign_keys ON, and busy_timeout 5000. ```rust use std::path::Path; use rusqlite::Connection; use crate::{DbError, migrations}; /// Open (or create) the database file, apply pragmas and run migrations. /// The caller is responsible for backing up first if `migrations::has_pending` (see backup.rs). pub fn open(path: &Path) -> Result { let mut conn = Connection::open(path)?; apply_pragmas(&conn)?; migrations::run(&mut conn)?; Ok(conn) } /// In-memory database for tests. pub fn open_in_memory() -> Result { let mut conn = Connection::open_in_memory()?; apply_pragmas(&conn)?; migrations::run(&mut conn)?; Ok(conn) } fn apply_pragmas(conn: &Connection) -> Result<(), DbError> { // WAL: readers don't block the writer. FULL: a committed sale survives a brownout (ADR-0003). // journal_mode returns a row, so it needs the `_and_check` variant. let _mode: String = conn.pragma_update_and_check(None, "journal_mode", "WAL", |r| r.get(0))?; conn.pragma_update(None, "synchronous", "FULL")?; conn.pragma_update(None, "foreign_keys", "ON")?; conn.pragma_update(None, "busy_timeout", 5000)?; Ok(()) } ``` -------------------------------- ### .editorconfig - Consistent editor settings Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/02-repo-tooling.md Defines UTF-8, LF, 2-space indentation, and final newline for all files. Overrides indentation to 4 spaces for Rust and disables trailing whitespace trimming for Markdown. ```ini root = true [*] charset = utf-8 end_of_line = lf insert_final_newline = true indent_style = space indent_size = 2 trim_trailing_whitespace = true [*.rs] indent_size = 4 [*.md] trim_trailing_whitespace = false ``` -------------------------------- ### Run core crate checks Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/03-core-crate.md Run tests, clippy, and formatting checks for the eatseetira-core crate. The commands must pass before the task is considered done. ```sh cargo test -p eatseetira-core cargo clippy -p eatseetira-core --all-targets -- -D warnings cargo fmt --all --check ``` -------------------------------- ### src/context.rs — DeviceContext struct Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/04-db-crate.md Defines DeviceContext, which holds branch, device, user, and business information. It is loaded once at startup by bootstrap::ensure_initialized. ```rust use eatseetira_core::{BranchId, DeviceId, UserId}; /// Who/where is writing. Loaded once at startup by `bootstrap::ensure_initialized`. #[derive(Debug, Clone, PartialEq, Eq)] pub struct DeviceContext { pub branch_id: BranchId, pub branch_code: String, pub branch_name: String, pub device_id: DeviceId, pub device_code: String, /// Basic package: the single owner. Later: the logged-in user. pub user_id: UserId, pub user_name: String, pub business_name: String, pub utc_offset_minutes: i32, } ``` -------------------------------- ### Add mirrored networking to .wslconfig Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/01-prerequisites.md If the Windows browser cannot reach the WSL server, add these lines to %USERPROFILE%\.wslconfig on Windows, then run wsl --shutdown in PowerShell and test again. ```ini [wsl2] networkingMode=mirrored ``` -------------------------------- ### Update WSL and check version (PowerShell) Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/01-prerequisites.md Run once in PowerShell to update WSL to version 2.x and verify WSLg is included. Use a Debian 12+/13 or Ubuntu 24.04 distro. ```powershell wsl --update wsl --version # WSL 2.x; WSLg is included ``` -------------------------------- ### Replace src-tauri/src/main.rs with minimal entry point Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/02-repo-tooling.md Replace the generated main.rs. The attribute prevents an extra console window on Windows in release builds and must not be removed. The main function calls the library's run function. ```rust // Prevents an extra console window on Windows in release. DO NOT REMOVE. #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] fn main() { eatseetira_app_lib::run(); } ``` -------------------------------- ### src/vite-env.d.ts - Vite client type reference Source: https://github.com/zyxavy/eatseetira-system/blob/main/docs/spec/02-repo-tooling.md TypeScript declaration file that references Vite client types. ```ts /// ```