Desktop Integration
How the Desktop app integrates with the projax API and core packages.
API Server Integration
The Desktop app automatically manages the API server:
Automatic Start
When you launch the Desktop app:
- Checks if API server is running
- Starts API server if not running
- Discovers the API port
- Connects to the API
API Discovery
The Desktop app discovers the API port by:
- Reading
~/.projax/api-port.txt - Trying common ports (3001-3005)
- Checking health endpoint
API Communication
All operations go through the REST API:
GET /api/projects- Fetch projectsPOST /api/projects- Add projectPOST /api/projects/:id/scan- Scan project- And more...
Core Package Integration
The Desktop app uses the core package indirectly through the API:
- Database operations via API
- Test detection via API
- Port scanning via API
Electron Architecture
Main Process
The Electron main process:
- Manages the application window
- Starts/stops the API server
- Handles file system operations
- Manages application lifecycle
Renderer Process
The React renderer:
- Provides the user interface
- Communicates with API server
- Handles user interactions
- Updates UI based on API responses
Preload Script
The preload script:
- Bridges main and renderer processes
- Provides secure IPC communication
- Exposes safe APIs to renderer
Data Flow
User Action (Renderer)
↓
API Request (Renderer)
↓
API Server (Express)
↓
Core Package (Database)
↓
JSON Database
↓
Response (API)
↓
UI Update (Renderer)
Error Handling
The Desktop app handles errors:
- API connection errors
- Network timeouts
- Invalid responses
- Server errors
Errors are displayed:
- In the status bar
- As toast notifications (if available)
- In the console (development mode)
State Management
The Desktop app manages state:
- Project list
- Selected project
- API connection status
- Loading states
Next Steps
- Development - Development setup
- API Documentation - Complete API reference