Skip to content

naranyala/starter-electron-vue-rsbuild

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

20 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Electron + Vue + Rsbuild Starter

A modern Electron desktop application starter using Vue 3, Rsbuild, and TypeScript with WinBox.js for window-based navigation.

Table of Contents


Quick Start

# Install dependencies
bun install

# Start development mode
bun run dev

# Build for production
bun run build

# Package for distribution
bun run dist

Available Commands

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

Project Structure

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

File Count Summary

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

Architecture Overview

Three-Process Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    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)β”‚                          β”‚
β”‚              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                          β”‚
β”‚                                                          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Key Architectural Decisions

  1. WinBox.js as Router: Uses floating windows instead of URL-based routing
  2. Event Bus System: Cross-process communication with type safety
  3. Dependency Injection: Centralized DI container for both processes
  4. API Layer: Type-safe abstraction over IPC calls
  5. Use Case Pattern: Business logic separated from UI and services
  6. Auto-Maximize Windows: WinBox windows open maximized, respecting sidebar

Key Features

Development Experience

  • 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

Architecture

  • 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)

Security

  • Context isolation enabled
  • Preload script for secure API exposure
  • Content Security Policy ready
  • Input validation on IPC calls
  • Security test suite included

Build and Distribution

  • Rsbuild for fast builds (Rust-powered)
  • electron-builder for packaging
  • Cross-platform support (Windows, macOS, Linux)
  • Multiple installer formats (MSI, DMG, AppImage, deb)

Window Management

  • WinBox.js for floating windows
  • Auto-maximize on creation
  • Sidebar-aware positioning (300px offset)
  • Window state management via Pinia
  • Minimize/hide behavior customization

Technology Stack

Core Technologies

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

Development Tools

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

Configuration

TypeScript

Path aliases configured in tsconfig.json:

{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "@/*": ["src/*"]
    },
    "outDir": "./dist-ts"
  }
}

Rsbuild

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)

Biome

Configured in biome.json:

  • 2-space indentation
  • Single quotes
  • Semicolons required
  • Ignores build output directories

Electron Window Defaults

  • Default size: 1024x640 pixels
  • Minimum size: 640x480 pixels
  • Context isolation: enabled
  • Node integration: disabled (security)

WinBox Window Defaults

  • Auto-maximize: enabled
  • Sidebar offset: 300px + 16px gaps
  • Theme: dark
  • Border: 4px

Documentation

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

Potential Improvements

The following suggestions focus on project structure improvements for better modularity and scalability. No code changes are suggested, only organizational improvements.

High Priority

1. Consolidate Use-Cases Directory Structure

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.

2. Remove or Populate Empty Directories

Current Issue: Several directories exist but are empty or underutilized:

  • src/renderer/views/ - Empty, but use-cases/ has 8 Vue files
  • src/main/handlers/ - Empty directory
  • src/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/ to views/
  • Either populate handlers/ with IPC handlers or remove it
  • Consolidate core/ utilities into a single utils/ directory
  • Remove empty directories to reduce confusion

Benefit: Reduced cognitive load, clearer project structure.

3. Consolidate Window Management

Current Issue: Window management is spread across 7 different locations with overlapping responsibilities:

  • src/renderer/services/window-factory.ts - Window creation
  • src/renderer/services/window-service.ts - Window service
  • src/renderer/windows/index.ts - Window manager
  • src/renderer/stores/windowStore.ts - Pinia store
  • src/renderer/composables/windowManager.js - Legacy composable
  • src/renderer/composables/useWinBoxNavigation.ts - Router composable
  • src/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.

4. Consolidate Legacy and Active Scripts

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.

5. Implement Feature-Based Organization

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.

Medium Priority

6. Standardize File Naming Conventions

Current Issue: Inconsistent naming conventions across the project:

  • Services: window-service.ts vs windowService.ts (kebab-case vs camelCase)
  • Use cases: electron-intro.ts vs ElectronIntro.vue
  • Composables: useWinBoxNavigation.ts vs windowManager.js
  • Mixed patterns: main-container.ts vs renderer-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.ts or *-utils.ts

Benefit: Consistent naming makes files easier to find and understand.

7. Add Environment Configuration Files

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.

8. Consolidate Event Systems Documentation

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.

9. Add Module Index Files

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.

10. Separate Test Files from Source

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.

Low Priority

11. Create Shared Constants Module

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.

12. Document Module Dependencies

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.

13. Add Build Output Analysis

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.

14. Consolidate CSS Files

Current Issue: CSS files are scattered:

  • ./index.css (root)
  • ./reset.css (root)
  • src/renderer/index.css
  • src/renderer/reset.css
  • src/renderer/styles/App.css
  • src/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.

15. Consider Monorepo Structure for Future Growth

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.


Summary of Improvement Priorities

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

License

MIT License - see LICENSE file for details.


Contributing

See docs/contributing.md for contribution guidelines.


Support

For issues and questions:

  1. Check documentation
  2. Review troubleshooting guide
  3. Open an issue on GitHub

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors