- **Electron Full Rework**: Completely rewrote `electron/main.js` — removed child process spawn, backend now runs in-process via `require()`; frameless window with custom title bar; dual-mode support (dev loads Vite at `:4200`, production loads built files)
- **`electron/preload.js`**: Enhanced contextBridge to expose `windowControls` (minimize/maximize/close) and `isElectron` flag alongside existing `ipcRenderer` bridge
- **`electron/package.json`**: Updated scripts (`start`, `dev`, `build-front` → calls React build), removed duplicated backend dependencies (backend now required in-process), updated electron-builder config with proper `files` and `extraResources`
- **`TitleBar` component**: New `react_frontend/src/components/layout/TitleBar.tsx` — custom frameless window title bar with drag region, app branding, and IPC-powered minimize/maximize/close buttons
- **`AppLayout`**: Conditionally renders `<TitleBar>` when built for Electron (`VITE_ELECTRON=true`); wrapped content in an extra flex container to accommodate title bar height
- **`vite.config.ts`**: Added `VITE_ELECTRON` env detection — sets `base: './'` for correct asset resolution in `file://` context
- **`api.ts`**: Dynamic base URL — uses `http://localhost:4000/api/v1` in Electron mode, `/api/v1` (proxy-relative) otherwise
- **`router.tsx`**: Conditional router factory — uses `createHashRouter` in Electron mode (required for `file://` navigation) and `createBrowserRouter` for web
- **`electron.d.ts`**: Added TypeScript declarations for `window.electron` global (windowControls, ipcRenderer, isElectron)
- **`package.json`**: Added `build:electron` script with `cross-env VITE_ELECTRON=true`; added `cross-env` devDependency
- Updated `Electron.md`
Co-authored-by: Copilot <copilot@github.com>
Electron 34 wraps the Showy backend + React frontend into a standalone desktop application for Windows. The backend runs in-process (no child process spawn), and the app uses a custom frameless title bar with IPC-driven window controls.
Architecture
graph TD
E[Electron Main Process] --> |require in-process| B[Node.js Backend]
E --> |BrowserWindow| FE[React Frontend Build]
FE --> |HTTP localhost:4000| B
FE --> |IPC: windowControls| E
Main Process — electron/main.js
Sets process.env.PARENT_PROCESS with Electron user data path
Starts backend in-process via require('../backend/server.js')
Creates frameless BrowserWindow (1280×800)
Dev mode (!app.isPackaged or ELECTRON_DEV=true): loads http://localhost:4200 (Vite dev server) + opens DevTools
Production mode: loads frontend_build/index.html (hash-routed React app)
Registers IPC handlers for window controls
Window Configuration
Setting
Value
Width
1280
Height
800
Min Width
900
Min Height
600
Frame
false (frameless)
Context Isolation
true
Node Integration
false
Sandbox
false (required for preload)
Preload Script — electron/preload.js
Exposes via contextBridge.exposeInMainWorld('electron', ...):
API
Methods
isElectron
true (flag for frontend detection)
windowControls
minimize(), maximize(), close()
ipcRenderer
send(), on(), once(), removeAllListeners()
IPC Channels
Channel
Direction
Purpose
window-minimize
Renderer → Main
Minimize window
window-maximize
Renderer → Main
Toggle maximize/restore
window-close
Renderer → Main
Close window
Custom Title Bar
The React frontend renders a <TitleBar> component when VITE_ELECTRON=true:
⚠️ Packaging caveat: The current config excludes backend/node_modules from the package via extraResources. The packaged app will be missing backend dependencies (Express, Sequelize, etc.) and will crash at runtime. To fix this for distribution, either include backend/node_modules in extraResources, or move all backend dependencies into electron/package.json.