Torrify - Developer Reference
For Developers: Quick reference guide for development workflows, special commands, and testing procedures.
Table of Contents
- Quick Start
- Development Commands
- Command Line Arguments
- Testing
- Build & Package
- Project Structure
- Key Files Reference
- Common Tasks
- Troubleshooting
Quick Start
# Install dependencies
npm install
# Run in development mode
npm run electron:dev
# Run tests
npm testDevelopment Commands
Start Development Server
# Start Vite dev server + Electron (recommended)
npm run electron:dev
# Start Vite dev server only (for browser testing)
npm run devWhat it does:
- Starts Vite dev server on
http://localhost:5173 - Builds Electron main process
- Launches Electron with hot reload
- Opens DevTools automatically
Build Commands
# Build everything (renderer + main process)
npm run build
# Build Electron main process only
npm run build:electron
# Preview production build (Vite only)
npm run previewPackage for Distribution
# Create installer for current platform
npm run package
# Or build for specific platforms
npm run package:win # Windows NSIS installer (.exe)
npm run package:mac # macOS DMG (.dmg)
npm run package:linux # Linux AppImage (.AppImage)Output Directory: dist-installer/
See Build & Package Installers for detailed instructions.
Command Line Arguments
Reset/Wipe Settings
Purpose: Delete settings file and reset to defaults (useful for testing welcome screen)
Usage:
# After building Electron
npm run build:electron
electron . --reset-settings
# Or with the alias
electron . --wipe-settingsWhat it does:
- Deletes
~/.torrify/settings.json - Resets to default settings on next launch
- Welcome screen will appear on next launch
When to use:
- Testing welcome screen functionality
- Resetting corrupted settings
- Testing first-time user experience
- Debugging settings-related issues
Note: Settings are wiped before the app starts, so you'll see default values immediately.
Testing
Run Tests
# Run all tests once
npm test
# Run tests in watch mode (recommended during development)
npm run test:watch
# Run tests with coverage report
npm run test:coverageTest Structure
src/
├── components/
│ └── __tests__/
│ ├── ChatPanel.test.tsx
│ ├── DemoDialog.test.tsx
│ ├── EditorPanel.test.tsx
│ ├── EditorPanel.backend.test.tsx
│ ├── HelpBot.test.tsx
│ ├── PreviewPanel.test.tsx
│ ├── SettingsModal.test.tsx
│ ├── SettingsModal.backend.test.tsx
│ ├── StlViewer.test.tsx
│ └── WelcomeModal.test.tsx
├── services/
│ ├── cad/__tests__/cad.test.ts
│ └── llm/__tests__/code-generation.test.ts
└── App.test.tsxCurrent Status: Run npm test for the latest count and status.
Writing New Tests
- Create test file:
src/components/__tests__/ComponentName.test.tsx - Import testing utilities:typescript
import { render, screen, fireEvent } from '@testing-library/react' import { describe, it, expect, vi } from 'vitest' - Mock Electron API in
src/test/setup.tsif needed - Run:
npm run test:watch
Build & Package
Development Build
# Full development workflow
npm run electron:devOutput:
dist/- Vite build (renderer process)dist-electron/- Electron build (main process)
Production Build
# Build for production
npm run build
# Package into installer
npm run packageOutput:
dist/- Production renderer builddist-electron/- Production main processdist-installer/- Packaged installers
Build & Package Installers
Torrify uses electron-builder to create platform-specific installers.
Prerequisites
Before building installers, ensure you have:
- Node.js 18+ installed
- All dependencies installed:
npm install - Icons in the
build/directory (see Icon Requirements) - Clean build state:
npm run build - Windows Only: Developer Mode enabled (see Windows Developer Mode)
Building Installers
Windows Developer Mode
Required for Windows builds: electron-builder downloads signing tools that contain symbolic links, which require special privileges on Windows.
Enable Developer Mode:
- Open Windows Settings
- Navigate to Privacy & Security → For developers
- Toggle Developer Mode to ON
- Restart your terminal/IDE
Alternative: Run PowerShell as Administrator (not recommended for regular development)
Build for Current Platform
# Build application first
npm run build
# Create installer for your current OS
npm run packageBuild for Specific Platforms
# Windows (NSIS installer)
npm run package:win
# Output: dist-installer/Torrify Setup X.X.X.exe
# Must run on: Windows with Developer Mode enabled
# macOS (DMG)
npm run package:mac
# Output: dist-installer/Torrify-X.X.X.dmg
# Output: dist-installer/Torrify-X.X.X-arm64.dmg
# Must run on: macOS only
# Linux (AppImage)
npm run package:linux
# Output: dist-installer/Torrify-X.X.X.AppImage
# Must run on: Linux (or WSL)Platform Requirements Summary:
- Windows: Must build on Windows (requires Developer Mode)
- macOS: Must build on macOS (uses Apple-specific tools)
- Linux: Must build on Linux or WSL (uses Linux-specific tools like mksquashfs)
Cannot cross-compile: Each platform requires native build tools that don't work on other operating systems.
Cross-Platform Builds via CI/CD
To build for all platforms without having all three operating systems:
Use GitHub Actions (recommended):
bashgit push origin main # Automatically builds Windows, macOS, and Linux # Download from GitHub Actions artifactsUse WSL for Linux builds on Windows:
bash# In WSL Ubuntu cd /mnt/e/SCADGPT npm install npm run package:linuxUse Virtual Machines:
- Windows VM for Windows builds
- macOS VM (on Mac hardware only) for macOS builds
- Linux VM for Linux builds
Icon Requirements
Icons are required in the build/ directory:
| Platform | File | Format | Sizes |
|---|---|---|---|
| Windows | icon.ico | ICO | 16, 32, 48, 64, 128, 256 |
| macOS | icon.icns | ICNS | 16-1024 (multiple) |
| Linux | icon.png | PNG | 512x512 or larger |
Quick Icon Generation
For development/testing, you can use a simple "T" icon:
# Generate basic icons (requires canvas package)
npm install --save-dev canvas png2icons
node scripts/generate-icon.mjsThen convert the generated PNGs to ICO and ICNS formats:
- Online converters: https://convertio.co/png-ico/, https://convertio.co/png-icns/
- Command line:
png2iconspackage
See build/README.md for detailed icon instructions.
electron-builder Configuration
The installer configuration is in package.json under the build key:
{
"build": {
"appId": "com.torrify.app",
"productName": "Torrify",
"directories": {
"buildResources": "build",
"output": "dist-installer"
},
"files": ["dist/**/*", "dist-electron/**/*", "package.json"],
"extraResources": [{"from": "resources", "to": "resources"}],
"asar": true,
"win": { ... },
"mac": { ... },
"linux": { ... }
}
}Platform-Specific Notes
Windows (NSIS)
Features:
- Custom installation directory
- Desktop and Start Menu shortcuts
- Uninstaller included
- Per-user or system-wide installation
Testing locally:
npm run package:win
cd dist-installer
.\Torrify Setup 0.9.2.exeInstaller options:
- One-click: Disabled (user can choose install location)
- Desktop shortcut: Optional
- Start menu: Yes
macOS (DMG)
Features:
- Drag-to-Applications installer
- Universal binary (x64 + arm64)
- Code signing support (requires Apple Developer ID)
- Notarization support (requires credentials)
Requirements for signing:
- Apple Developer ID Application certificate
- Set environment variables:
CSC_LINK- Path to certificateCSC_KEY_PASSWORD- Certificate passwordAPPLE_ID- Apple ID for notarizationAPPLE_ID_PASSWORD- App-specific password
Building unsigned (development):
export CSC_IDENTITY_AUTO_DISCOVERY=false
npm run package:macTesting DMG:
- Open the
.dmgfile - Drag Torrify to Applications
- Launch from Applications
Linux (AppImage)
Features:
- Self-contained executable
- No installation required
- Works on most Linux distributions
- Desktop integration via AppImageLauncher
Testing AppImage:
chmod +x dist-installer/Torrify-*.AppImage
./dist-installer/Torrify-*.AppImageDesktop integration:
- Install AppImageLauncher:
sudo apt install appimagelauncher - Double-click the AppImage
- Choose "Integrate and run"
CI/CD with GitHub Actions
Torrify includes a GitHub Actions workflow to build installers for all platforms automatically.
Workflow file: .github/workflows/build-installers.yml
Triggers:
- Push to
mainordevelopbranches - Pull requests
- Git tag
release(for release-candidate builds) - Manual dispatch
Platforms built:
- Windows (on
windows-latest) - macOS (on
macos-latest) - Linux (on
ubuntu-latest)
Artifacts:
- Uploaded to GitHub Actions artifacts (30 day retention)
- No automatic publishing to GitHub Releases
Triggering a Build
Automatic (on push to main):
git push origin mainManual dispatch:
- Go to GitHub Actions tab
- Select "Build Installers" workflow
- Click "Run workflow"
Trigger a release-candidate build:
# Tag the release build
git tag release
git push origin release
# Workflow will build and upload installers to Actions artifactsTo publish a release, download artifacts from the Actions run and attach them to a GitHub Release manually.
Viewing Build Artifacts
- Go to GitHub Actions tab
- Click on the workflow run
- Scroll to "Artifacts" section
- Download platform-specific artifacts
Troubleshooting Builds
Windows: Cannot Create Symbolic Link
Error: ERROR: Cannot create symbolic link : A required privilege is not held by the client
Cause: Windows requires special privileges to create symbolic links, which electron-builder needs when extracting signing tools.
Solution 1 (Recommended):
- Open Windows Settings
- Go to Privacy & Security → For developers
- Enable Developer Mode
- Restart your terminal/IDE
- Run
npm run package:winagain
Solution 2 (Alternative):
- Run PowerShell as Administrator
- Execute
npm run package:win - Note: You'll need admin privileges every time
Why This Happens: The CSC_IDENTITY_AUTO_DISCOVERY=false flag doesn't prevent electron-builder from downloading signing tools. It still downloads them and tries to extract symlinks, which fails without proper Windows privileges.
Missing Icons
Error: WARNING: No icon found at build/icon.png
Solution:
- Check if
build/directory exists - Generate icons:
node scripts/generate-icon.mjs - Convert PNGs to ICO/ICNS formats
- Place files in
build/directory
Build Fails on macOS
Error: Code signing failed
Solution:
- Signing is already disabled in package scripts via
CSC_IDENTITY_AUTO_DISCOVERY=false - If still failing, manually set:bash
export CSC_IDENTITY_AUTO_DISCOVERY=false npm run package:mac - Or provide proper signing credentials
Linux: Cannot Build AppImage on Windows
Error: cannot execute: "mksquashfs": file does not exist
Cause: AppImage requires Linux-specific tools that don't run on Windows.
Solution:
- Option 1: Use WSL (Windows Subsystem for Linux)bash
# In WSL Ubuntu cd /mnt/e/SCADGPT npm install npm run package:linux - Option 2: Use GitHub Actions CI/CD (automatic)
- Option 3: Use a Linux VM or dual boot
Why: The mksquashfs tool is a Linux binary that creates the AppImage filesystem. It cannot run on Windows directly.
macOS: Cannot Build DMG on Windows/Linux
Error: Various errors about missing macOS tools
Cause: DMG creation requires macOS-specific tools.
Solution:
- Option 1: Use GitHub Actions CI/CD (runs on macOS runner)
- Option 2: Use a Mac or macOS VM (requires Apple hardware)
Why: DMG and code signing tools are macOS-only.
electron-builder Hangs
Error: Build process hangs or freezes
Solution:
- Check for Node.js version issues (use Node 18+)
- Clear cache:
rm -rf ~/.electron ~/.cache/electron-builder - Try with verbose logging:
DEBUG=electron-builder npm run package - Check antivirus isn't blocking electron-builder
Large Installer Size
Problem: Installer is very large (>200MB)
Solution:
- Verify
asaris enabled inpackage.json(it is by default) - Check
filesarray only includes necessary files - Remove unnecessary dependencies
- Check for large files in
resources/
Windows Installer Unsigned Warning
Problem: Windows shows "Unknown Publisher" warning
Solution:
- This is normal for unsigned installers
- For production, sign with a code signing certificate
- Set
CSC_LINKandCSC_KEY_PASSWORDenvironment variables - Or purchase a certificate from DigiCert, Sectigo, etc.
Advanced Configuration
Custom Installer Graphics
Add custom installer graphics to build/:
Windows:
installerIcon.ico- Installer iconinstallerHeader.bmp- Installer header image (150x57)installerSidebar.bmp- Installer sidebar image (164x314)
macOS:
background.png- DMG background image (540x380)background@2x.png- Retina DMG background (1080x760)
Code Signing
Windows:
# Set certificate
export CSC_LINK=/path/to/certificate.pfx
export CSC_KEY_PASSWORD=your_password
# Build signed installer
npm run package:winmacOS:
# Set certificate and notarization credentials
export CSC_LINK=/path/to/certificate.p12
export CSC_KEY_PASSWORD=your_password
export APPLE_ID=your@apple.id
export APPLE_ID_PASSWORD=app-specific-password
# Build and notarize
npm run package:macCustom Build Scripts
Add custom build scripts to package.json:
{
"scripts": {
"package:all": "npm run package:win && npm run package:mac && npm run package:linux",
"package:unsigned": "CSC_IDENTITY_AUTO_DISCOVERY=false npm run package",
"clean:build": "rm -rf dist dist-electron dist-installer"
}
}Version Management
Version is managed in package.json:
{
"version": "0.9.2"
}To bump version:
# Patch (0.9.2 -> 0.9.3)
npm version patch
# Minor (0.9.2 -> 0.10.0)
npm version minor
# Major (0.9.2 -> 1.0.0)
npm version majorThis will:
- Update
package.jsonversion - Create a git commit
- Create a git tag
Then push the tag to trigger CI/CD:
git push && git push --tagsProject Structure
e:\Torrify/
├── electron/ # Electron main process
│ ├── cad/ # CAD backend services
│ ├── main.ts # Main process (IPC, CAD integration)
│ └── preload.ts # Preload script (context bridge)
├── src/ # React frontend
│ ├── components/ # React components
│ ├── services/ # CAD + LLM service layer
│ ├── App.tsx # Main app component
│ └── main.tsx # React entry point
├── resources/ # Bundled API context
├── scripts/ # Context generation scripts
├── dist/ # Build output (renderer)
├── dist-electron/ # Build output (main)
└── package.jsonKey Files Reference
Configuration Files
| File | Purpose |
|---|---|
package.json | Dependencies and scripts |
vite.config.ts | Vite build configuration |
tsconfig.json | TypeScript config (renderer) |
tsconfig.electron.json | TypeScript config (main) |
tailwind.config.js | TailwindCSS configuration |
vitest.config.ts | Test configuration |
Core Application Files
| File | Purpose |
|---|---|
electron/main.ts | Electron main process, IPC handlers |
electron/preload.ts | Context bridge, API exposure |
src/App.tsx | Main React component, layout |
src/main.tsx | React entry point |
src/vite-env.d.ts | TypeScript definitions for Electron API |
Component Files
| File | Purpose |
|---|---|
src/components/ChatPanel.tsx | AI chat interface |
src/components/EditorPanel.tsx | Monaco code editor |
src/components/PreviewPanel.tsx | 3D preview display |
src/components/SettingsModal.tsx | Settings configuration UI |
src/components/WelcomeModal.tsx | First-time welcome screen |
src/components/StlViewer.tsx | Three.js STL viewer |
Service Files
| File | Purpose |
|---|---|
src/services/llm/types.ts | LLM service interfaces |
src/services/llm/index.ts | LLM service factory |
src/services/llm/GeminiService.ts | Google Gemini implementation |
Common Tasks
Reset Settings for Testing
# Method 1: Command line argument
npm run build:electron
electron . --reset-settings
# Method 2: Delete manually
# Windows: Delete C:\Users\<username>\.torrify\settings.json
# Linux/Mac: Delete ~/.torrify/settings.jsonTest Welcome Screen
- Reset settings:
electron . --reset-settings - Launch app:
npm run electron:dev - Welcome screen should appear
- Configure OpenSCAD path and/or API key
- Welcome screen should not appear on next launch
Add New LLM Provider
- Create service file:
src/services/llm/ProviderNameService.ts - Implement
LLMServiceinterface - Add to factory:
src/services/llm/index.ts - Update
PROVIDER_NAMESandDEFAULT_MODELS - Add tests if needed
Example: See GeminiService.ts for reference
Debug IPC Communication
- Open DevTools (auto-opens in dev mode)
- Check Console for errors
- Check Network tab for IPC calls
- Add
console.loginelectron/main.ts(gated to dev mode)
Test OpenSCAD Integration
- Ensure OpenSCAD is installed
- Configure path in Settings (⚙️ icon)
- Write test code in editor:openscad
cube([10, 10, 10]); - Press
Ctrl+Sor click Render - Check preview panel for 3D model
Test File Operations
Open File:
- Click "Open" button or press
Ctrl+O - Select a
.scadfile - Verify code loads in editor
- Verify window title updates with filename
- Verify chat is cleared
- Click "Open" button or press
Save File:
- Open a file or create new code
- Click "Save" (only enabled if file is open) or press
Ctrl+S - Verify file saves correctly
- Verify window title removes
*indicator
Save As:
- Click "Save As" or press
Ctrl+Shift+S - Choose location and filename
- Verify file saves
- Verify window title updates
- Click "Save As" or press
Unsaved Changes:
- Modify code in editor
- Verify
*appears in window title - Try opening new file - should warn about unsaved changes
- Try creating new file - should warn about unsaved changes
Troubleshooting
Port 5173 Already in Use
Error: Port 5173 is already in use
Solution: Change port in vite.config.ts:
server: {
port: 5174, // Use different port
}OpenSCAD Not Found
Error: OpenSCAD executable not found
Solution:
- Open Settings (⚙️ icon)
- Click "Browse..." next to OpenSCAD path
- Select
openscad.exe(Windows) oropenscad(Linux/Mac) - Save settings
Tests Failing
Error: Tests fail with mock errors
Solution:
- Check
src/test/setup.tsfor proper mocks - Ensure all Electron API methods are mocked
- Run:
npm test -- --clearCache
Build Errors
Error: TypeScript compilation errors
Solution:
# Clean and rebuild
rm -rf dist dist-electron node_modules/.vite
npm install
npm run buildWelcome Screen Not Showing
Check:
- Settings file exists:
~/.torrify/settings.json - OpenSCAD path is configured and valid
- API key is configured (if required)
- Reset settings:
electron . --reset-settings
Settings Not Persisting
Check:
- Settings file location:
~/.torrify/settings.json - File permissions (should be user-readable only)
- Check console for save errors
- Verify IPC communication in DevTools
Environment Variables
Development
VITE_DEV_SERVER_URL- Set automatically by Vite- Used to gate console.log statements
- Used to determine if DevTools should open
OPENROUTER_API_KEY- Required for PRO (OpenRouter) access
Production
OPENROUTER_API_KEYrequired for PRO (OpenRouter)- Settings stored in
~/.torrify/settings.json
IPC API Reference
Settings
get-settings- Get current settingssave-settings- Save settingscheck-openscad-path- Validate OpenSCAD pathselect-openscad-path- Open file dialog for OpenSCADshould-show-welcome- Check if welcome screen should showreset-settings- Delete settings file (programmatic)get-openrouter-key- ReadOPENROUTER_API_KEYfrom environment
Rendering
render-scad- Render OpenSCAD to PNG (legacy)render-stl- Render OpenSCAD to STL (current)
File Operations
open-scad-file- Open .scad file dialog and load filesave-scad-file- Save .scad file (direct save or Save As dialog)set-window-title- Update window title with filenameget-recent-files- Load recent files listclear-recent-files- Clear recent files listremove-recent-file- Remove a single recent entryopen-recent-file- Open a recent file or project
Projects
save-project- Save project file (.torrify)load-project- Load project fileexport-scad- Export code as .scad fileexport-stl- Export STL file
Documentation & Knowledge Base
load-documentation- Load docs for Help Botget-context- Load API context for a backendget-context-status- Read context file metadataupdate-context-from-cloud- Update context from a URLreset-context-to-factory- Restore bundled context
Local LLM
get-ollama-models- Fetch available Ollama models
Menu Events
on-menu-event- Listen for menu commandsremove-menu-listener- Unsubscribe from menu commands
Utilities
get-temp-dir- Get temporary directory path
Development Workflow
Typical Development Session
Start Development
bashnpm run electron:devMake Changes
- Edit React components in
src/components/ - Edit Electron code in
electron/ - Hot reload should pick up changes
- Edit React components in
Test Changes
- Manual testing in Electron window
- Run tests:
npm run test:watch
Build for Testing
bashnpm run build npm run electron
Testing Welcome Screen Flow
Reset Settings
bashnpm run build:electron electron . --reset-settingsLaunch App
bashnpm run electron:devVerify Welcome Shows
- Welcome modal should appear
- Both OpenSCAD and API key should show as not configured
Configure Settings
- Click "Open Settings" or "Configure OpenSCAD Path"
- Set OpenSCAD path
- Optionally set API key
- Save
Verify Welcome Doesn't Show
- Close and reopen app
- Welcome should not appear
File Locations
Settings File
Location: ~/.torrify/settings.json
Windows: C:\Users\<username>\.torrify\settings.json
Linux/Mac: ~/.torrify/settings.json
Contents:
{
"openscadPath": "C:\\Program Files\\OpenSCAD\\openscad.exe",
"llm": {
"provider": "gemini",
"model": "gemini-2.0-flash-exp",
"apiKey": "",
"enabled": false,
"temperature": 0.7,
"maxTokens": 2048
}
}Temporary Files
Location: %TEMP%\torrify\ (Windows) or /tmp/torrify/ (Linux/Mac)
Files:
temp_model.scad- Current OpenSCAD coderender_preview.png- PNG render output (legacy)render_preview.stl- STL render output (current)
Quick Command Reference
# Development
npm run electron:dev # Start dev server + Electron
npm run dev # Vite dev server only
npm run build:electron # Build Electron main process
# Testing
npm test # Run all tests
npm run test:watch # Watch mode
npm run test:coverage # With coverage
# Building
npm run build # Full production build
npm run package # Create installer
# Settings
electron . --reset-settings # Wipe settings (after build)
electron . --wipe-settings # Alias for --reset-settingsNotes
- Hot Reload: React components hot reload automatically
- Electron Reload: Main process requires restart (run
npm run build:electron) - DevTools: Auto-opens in development mode
- Logging: Console.log only in development (gated by
VITE_DEV_SERVER_URL) - Settings: Persist across app restarts
- Welcome Screen: Only shows if OpenSCAD path or API key is missing
- File Operations: File size limit is 10MB for
.scadfiles - Window Title: Automatically updates with filename and unsaved changes indicator
Additional Resources
- Home - User-facing documentation
- HANDOFF.md - Complete project history
- SECURITY_AUDIT.md - Security documentation
- TESTING.md - Testing guide
- LLM_INTEGRATION.md - AI integration guide
Last Updated: January 24, 2026