Skip to content

Commit 5cb6a34

Browse files
authored
Merge pull request #10 from JeffGepiga/OptimizedServices
Optimized services
2 parents 243032c + ce2b4e4 commit 5cb6a34

132 files changed

Lines changed: 24686 additions & 20373 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/copilot-instructions.md

Lines changed: 67 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# DevBox Pro - AI Coding Agent Instructions
22

33
## Project Overview
4-
DevBox Pro is an Electron desktop app providing a local PHP development environment with bundled services (PHP, MySQL/MariaDB, Redis, Nginx/Apache, etc.). No Docker required.
4+
DevBox Pro is an Electron desktop app for local PHP and Node.js development with bundled runtimes and services. It supports multi-version PHP, Node.js, MySQL, MariaDB, Redis, PostgreSQL, MongoDB, Nginx, Apache, Mailpit, phpMyAdmin, MinIO, Memcached, and related tooling without Docker.
55

6-
**Tech Stack:** Electron 28 + React 18 + Vite + TailwindCSS
6+
**Tech Stack:** Electron 40 + React 19 + Vite 7 + TailwindCSS 4
77

88
## Architecture
99

@@ -13,16 +13,30 @@ DevBox Pro is an Electron desktop app providing a local PHP development environm
1313
- **Communication**: All cross-process calls go through IPC via `preload.js``window.devbox.*` API
1414
- **Shared Config** (`src/shared/serviceConfig.js`): Single source of truth for service versions and ports
1515

16-
### Manager Pattern (src/main/services/)
17-
Each service domain has a dedicated manager class initialized in `main.js`:
18-
- `ServiceManager` - Starts/stops services (Nginx, MySQL, Redis, etc.), manages ports
19-
- `ProjectManager` - CRUD for projects, virtual host generation, compatibility checks
20-
- `DatabaseManager` - MySQL/MariaDB operations, import/export, credentials
21-
- `BinaryDownloadManager` - Downloads/extracts binaries with progress tracking
22-
- `CliManager` - External CLI tool (`dvp`) for terminal integration
16+
### Service Architecture (Critical)
17+
Service managers have been refactored into thin facade classes plus concern-specific mixins under `src/main/services/<domain>/`.
18+
19+
Examples:
20+
- `ProjectManager.js` composes mixins from `src/main/services/project/`
21+
- `ServiceManager.js` composes mixins from `src/main/services/service/`
22+
- `BinaryDownloadManager.js` composes mixins from `src/main/services/binary/`
23+
- `DatabaseManager.js` composes mixins from `src/main/services/database/`
24+
- `GitManager.js` composes mixins from `src/main/services/git/`
25+
- `CompatibilityManager.js` composes mixins from `src/main/services/compatibility/`
26+
- `SupervisorManager.js` composes mixins from `src/main/services/supervisor/`
2327

2428
Managers receive references to each other via `managers` object for cross-communication.
2529

30+
### Manager Responsibilities
31+
- `ProjectManager` - Project CRUD, install flows, environment sync, vhost orchestration, compatibility checks
32+
- `ServiceManager` - Starts/stops web servers and bundled services, owns runtime config generation
33+
- `DatabaseManager` - Multi-engine database operations, import/export, credentials, metadata
34+
- `BinaryDownloadManager` - Download, extract, import, update, and discover binary assets
35+
- `CliManager` - External `dvp` command integration and PATH/project mapping
36+
- `GitManager` - Git executable discovery, clone/auth, SSH key workflows, progress reporting
37+
- `CompatibilityManager` - Bundled/remote compatibility rules and config normalization
38+
- `SupervisorManager` - Background worker/process management for PHP, Node.js, Python, and queues
39+
2640
### IPC Handler Pattern
2741
All frontend-to-backend calls defined in `src/main/ipc/handlers.js`:
2842
```javascript
@@ -41,34 +55,60 @@ Exposed to renderer via `preload.js` as `window.devbox.projects.create(config)`.
4155
### Service Versioning
4256
Multiple versions of services can run simultaneously on different ports:
4357
- Port offsets defined in `shared/serviceConfig.js` (`VERSION_PORT_OFFSETS`)
44-
- First web server to start claims ports 80/443; second gets 8081/8444
58+
- Base/default ports defined in `shared/serviceConfig.js` (`DEFAULT_PORTS`)
59+
- First web server to start can claim ports `80` and `443`; the alternate server is assigned fallback ports and proxied automatically
4560

4661
### Project Configuration
4762
Projects stored in `configStore.get('projects')` array with:
4863
- Per-project PHP version, web server choice, SSL settings
49-
- `.test` domain generation (e.g., `myproject.test`)
50-
- Virtual host configs auto-generated for Nginx/Apache
64+
- Per-project Node.js version and runtime command configuration for Node projects
65+
- `.test` domain generation (for example `myproject.test`)
66+
- Virtual host configs auto-generated for Nginx and Apache
67+
- Compatibility checks accept both saved-project and flattened UI payloads
5168

5269
### Binary Management
5370
- Binaries downloaded to `app.getPath('userData')/resources/`
5471
- Remote config at `config/binaries.json` defines download URLs
5572
- Extraction runs in worker thread (`extractWorker.js`) to avoid blocking UI
73+
- Installed/versioned assets are discovered via manager mixins under `src/main/services/binary/`
5674

5775
### Process Spawning (Windows)
58-
Always use `windowsHide: true` to prevent console window flashing:
76+
Always use `windowsHide: true` to prevent console window flashing.
77+
78+
Preferred approach:
5979
```javascript
60-
spawn(command, args, { windowsHide: true, shell: process.platform === 'win32' });
80+
spawn(executablePath, args, { windowsHide: true, shell: false });
6181
```
6282

83+
Rules:
84+
- Prefer direct executable paths plus argument arrays
85+
- Avoid `shell: true` with argument arrays; Node now emits `DEP0190` for that pattern
86+
- Only use shell execution when you truly need a shell builtin or wrapper, and then keep it explicit
87+
- Quote filesystem paths inside generated config files because install paths commonly contain spaces on Windows
88+
89+
### Generated Configs
90+
- Runtime web server and service configs under the user data path are derived artifacts
91+
- Do not hand-edit generated Nginx, Apache, or database config files; update the generator code instead
92+
93+
### Tests Mirror Source
94+
- Keep integration coverage in the main manager tests under `tests/main/services/*Manager.test.js`
95+
- Add focused unit tests under subfolders that mirror the mixin layout, such as `tests/main/services/project/` or `tests/main/services/git/`
96+
6397
## Development Workflow
6498

6599
```bash
66100
npm run dev # Start Electron + Vite dev server concurrently
101+
npm run build:renderer
67102
npm run build:win # Build Windows installer
68103
npm run build:mac # Build macOS installer
104+
npm run build:all # Build Windows and macOS packages
105+
npm test # Run all Vitest suites
106+
npm run test:main
107+
npm run test:renderer
108+
npm run test:e2e
69109
```
70110

71-
Renderer dev server runs at `http://localhost:3000`. Main process hot-reloads on save.
111+
Renderer dev server runs at `http://localhost:3000`.
72112

73113
## File Locations
74114

@@ -79,6 +119,8 @@ Renderer dev server runs at `http://localhost:3000`. Main process hot-reloads on
79119
| Preload API | `src/main/preload.js` |
80120
| React pages | `src/renderer/src/pages/` |
81121
| Binary URLs | `config/binaries.json` |
122+
| Compatibility rules | `config/compatibility.json` |
123+
| Service mixins | `src/main/services/<domain>/` |
82124
| App config | `~/.devbox-pro/` (runtime) |
83125

84126
## Common Patterns
@@ -91,7 +133,14 @@ Renderer dev server runs at `http://localhost:3000`. Main process hot-reloads on
91133
### Adding a New Service Version
92134
1. Update `SERVICE_VERSIONS` in `src/shared/serviceConfig.js`
93135
2. Add download URLs to `config/binaries.json`
94-
3. Define port offset in `VERSION_PORT_OFFSETS` if needed
136+
3. Define port offset in `VERSION_PORT_OFFSETS` if the service is versioned and daemonized
137+
4. Update renderer selectors or service metadata if the service is user-facing
138+
139+
### Extending a Manager
140+
1. Prefer adding a new mixin under the relevant `src/main/services/<domain>/` folder
141+
2. Keep the facade thin: constructor state plus `Object.assign(...)`
142+
3. Use `this.methodName()` for cross-mixin calls instead of cross-importing mixins
143+
4. Mirror new mixins with focused tests under `tests/main/services/<domain>/`
95144

96145
### Platform-Specific Code
97146
```javascript
@@ -103,3 +152,5 @@ const exe = process.platform === 'win32' ? 'php.exe' : 'php';
103152
- Test service start/stop with multiple versions running
104153
- Verify port conflicts handled gracefully (alternate ports assigned)
105154
- Test on both Windows and macOS for path separator issues (`path.join` always)
155+
- Prefer targeted Vitest slices for the service or mixin you changed before running broader suites
156+
- When changing generated configs or runtime spawning, cover Windows path and quoting behavior explicitly

README.MD

Lines changed: 63 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
<p align="center">
2-
<img src="https://img.shields.io/badge/Electron-28.0.0-47848F?style=for-the-badge&logo=electron&logoColor=white" alt="Electron">
3-
<img src="https://img.shields.io/badge/React-18.2.0-61DAFB?style=for-the-badge&logo=react&logoColor=black" alt="React">
4-
<img src="https://img.shields.io/badge/Vite-5.0.10-646CFF?style=for-the-badge&logo=vite&logoColor=white" alt="Vite">
5-
<img src="https://img.shields.io/badge/TailwindCSS-3.4.0-38B2AC?style=for-the-badge&logo=tailwind-css&logoColor=white" alt="TailwindCSS">
2+
<img src="https://img.shields.io/badge/Electron-40.0.0-47848F?style=for-the-badge&logo=electron&logoColor=white" alt="Electron">
3+
<img src="https://img.shields.io/badge/React-19.0.0-61DAFB?style=for-the-badge&logo=react&logoColor=black" alt="React">
4+
<img src="https://img.shields.io/badge/Vite-7.0.0-646CFF?style=for-the-badge&logo=vite&logoColor=white" alt="Vite">
5+
<img src="https://img.shields.io/badge/TailwindCSS-4.0.0-38B2AC?style=for-the-badge&logo=tailwind-css&logoColor=white" alt="TailwindCSS">
66
</p>
77

88
# 🚀 DevBox Pro
99

10-
**Run legacy and modern PHP & Node.js apps side by side — no conflicts, no headaches**
10+
**Run legacy and modern PHP and Node.js apps side by side with isolated runtimes, bundled services, and zero Docker setup.**
1111

12-
Maintaining an old PHP 7.4 project while building a new Laravel 11 app on PHP 8.5? Running a Next.js frontend alongside a PHP backend? DevBox Pro makes it effortless. Unlike traditional setups, you can **run multiple PHP and Node.js versions simultaneously** — giving you the freedom to work on legacy applications alongside cutting-edge projects without switching environments or breaking dependencies.
12+
Maintaining an old PHP 7.4 project while building a new Laravel 11 app on PHP 8.5? Running a Next.js frontend alongside a PHP backend? DevBox Pro is built for exactly that workflow. It lets you run multiple PHP, Node.js, database, and web server versions at the same time, with per-project configuration, automatic local domains, compatibility warnings, and bundled tooling.
1313

14-
DevBox Pro bundles everything you need: PHP 7.4 through 8.5, Node.js 16 through 24, MySQL, MariaDB, Redis, Nginx, Apache, and more — all in one standalone desktop app. No Docker, no complex configurations, just instant multi-version development.
14+
DevBox Pro is an Electron desktop app with a React renderer and a Node.js main process. It manages PHP, Node.js, MySQL, MariaDB, Redis, Nginx, Apache, PostgreSQL, MongoDB, MinIO, Memcached, Mailpit, phpMyAdmin, Composer, Git, and more from one local interface.
1515

1616
---
1717

1818
## ✨ Features
1919

2020
### 🐘 Multi-PHP Version Support
21-
- **PHP 7.4, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5** - Run any version side by side
21+
- **PHP 7.4, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5** - Run multiple versions side by side
2222
- Per-project PHP version selection with compatibility validation
2323
- Easy extension management per version with php.ini editor
2424
- Pre-configured for optimal performance
@@ -32,7 +32,7 @@ DevBox Pro bundles everything you need: PHP 7.4 through 8.5, Node.js 16 through
3232
### 🌐 Web Server Options
3333
- **Nginx 1.24, 1.26, 1.28** - High-performance, low memory footprint (recommended)
3434
- **Apache 2.4** - Full .htaccess support, mod_rewrite included
35-
- Multi-version support - run different versions per project
35+
- Front-door ownership and automatic proxying between Nginx and Apache
3636
- Automatic virtual host creation
3737
- HTTP & HTTPS support for every project
3838

@@ -42,15 +42,21 @@ DevBox Pro bundles everything you need: PHP 7.4 through 8.5, Node.js 16 through
4242
| **MySQL** | 5.7, 8.0, 8.4 | Powerful relational database |
4343
| **MariaDB** | 10.6, 10.11, 11.4 | MySQL-compatible, open source |
4444
| **Redis** | 6.2, 7.2, 7.4 | In-memory cache & session storage |
45+
| **PostgreSQL** | 14, 15, 16, 17 | Advanced relational database |
46+
| **MongoDB** | 6.0, 7.0, 8.0 | Document database |
47+
| **Memcached** | 1.6 | Distributed memory caching |
48+
| **MinIO** | Latest | S3-compatible object storage |
4549
| **Mailpit** | Latest | Email testing with SMTP server |
4650
| **phpMyAdmin** | Latest | Web-based database management |
4751
| **Node.js** | 16, 18, 20, 22, 24 (LTS) | JavaScript runtime for projects & tooling |
52+
| **Python** | 3.10, 3.11, 3.12, 3.13 | Runtime for project tooling and workers |
53+
| **SQLite** | 3 | Embedded database runtime |
4854
| **Composer** | Latest | PHP dependency manager |
4955

5056
### 💾 Database Management
51-
- **Multi-version support** - Run MySQL 8.0 and MariaDB 11.4 simultaneously
57+
- **Multi-engine support** - MySQL, MariaDB, PostgreSQL, and MongoDB workflows
5258
- **Per-version data isolation** - Each version has its own data directory
53-
- **Database import/export** with .gz compression support
59+
- **Database import/export** with `.sql`, `.gz`, PostgreSQL, and MongoDB flows
5460
- **Progress tracking** for import/export operations
5561
- **phpMyAdmin integration** for web-based management
5662
- **Automatic database creation** per project
@@ -73,6 +79,7 @@ DevBox Pro bundles everything you need: PHP 7.4 through 8.5, Node.js 16 through
7379
- **Multi-version management** - Keep multiple versions installed
7480
- **One-click updates** - Easy version upgrades
7581
- **Import custom binaries** - Use your own compiled versions
82+
- **Remote definitions** - Binary metadata and compatibility rules can be updated without shipping a new app build
7683

7784
### ☁️ Cloud Configuration Updates
7885
- **Remote binary definitions** - New versions available without app update
@@ -82,7 +89,7 @@ DevBox Pro bundles everything you need: PHP 7.4 through 8.5, Node.js 16 through
8289
- **Version tracking** - Only download when updates are available
8390

8491
### 💻 Terminal Commands
85-
- **Direct command access** - Use `php`, `npm`, `node`, `composer` directly from any terminal
92+
- **Direct command access** - Use `php`, `npm`, `node`, `composer`, `mysql`, `mysqldump`, and related tools directly from any terminal
8693
- **Automatic version detection** - Detects your project and uses the correct PHP/Node.js version
8794
- **Works everywhere** - VS Code, Windows Terminal, PowerShell, or any terminal emulator
8895
- **No prefix needed** - Just run `php artisan migrate` instead of complex paths
@@ -166,7 +173,7 @@ mysqldump -u root mydb > backup.sql
166173
### Prerequisites
167174

168175
- Node.js 24+
169-
- npm or yarn
176+
- npm
170177
- Git
171178

172179
### Setup
@@ -179,19 +186,23 @@ cd DevBoxPro
179186
# Install dependencies
180187
npm install
181188

182-
# Start development server
189+
# Start the Electron app with the Vite renderer dev server
183190
npm run dev
184191

185-
# Build for production
186-
npm run build
192+
# Build the renderer bundle only
193+
npm run build:renderer
187194

188-
# Create distribution package
189-
npm run dist
195+
# Build platform packages
196+
npm run build:win
197+
npm run build:mac
198+
npm run build:all
190199
```
191200

201+
The renderer dev server runs at `http://localhost:3000`.
202+
192203
### Testing
193204

194-
DevBox Pro includes a comprehensive test suite covering Unit, Integration, and End-to-End (E2E) scenarios.
205+
DevBox Pro includes unit, integration, and end-to-end coverage.
195206

196207
```bash
197208
# Run all tests
@@ -207,7 +218,7 @@ npm run test:renderer
207218
npm run test:e2e
208219
```
209220

210-
The E2E tests are built using Playwright and cover the full project lifecycle, database workflows, binary downloads, SSL configuration, and settings persistence.
221+
The test suite covers the main-process managers, the renderer, and Playwright end-to-end scenarios for project creation, binaries, databases, SSL, and settings persistence.
211222

212223
### Project Structure
213224

@@ -216,19 +227,22 @@ DevBoxPro/
216227
├── src/
217228
│ ├── main/ # Electron main process
218229
│ │ ├── services/
219-
│ │ │ ├── BinaryDownloadManager.js # Binary downloads and archive extraction
220-
│ │ │ ├── CliManager.js # External terminal integration
221-
│ │ │ ├── CompatibilityManager.js # Version compatibility rules and updates
222-
│ │ │ ├── DatabaseManager.js # Database operations (CRUD, import/export)
223-
│ │ │ ├── GitManager.js # Git clone and SSH key workflows
224-
│ │ │ ├── LogManager.js # Log management
225-
│ │ │ ├── PhpManager.js # PHP version management
226-
│ │ │ ├── ProjectManager.js # Project lifecycle and vhost generation
227-
│ │ │ ├── ServiceManager.js # Web servers, databases, and background services
228-
│ │ │ ├── SslManager.js # SSL certificates
229-
│ │ │ ├── SupervisorManager.js # Process supervisor
230-
│ │ │ ├── UpdateManager.js # App updates
231-
│ │ │ ├── extractWorker.js # Worker-thread archive extraction
230+
│ │ │ ├── BinaryDownloadManager.js # Thin facade for binary downloads and extraction
231+
│ │ │ ├── CliManager.js # Thin facade for terminal integration
232+
│ │ │ ├── CompatibilityManager.js # Thin facade for compatibility rules and updates
233+
│ │ │ ├── DatabaseManager.js # Thin facade for multi-engine DB operations
234+
│ │ │ ├── GitManager.js # Thin facade for Git clone and SSH workflows
235+
│ │ │ ├── ProjectManager.js # Thin facade for project lifecycle and vhosts
236+
│ │ │ ├── ServiceManager.js # Thin facade for service lifecycle and config generation
237+
│ │ │ ├── SupervisorManager.js # Thin facade for worker and process supervision
238+
│ │ │ ├── binary/ # Binary manager mixins
239+
│ │ │ ├── cli/ # CLI manager mixins
240+
│ │ │ ├── compatibility/ # Compatibility manager mixins
241+
│ │ │ ├── database/ # Database manager mixins
242+
│ │ │ ├── git/ # Git manager mixins
243+
│ │ │ ├── project/ # Project manager mixins
244+
│ │ │ ├── service/ # Service manager mixins
245+
│ │ │ ├── supervisor/ # Supervisor manager mixins
232246
│ │ │ └── ...
233247
│ │ ├── ipc/
234248
│ │ │ └── handlers.js # IPC communication
@@ -282,15 +296,22 @@ DevBoxPro/
282296
|---------|-------------|
283297
| PHP Projects | 8000+ (auto-assigned) |
284298
| MySQL | 3306 |
285-
| MariaDB | 3306 (or 3307 if MySQL is running) |
299+
| MariaDB | 3310 |
286300
| Redis | 6379 |
301+
| PostgreSQL | 5432 |
302+
| MongoDB | 27017 |
303+
| Memcached | 11211 |
304+
| MinIO API | 9000 |
305+
| MinIO Console | 9001 |
287306
| Mailpit SMTP | 1025 |
288307
| Mailpit Web | 8025 |
289308
| phpMyAdmin | 8080 |
290309
| Nginx HTTP | 80 |
291310
| Nginx HTTPS | 443 |
292-
| Apache HTTP | 80 (or 8081 if Nginx is on 80) |
293-
| Apache HTTPS | 443 |
311+
| Apache HTTP | 8081 when Apache is not the front-door server |
312+
| Apache HTTPS | 8444 when Apache is not the front-door server |
313+
314+
Web server ownership is dynamic. The first active web server can claim ports `80` and `443`, while the other is assigned alternate ports and proxied automatically.
294315

295316
### Environment Variables
296317

@@ -325,10 +346,12 @@ MAIL_PORT=1025
325346

326347
## 🛠️ Technologies
327348

328-
- **Electron** - Cross-platform desktop framework
329-
- **React** - UI library
330-
- **Vite** - Fast build tool
331-
- **TailwindCSS** - Utility-first CSS
349+
- **Electron 40** - Cross-platform desktop framework
350+
- **React 19** - UI library
351+
- **Vite 7** - Build and dev server
352+
- **TailwindCSS 4** - Styling pipeline
353+
- **Vitest** - Unit and integration testing
354+
- **Playwright** - End-to-end testing
332355
- **electron-builder** - Distribution packaging
333356

334357
---

0 commit comments

Comments
 (0)