- New notes: History, Artwork - Rewrite TMDB Integration: single detail request, entry mapper, rate limiter, refresh sync, stale-entry refresh, recommendations - Update pages, routing, API reference, models, database migrations, services, components, hooks, API clients, settings, media system, library, Electron (Tauri in progress) and known issues - Rewrite README for the current React/Express stack and setup
7.5 KiB
title, tags
| title | tags | ||
|---|---|---|---|
| Electron |
|
Electron
[!note] Tauri in progress A Tauri v2 version of the desktop app is being built in
tauri/on thefeat/tauri-appbranch (not merged yet). Electron stays as is until it's ready. Dev mode works on Windows; the release build is blocked by the packaged backend resolvingsettings.jsonfrom inside pkg's read-only bundle. Seetauri/README.mdon that branch.
Overview
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_PROCESSwith Electron user data path - Starts backend in-process via
require('../backend/server.js') - Creates frameless
BrowserWindow(1280×800) - Dev mode (
!app.isPackagedorELECTRON_DEV=true): loadshttp://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:
- Draggable region (
-webkit-app-region: drag) - App branding ("SHOWY")
- Min/Max/Close buttons (no-drag region, sends IPC)
See: react_frontend/src/components/layout/TitleBar.tsx
Dev Mode Workflow
- Start Vite dev server:
cd react_frontend && pnpm dev(port 4200) - Run Electron in dev:
cd electron && pnpm dev - Electron detects
ELECTRON_DEV=true→ loads from Vite HMR server
Production Build Workflow
- Build React for Electron:
cd react_frontend && pnpm build:electron- Sets
VITE_ELECTRON=true→ hash router,base: './', API points tolocalhost:4000 - Outputs to
electron/frontend_build/
- Sets
- Package with electron-builder:
cd electron && pnpm generate-exe- Bundles
frontend_build/, backend code, and electron files - Outputs to
dist/electron/
- Bundles
Build Configuration
| Field | Value |
|---|---|
appId |
x4lo.showy |
| Target | Windows x64 directory output |
| Output | ../dist/electron |
Frontend Adaptations for Electron
| Concern | Web Mode | Electron Mode |
|---|---|---|
| Router | createBrowserRouter |
createHashRouter |
| API Base URL | /api/v1 (Vite proxy) |
http://localhost:4000/api/v1 |
| Asset Paths | / base |
./ relative base |
| Title Bar | Hidden (native browser) | Custom <TitleBar> component |
| Detection | — | import.meta.env.VITE_ELECTRON === 'true' |
Package Dependencies
| Package | Purpose |
|---|---|
electron ^34 |
Runtime |
electron-builder ^25 |
Packaging (devDep) |
Backend dependencies live in backend/package.json (required in-process at runtime).
Important Files
| File | Role |
|---|---|
electron/main.js |
Main process — in-process backend, window creation, IPC |
electron/preload.js |
Context bridge (window controls + IPC) |
electron/package.json |
Scripts + builder config |
react_frontend/src/components/layout/TitleBar.tsx |
Custom frameless title bar |
react_frontend/src/electron.d.ts |
TypeScript types for window.electron |
Folder Structure
Running from source (npm run start in electron/)
Before running from source, you need:
cd react_frontend && pnpm build:electron→ builds the React app intoelectron/frontend_build/cd backend && npm install→ install backend depscd electron && npm install→ install electron depcd electron && npm start
Expected structure:
Showy/
├── backend/
│ ├── server.js
│ ├── package.json
│ └── node_modules/ ← npm install in backend/
├── electron/
│ ├── main.js
│ ├── preload.js
│ ├── package.json
│ ├── node_modules/ ← npm install in electron/
│ └── frontend_build/ ← created by pnpm build:electron
│ ├── index.html
│ └── assets/
After packaging (npm run generate-exe)
dist/electron/win-unpacked/
├── Showy.exe
├── resources/
│ ├── app/
│ │ ├── main.js
│ │ ├── preload.js
│ │ └── frontend_build/
│ │ ├── index.html
│ │ └── assets/
│ └── backend/ ← copied via extraResources (no node_modules!)
│ ├── server.js
│ └── ...
└── (Electron runtime DLLs)
⚠️ Packaging caveat: The current config excludes
backend/node_modulesfrom the package viaextraResources. The packaged app will be missing backend dependencies (Express, Sequelize, etc.) and will crash at runtime. To fix this for distribution, either includebackend/node_modulesinextraResources, or move all backend dependencies intoelectron/package.json.
See Also
- Architecture — System overview
- Frontend — React frontend details
- Backend — API and services
- Deployment — Docker alternative