Introduction & Getting Started
Relevant source files
The following files were used as context for generating this wiki page:
Duplicator is a cross-platform accounting and document management application designed for reproduction collectives using duplicators and photocopiers. It is built using Electron and integrates a Caddy web server and a PHP runtime to provide a portable, self-contained environment for managing printing costs, document imposition, and usage statistics.
Sources: README.md:3-5, package.json:2-6
The system architecture relies on Electron to manage the desktop window and life-cycle of background processes, including a Caddy server for handling HTTP requests and a PHP-SAPI (Server Application Programming Interface) for processing the application logic and interacting with an SQLite database.
Sources: main-caddy.js:58-65, README.md:46-51
Project Overview & Features
Duplicator provides a suite of tools categorized into accounting management and document processing.
Key Functional Categories
- Accounting Management: Calculates cost prices for machines, tracks printing volumes (ink, masters, drums), and generates profitability reports.
- Document Processing: Centralized PDF/PNG library with full-text search, automatic thumbnail generation, and advanced PDF imposition (8/16 pages A5/A6 on A3).
- Technical Stack: Uses an integrated Caddy server for portability and supports integrated PHP servers for Windows.
Sources: README.md:16-44
System Architecture
The application follows a hybrid architecture where Electron acts as a shell for a web-based PHP application.
The diagram shows how Electron spawns Caddy and PHP as child processes, with Caddy acting as a reverse proxy for the PHP backend.
Sources: main-caddy.js:58-65, main-caddy.js:819-860, main-caddy.js:895-920
Getting Started
Prerequisites
Before running the application in a development environment, ensure the following are installed:
- Node.js: Version 18 or newer is required.
- NPM/Yarn: Package managers for dependency installation.
- PHP: Required on Linux systems (version 7.4+ recommended with
gd,sqlite3,mbstring, andxmlextensions).
Sources: README.md:58-60, php-install-guide.html:138-144, test-php-detection.sh:34-40
Installation
- Clone and Install:
npm install - Download Binaries: The project requires platform-specific binaries for Caddy and PHP.
npm run download-all - Run Development Mode:
npm start
Sources: README.md:65-74, package.json:8-12
Process Management and Lifecycle
The main-caddy.js file is the entry point for the Electron application, responsible for initializing the environment and managing child processes.
Backend Initialization Sequence
The application follows a strict startup sequence to ensure the environment is ready before displaying the UI.
This sequence ensures that both the PHP engine and the Caddy proxy are responsive before the user interface is presented.
Core Components Table
| Component | Responsibility | Relevant Files |
|---|---|---|
| Electron Main | Orchestrates OS-level integration, updates, and process spawning. | main-caddy.js, package.json |
| Caddy | Serves static assets and acts as a reverse proxy for PHP. | Caddyfile, caddy/README.md |
| PHP SAPI | Executes the business logic and manages the SQLite database. | app/controler/functions/init.php, php-fpm.conf |
| Auto-Updater | Manages GitHub-based releases and background updates. | main-caddy.js:1150-1180 |
Sources: main-caddy.js:58-65, package.json:54-65, app/controler/functions/init.php:11-20
Platform Specifics
The application handles various OS environments differently to maintain portability:
- Windows: Embeds
php.exeandcaddy.exewithin theasar.unpackeddirectory. It uses a temporaryCaddyfileto handle Windows-style file paths and dynamic port assignment to avoid conflicts. - Linux (AppImage): Often relies on the system PHP. If PHP is missing, the application displays an installation guide (
php-install-guide.html). - macOS: Packaged as a
.dmgwith bundled binaries in the application bundle.
Sources: main-caddy.js:560-580, main-caddy.js:895-915, php-install-guide.html:120-135
PHP Requirements on Linux
If PHP is not detected, users must install the following packages:
sudo apt update
sudo apt install php php-cli php-gd php-sqlite3 php-mbstring php-xml
Sources: php-install-guide.html:122-124, test-php-detection.sh:38-42
Summary
The Duplicator project provides a robust, self-hosted accounting environment by leveraging Electron as a process manager for Caddy and PHP. By integrating these tools, it offers a portable solution that can be deployed as a single executable (AppImage, EXE, or DMG) while maintaining the flexibility of a web-based application. Developers can get started by installing Node.js dependencies and using the provided scripts to fetch required binaries.
Sources: README.md:12-14, main-caddy.js:1320-1330