A modern Electron desktop application starter using Vue 3, Rsbuild, and TypeScript with WinBox.js for window-based navigation.
- Quick Start
- Available Commands
- Project Structure
- Architecture Overview
- Key Features
- Technology Stack
- Configuration
- Documentation
- Potential Improvements
- License
# Install dependencies
bun install
# Start development mode
bun run dev
# Build for production
bun run build
# Package for distribution
bun run dist| Command | Description |
|---|---|
bun run dev |
Launch Electron in development mode |
bun run dev:web |
Start renderer dev server only |
bun run dev:electron |
Start Electron with dev server |
bun run build |
Build full application (TypeScript + frontend) |
bun run build:frontend |
Build frontend only |
bun run build:ts |
Compile TypeScript to dist-ts/ |
bun run dist |
Package installers with electron-builder |
bun run start |
Start the built Electron application |
bun run lint |
Run Biome linter |
bun run lint:fix |
Auto-fix lint issues |
bun run format |
Format code with Biome |
bun run test |
Run all tests (Bun test runner) |
bun run test:watch |
Run tests in watch mode |
bun run test:coverage |
Run tests with coverage report |
bun run test:main |
Run main process tests |
bun run test:renderer |
Run renderer process tests |
bun run test:shared |
Run shared utilities tests |
bun run test:security |
Run security tests |
starter-electron-vue-rsbuild/
βββ scripts/ # Build and development orchestration (19 files)
β βββ cli.mjs # Main CLI entry point
β βββ commands/ # Command implementations
β β βββ build.mjs # Build command orchestration
β β βββ dev.mjs # Development server with import fixing
β β βββ start.mjs # Start built application
β βββ core/ # Core utilities
β β βββ config.mjs # Centralized configuration
β β βββ errors.mjs # Error classes and handling
β β βββ logger.mjs # Logging utilities
β βββ utils/ # Helper utilities
β β βββ exec.mjs # Command execution
β β βββ fs.mjs # File system operations
β β βββ network.mjs # Port finding utilities
β β βββ validate.mjs # Validation utilities
β βββ backup/ # Legacy scripts (reference only)
β βββ build-electron.mjs
β βββ build-frontend.mjs
β βββ build.mjs
β βββ check-dependencies.mjs
β βββ dev-electron.mjs
β βββ fix-imports.js
β βββ main.mjs
β βββ start.mjs
β
βββ src/
β βββ main/ # Electron main process (20 files)
β β βββ main.ts # Production entry point
β β βββ main.dev.ts # Development entry point
β β βββ di/ # Dependency injection (4 files)
β β β βββ main-container.ts # Main process DI container
β β β βββ service-providers.ts # Service registration
β β β βββ tokens.ts # DI injection tokens
β β β βββ index.ts
β β βββ events/ # Event bus system (4 files)
β β β βββ main-event-bus.ts # Main process event bus
β β β βββ ipc-handlers.ts # IPC event handlers
β β β βββ examples.ts # Usage examples
β β β βββ index.ts
β β βββ use-cases/ # Business logic (14 files)
β β β βββ app-service.ts # App service interface
β β β βββ app-service-instance.ts
β β β βββ file-service.ts # File service interface
β β β βββ file-service-instance.ts
β β β βββ window-service.ts # Window service interface
β β β βββ window-service-instance.ts
β β β βββ electron-intro.ts # Feature use cases
β β β βββ electron-architecture.ts
β β β βββ electron-security.ts
β β β βββ electron-packaging.ts
β β β βββ electron-native-apis.ts
β β β βββ electron-performance.ts
β β β βββ electron-development.ts
β β β βββ electron-versions.ts
β β β βββ index.ts
β β β βββ use-cases-index.ts
β β βββ lib/ # Utilities (4 files)
β β βββ filesystem-utils.ts # File operations
β β βββ ipc-utils.ts # IPC helpers
β β βββ process-utils.ts # Process management
β β βββ window-utils.ts # Window creation (1024x640 default)
β β
β βββ renderer/ # Vue renderer process (40+ files)
β β βββ main.ts # Vue app entry point
β β βββ components/ # Vue components (2 files)
β β β βββ App.vue # Root component
β β β βββ Sidebar.vue # Sidebar with window list
β β βββ use-cases/ # View components (8 Vue files)
β β β βββ ElectronIntro.vue
β β β βββ ElectronArchitecture.vue
β β β βββ ElectronSecurity.vue
β β β βββ ElectronPackaging.vue
β β β βββ ElectronNativeAPIs.vue
β β β βββ ElectronPerformance.vue
β β β βββ ElectronDevelopment.vue
β β β βββ ElectronVersions.vue
β β β βββ index.ts
β β βββ composables/ # Vue composables (8 files)
β β β βββ useInject.ts # DI composable
β β β βββ useEventBus.ts # Event bus composable
β β β βββ useWinBoxNavigation.ts # WinBox router composable
β β β βββ useIPC.ts # IPC composable
β β β βββ useWindow.ts # Window composable
β β β βββ useAppInfo.ts # App info composable
β β β βββ windowManager.js # Window manager (legacy)
β β β βββ index.ts
β β βββ router/ # WinBox router (3 files)
β β β βββ winbox-router.ts # Router implementation
β β β βββ views.ts # View registry
β β β βββ index.ts
β β βββ api/ # API layer (6 files)
β β β βββ base.api.ts # Base API client
β β β βββ file.api.ts # File API
β β β βββ app.api.ts # App API
β β β βββ window.api.ts # Window API
β β β βββ system.api.ts # System API
β β β βββ index.ts
β β βββ services/ # Renderer services (12 files)
β β β βββ window-factory.ts # WinBox factory (auto-maximize)
β β β βββ window-service.ts # Window service
β β β βββ ipc-service.ts # IPC service
β β β βββ window-generator.ts # Window content generator
β β β βββ [electron-*]-window.ts # Feature window services
β β βββ stores/ # Pinia stores (2 files)
β β β βββ pinia.ts # Pinia setup
β β β βββ windowStore.ts # Window state management
β β βββ events/ # Renderer events (2 files)
β β β βββ renderer-event-bus.ts
β β β βββ index.ts
β β βββ windows/ # WinBox windows (2 files)
β β β βββ index.ts # Window manager
β β β βββ types.ts # Window types
β β βββ lib/ # Utilities (2 files)
β β β βββ dom.ts # DOM utilities
β β β βββ events.ts # Event utilities
β β βββ styles/ # Global styles (2 files)
β β β βββ App.css # App styles (WinBox dark theme)
β β β βββ global.css # Global styles
β β βββ assets/ # Static assets
β β β βββ icons/ # App icons
β β β βββ images/ # Images
β β βββ views/ # Screen-level components (empty)
β β βββ reset.css # CSS reset
β β βββ index.css # Main styles
β β
β βββ shared/ # Shared code (25 files)
β β βββ di/ # DI core (5 files)
β β β βββ di-container.ts # Container implementation
β β β βββ injection-token.ts # Token class
β β β βββ injectable.ts # Injectable decorator
β β β βββ service-metadata.ts # Service metadata
β β β βββ index.ts
β β βββ events/ # Event bus core (4 files)
β β β βββ event-bus.ts # Core implementation
β β β βββ types.ts # Event types
β β β βββ definitions.ts # Event definitions
β β β βββ index.ts
β β βββ ipc/ # IPC utilities (3 files)
β β β βββ channels.ts # Channel definitions
β β β βββ handlers.ts # Handler utilities
β β β βββ index.ts
β β βββ errors/ # Error handling (4 files)
β β β βββ base.error.ts # Base error class
β β β βββ ipc.error.ts # IPC errors
β β β βββ validation.error.ts # Validation errors
β β β βββ index.ts
β β βββ config/ # Configuration (3 files)
β β β βββ env.config.ts # Environment config
β β β βββ app.config.ts # App config
β β β βββ index.ts
β β βββ types/ # TypeScript types (3 files)
β β β βββ electron-api.ts # Electron API types
β β β βββ entities.ts # Entity types
β β β βββ ipc-channels.ts # IPC channel types
β β βββ contracts/ # Interface contracts (1 file)
β β β βββ api-contracts.ts
β β βββ core/ # Core utilities (2 files)
β β β βββ index.ts
β β β βββ types.ts
β β βββ constants.ts # Global constants
β β
β βββ preload.ts # Preload script (secure IPC)
β βββ shims-vue.d.ts # Vue type declarations
β βββ __tests__/ # Tests (1 file)
β βββ security.test.ts
β
βββ docs/ # Documentation (15 files)
β βββ README.md # Documentation index
β βββ architecture.md # Architecture guide
β βββ development.md # Development workflow
β βββ build-packaging.md # Build and packaging
β βββ ipc.md # IPC communication
β βββ EVENT_BUS.md # Event bus documentation
β βββ WINBOX_ROUTER.md # WinBox router docs
β βββ DEPENDENCY_INJECTION.md # DI documentation
β βββ testing.md # Testing guide
β βββ deployment.md # Deployment guide
β βββ troubleshooting.md # Troubleshooting
β βββ configuration.md # Configuration guide
β βββ features-and-capabilities.md
β βββ ai-agents.md # AI agent guide
β βββ contributing.md # Contribution guide
β
βββ build/ # Frontend build output (Rsbuild)
βββ dist/ # Packaged Electron artifacts
βββ dist-ts/ # TypeScript compilation output
βββ reports/ # Test and analysis reports
β βββ security-test-report.json
β βββ security-report.json
β
βββ package.json # Dependencies and scripts
βββ tsconfig.json # TypeScript configuration
βββ tsconfig.main.json # Main process TS config
βββ tsconfig.node.json # Node TS config
βββ rsbuild.config.ts # Rsbuild configuration
βββ biome.json # Biome (linter/formatter) config
βββ index.css # Root styles
βββ reset.css # CSS reset
βββ LICENSE
| Directory | Files | Purpose |
|---|---|---|
| scripts/ | 19 | Build and development orchestration |
| src/main/ | 20 | Electron main process |
| src/renderer/ | 40+ | Vue renderer process |
| src/shared/ | 25 | Shared utilities and types |
| docs/ | 15 | Documentation |
| Total | 120+ | Source files |
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Electron App β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β ββββββββββββββββββββ ββββββββββββββββββββ β
β β Main Process ββββββββββΊβ Renderer Process β β
β β (Node.js) β IPC β (Vue 3 + WinBox) β β
β β β β β β
β β - Window mgmt β β - UI components β β
β β - File system β β - WinBox router β β
β β - Native APIs β β - State (Pinia) β β
β β - Event bus β β - Event bus β β
β ββββββββββββββββββββ ββββββββββββββββββββ β
β β² β² β
β β β β
β ββββββββββββ¬ββββββββββββββββββββ β
β β β
β βββββββββΌβββββββββ β
β β Preload Script β β
β β (Secure Bridge)β β
β ββββββββββββββββββ β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- WinBox.js as Router: Uses floating windows instead of URL-based routing
- Event Bus System: Cross-process communication with type safety
- Dependency Injection: Centralized DI container for both processes
- API Layer: Type-safe abstraction over IPC calls
- Use Case Pattern: Business logic separated from UI and services
- Auto-Maximize Windows: WinBox windows open maximized, respecting sidebar
- TypeScript with strict mode enabled
- Hot Module Replacement (HMR) in development
- Unified CLI for all development tasks
- Biome for unified linting and formatting
- Comprehensive documentation (15 files)
- ES module import auto-fixing
- Clean separation between main and renderer processes
- Dependency injection for testability
- Event bus for decoupled communication
- WinBox.js window-based navigation
- Type-safe IPC with predefined channels
- Auto-maximize windows respecting sidebar (300px)
- Context isolation enabled
- Preload script for secure API exposure
- Content Security Policy ready
- Input validation on IPC calls
- Security test suite included
- Rsbuild for fast builds (Rust-powered)
- electron-builder for packaging
- Cross-platform support (Windows, macOS, Linux)
- Multiple installer formats (MSI, DMG, AppImage, deb)
- WinBox.js for floating windows
- Auto-maximize on creation
- Sidebar-aware positioning (300px offset)
- Window state management via Pinia
- Minimize/hide behavior customization
| Technology | Version | Purpose |
|---|---|---|
| Electron | 40.x | Desktop application framework |
| Vue | 3.5.x | UI framework |
| TypeScript | 5.9.x | Type safety |
| Rsbuild | 1.7.x | Build tool (Rust-powered) |
| Pinia | 3.0.x | State management |
| WinBox | 0.2.x | Window management/router |
| Tool | Purpose |
|---|---|
| Biome | Linting and formatting |
| electron-builder | Packaging and distribution |
| concurrently | Run multiple commands |
| tsc-alias | TypeScript path alias resolution |
| tsconfig-paths | TypeScript path mapping |
Path aliases configured in tsconfig.json:
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
},
"outDir": "./dist-ts"
}
}Configured in rsbuild.config.ts:
- Entry:
src/renderer/main.ts - Output:
./build - Vue plugin enabled
- Type checking enabled
- Dev server on port 3000 (auto-finds available port)
Configured in biome.json:
- 2-space indentation
- Single quotes
- Semicolons required
- Ignores build output directories
- Default size: 1024x640 pixels
- Minimum size: 640x480 pixels
- Context isolation: enabled
- Node integration: disabled (security)
- Auto-maximize: enabled
- Sidebar offset: 300px + 16px gaps
- Theme: dark
- Border: 4px
Comprehensive documentation is available in the docs/ directory:
| Document | Description |
|---|---|
| Architecture | System design and process boundaries |
| Development | Development workflow guide |
| Build & Packaging | Production build process |
| IPC Guide | Inter-process communication |
| Event Bus | Event system documentation |
| WinBox Router | Window-based navigation |
| Dependency Injection | DI system guide |
| Testing | Testing guide with Bun test runner π§ͺ |
| Deployment | Distribution process |
| Troubleshooting | Common issues and solutions |
| Configuration | Configuration guide |
| Features | Complete feature list |
| AI Agents | AI agent guide |
| Contributing | Contribution guide |
The following suggestions focus on project structure improvements for better modularity and scalability. No code changes are suggested, only organizational improvements.
Current Issue: The use-cases/ directories in both main and renderer contain mixed concerns. The main process has 14 files mixing services, use cases, and service instances. The renderer has 8 Vue components in use-cases/ which should be in views/ or components/.
Suggested Structure:
src/main/
βββ services/ # Core services (stateless utilities)
β βββ window.service.ts
β βββ file.service.ts
β βββ app.service.ts
βββ handlers/ # IPC handlers
β βββ app.handler.ts
β βββ file.handler.ts
β βββ window.handler.ts
βββ use-cases/ # Business logic only
βββ get-system-info.use-case.ts
βββ manage-window.use-case.ts
src/renderer/
βββ views/ # Move use-cases/*.vue here
β βββ ElectronIntro.vue
β βββ ElectronArchitecture.vue
β βββ ...
βββ use-cases/ # Remove or repurpose for business logic
Benefit: Clearer separation of concerns, easier to find files, better scalability.
Current Issue: Several directories exist but are empty or underutilized:
src/renderer/views/- Empty, but use-cases/ has 8 Vue filessrc/main/handlers/- Empty directorysrc/shared/utils/- Does not exist (should be in src/shared/core/)src/shared/core/- Only 2 files, unclear purpose
Suggested Actions:
- Move Vue components from
use-cases/toviews/ - Either populate
handlers/with IPC handlers or remove it - Consolidate
core/utilities into a singleutils/directory - Remove empty directories to reduce confusion
Benefit: Reduced cognitive load, clearer project structure.
Current Issue: Window management is spread across 7 different locations with overlapping responsibilities:
src/renderer/services/window-factory.ts- Window creationsrc/renderer/services/window-service.ts- Window servicesrc/renderer/windows/index.ts- Window managersrc/renderer/stores/windowStore.ts- Pinia storesrc/renderer/composables/windowManager.js- Legacy composablesrc/renderer/composables/useWinBoxNavigation.ts- Router composablesrc/renderer/router/winbox-router.ts- Router implementation
Suggested Structure:
src/renderer/features/windows/
βββ window-manager.ts # Single source of truth
βββ window-factory.ts # Window creation
βββ window-store.ts # Pinia store
βββ useWindowManager.ts # Main composable
βββ useWinBoxNavigation.ts # Navigation composable
βββ types.ts # Types
Benefit: Single source of truth, easier to maintain, reduced duplication.
Current Issue: The scripts/ directory has both active and backup scripts mixed together. The backup/ folder contains 8 legacy files that may cause confusion.
Current Structure:
scripts/
βββ cli.mjs # Active
βββ build.mjs # Active (duplicate?)
βββ dev.mjs # Active (duplicate?)
βββ commands/ # Active
β βββ build.mjs
β βββ dev.mjs
β βββ start.mjs
βββ backup/ # Legacy (8 files)
Suggested Structure:
scripts/
βββ cli.mjs # Single entry point
βββ commands/ # All commands
β βββ build.mjs
β βββ dev.mjs
β βββ start.mjs
βββ core/ # Core utilities
βββ utils/ # Helper utilities
βββ legacy/ # Renamed from backup
βββ [document what was deprecated and why]
Benefit: Clearer distinction between active and legacy code.
Current Issue: Type-based organization (components, services, composables) becomes difficult to navigate as the project grows beyond 50 components.
Suggested Structure for Large Projects:
src/renderer/
βββ features/
β βββ window-management/
β β βββ components/
β β βββ composables/
β β βββ services/
β β βββ index.ts
β βββ file-operations/
β β βββ components/
β β βββ composables/
β β βββ index.ts
β βββ settings/
β βββ components/
β βββ composables/
βββ shared/
β βββ components/
β βββ composables/
βββ app/
βββ stores/
βββ main.ts
When to Implement: When the project exceeds 50 components or 10,000 lines of code.
Benefit: Better scalability, easier to find feature-related code.
Current Issue: Inconsistent naming conventions across the project:
- Services:
window-service.tsvswindowService.ts(kebab-case vs camelCase) - Use cases:
electron-intro.tsvsElectronIntro.vue - Composables:
useWinBoxNavigation.tsvswindowManager.js - Mixed patterns:
main-container.tsvsrenderer-container.ts
Suggested Convention:
- Services:
*.service.ts - Use cases:
*.use-case.ts - Handlers:
*.handler.ts - Composables:
use*.ts - Stores:
use*Store.ts - Components:
*.vue(PascalCase for components) - Utilities:
*.util.tsor*-utils.ts
Benefit: Consistent naming makes files easier to find and understand.
Current Issue: No .env files exist for environment-specific configuration. Configuration is hardcoded in scripts/core/config.mjs.
Suggested Addition:
.env # Default environment
.env.development # Development-specific
.env.production # Production-specific
.env.test # Test-specific
Benefit: Easier environment management, better security for sensitive values.
Current Issue: Event bus exists in multiple places with potential overlap:
src/shared/events/(core)src/main/events/(main process)src/renderer/events/(renderer process)src/renderer/composables/useEventBus.ts(Vue composable)
Suggested: Add a README.md in src/shared/events/ documenting:
- When to use shared vs process-specific event buses
- Event naming conventions
- Cross-process event patterns
Benefit: Reduced confusion, better adoption of event system.
Current Issue: Some modules lack proper index files for clean imports. For example, src/shared/core/ has index.ts but src/shared/contracts/ does not.
Suggested: Ensure every module directory has an index.ts that exports public APIs:
src/shared/contracts/index.ts
src/shared/utils/index.ts
src/main/handlers/index.ts (if created)
Benefit: Cleaner imports, better encapsulation.
Current Issue: Tests are mixed with source files (src/__tests__/security.test.ts) but there's no clear testing structure.
Suggested Structure:
tests/
βββ unit/
β βββ main/
β βββ renderer/
β βββ shared/
βββ integration/
β βββ ipc.test.ts
βββ e2e/
βββ app.test.ts
Benefit: Clearer test organization, easier to run specific test suites.
Current Issue: Constants are scattered across files (src/shared/constants.ts, src/shared/ipc/channels.ts, etc.).
Suggested:
src/shared/constants/
βββ app.constants.ts
βββ ipc.constants.ts
βββ window.constants.ts
βββ index.ts
Benefit: Centralized constants, easier to maintain.
Current Issue: Module dependencies are implicit. It's unclear which modules depend on which.
Suggested: Add DEPENDENCIES.md in each major module documenting:
- What modules it depends on
- What modules depend on it
- Circular dependency warnings
Benefit: Better understanding of module relationships, easier refactoring.
Current Issue: No automated bundle size tracking or analysis.
Suggested: Add to package.json scripts:
{
"scripts": {
"analyze": "rsbuild --analyze",
"report": "open build/stats.html"
}
}Benefit: Better bundle size awareness, easier optimization.
Current Issue: CSS files are scattered:
./index.css(root)./reset.css(root)src/renderer/index.csssrc/renderer/reset.csssrc/renderer/styles/App.csssrc/renderer/styles/global.css
Suggested:
src/renderer/styles/
βββ reset.css # CSS reset
βββ variables.css # CSS variables
βββ global.css # Global styles
βββ components/ # Component-specific styles
βββ winbox.css # WinBox-specific styles
Benefit: Clearer style organization, easier maintenance.
Current Issue: As features grow, single repo may become unwieldy.
Suggested Future Structure (if needed):
packages/
βββ core/ # Shared core (DI, events, errors)
βββ main-process/ # Main process code
βββ renderer/ # Renderer code
βββ ui-components/ # Reusable UI components
βββ app/ # Main application
When to Consider: When the project exceeds 50,000 lines of code or multiple teams work on it.
Benefit: Better separation of concerns, independent versioning.
| Priority | Count | Focus Areas |
|---|---|---|
| High | 5 | Directory consolidation, empty directories, window management, script organization, feature-based structure |
| Medium | 5 | Naming conventions, environment config, event documentation, index files, test organization |
| Low | 5 | Constants, dependency docs, build analysis, CSS consolidation, monorepo consideration |
MIT License - see LICENSE file for details.
See docs/contributing.md for contribution guidelines.
For issues and questions:
- Check documentation
- Review troubleshooting guide
- Open an issue on GitHub