Setup & Configuration Wizard
Relevant source files
The following files were used as context for generating this wiki page:
The Setup & Configuration Wizard is the initial entry point for users to initialize the Duplicator application. Its primary purpose is to establish the system's foundational environment, including the creation of the SQLite database, the configuration of hardware machines (duplicators and photocopiers), the definition of pricing models for consumables and paper, and the establishment of administrative security credentials.
The wizard operates in three distinct modes: a choice screen where the user selects the initialization path, an upload screen for restoring existing database files, and a creation screen for manual entry of new system parameters. It ensures that the application has a valid persistence layer and at least one configured machine before allowing access to the main Home Screen.
Sources: app/view/setup.html.php:68-71, app/models/setup_save.php:143-149
Workflow Architecture
The setup process follows a logical flow from environment detection to data persistence. When the application starts, the main Electron process determines the database path and ensures the storage directory exists. If no machines are detected in the database, the system routes the user to the Wizard.
Setup Decision Flow
This diagram illustrates how the system handles initial entry and user choices within the wizard.
Configuration Modes
The wizard provides flexible paths for system initialization based on whether the user is a new or returning administrator.
| Mode | Description | Key Actions |
|---|---|---|
| Choice | Initial landing page of the wizard. | User selects between create or upload paths. |
| Upload | Restores system state from an existing backup. | Accepts .sqlite files up to 50 MB; creates security backup if existing file found. |
| Create | Manual setup of the entire environment. | Configures Admin password, Machine hardware, and Paper pricing. |
Sources: app/view/setup.html.php:87-133
Manual Configuration (Create Mode)
The manual creation mode is a multi-step form that aggregates hardware specifications and pricing logic.
1. Security Initialization
The wizard requires the establishment of an administrator password. This password is hached using the bcrypt algorithm before being stored in the admin_passwords table.
Sources: app/models/setup_save.php:143-144, app/view/setup.html.php:150-167
2. Machine Specifications
Users can add three distinct categories of machines, each triggering a unique pricing configuration sub-form:
- Duplicators: Requires Master and Passage counters. Includes custom "Tambour" (drum) management.
- Ink Photocopiers: Configures unit and pack prices for CMYK (Cyan, Magenta, Yellow, Black) ink.
- Toner Photocopiers: Configures pricing for toner cartridges, developer units, and drum units per page.
Sources: app/view/setup.html.php:171-193, app/models/setup_save.php:103-128
3. Pricing Logic
Paper pricing is established based on the A3 sheet format. The system automatically calculates the A4 price as exactly half of the A3 price.
Sources: app/view/setup.html.php:337-347, app/models/setup_save.php:132-134
Data Persistence & Validation
The setup_save.php model handles the server-side logic for persisting wizard data into the SQLite database.
Logic Flow in setup_save.php
Database Initialization
If the database file is missing or empty upon setup, the system utilizes SQLiteDatabaseManager to build the required schema. Essential tables created during this process include:
duplicopieurs&photocopieursprix(consumable prices)papier(paper prices)admin_passwordscons(consumable tracking)
Sources: app/models/setup_save.php:14-25, app/models/admin/DatabaseManager.php:304-450
Technical Implementation Details
Validation Rules
The client-side validation, powered by jQuery, ensures data integrity before submission:
- Password Match: The submit button is disabled unless the password and confirmation match and meet the 6-character minimum.
- Machine Requirement: At least one machine must be added to the temporary
machinesarray before the final submission is allowed. - Required Fields: Machine name and current counters are mandatory for all hardware entries.
Sources: app/view/setup.html.php:484-500, app/view/setup.html.php:511-525
Environment Integration
The wizard relies on constants and utility functions defined in the application initialization layer.
Sources: app/controler/functions/init.php:45-56
| Element | Source File | Description |
|---|---|---|
pdo_connect() | database.php | Establish connection to the SQLite instance. |
AdminMachineManager | MachineManager.php | Class responsible for inserting hardware records. |
DUPLICATOR_DB_PATH | main-caddy.js | Environment variable pointing to the persistent storage. |
Conclusion
The Setup & Configuration Wizard is a critical infrastructure component that transitions the application from a raw binary state to a functional tool. By enforcing administrative security and hardware baselining, it ensures that all subsequent accounting and document processing features have the necessary parameters to perform accurate calculations.