How prestashop/autoupgrade works
Main Components
• CLI Interface – At the root level, the “bin/console” file provides the entry point to interact with update, backup, and restore commands. This interface will route to a series of command classes (located in classes/Commands and similar folders) and the state management classes (classes/State).
• Web Interface – The module exposes a web assistant through controllers (found in controllers/admin/self-managed) and templating files under “views/templates”. This part builds the UI for human interaction.
• Backup and Restore Process Workflows – Similar workflows exist for backup (BackupInitialization, BackupFiles, BackupDatabase, BackupComplete) and restore (RestoreInitialization, RestoreEmpty/Files, RestoreDatabase, RestoreComplete). These can be drawn as separate but related sequential flows.
• Business Logic & Domain Layer – This layer contains a vast set of PHP classes (under classes/) that implement tasks, state management, parameters, router middleware, and service logic. Components here include Task runners (classes/Task and its subdirectories), service classes (classes/Services), configuration handling (classes/Parameters), and logging utilities (classes/Log).
• Frontend Assets – The “_dev” folder houses TypeScript and SCSS files used to build the user interface, including components (in _dev/src/ts/appUI) and layout/dialog/page management. This part also includes integrations (via Vite configuration files) and Storybook (in the “storybook” folder) for UI component development.
Relationships and Interactions
• CLI commands (from “bin/console”) invoke business logic from the Task Runner classes. These tasks typically follow the sequential steps outlined in the update, backup, or restore workflows.
• The update process begins with initialization (clearing temporary files), then—depending on the “channel” (online versus local)—either downloads the proper archive or directly unzips a local file. Each of these steps interacts with file system related classes and service classes.
• The frontend code (TypeScript and SCSS modules) integrates with API endpoints (under controllers and routes) and enhances the interaction, for example, handling dialogs or setting up pages that correspond to update, backup, and restore functions.
• Testing and linting layers (tests, tests/unit, tests/UI, phpstan configuration) serve to validate both the backend and frontend components.
• The Storybook project exists to provide a sandbox for the UI components. It represents an isolated view of the frontend, which can be shown as an adjunct component.
Architectural Patterns and Design Principles
• Separation of Concerns – There is a clear separation between the user interfaces (CLI and web UI) and the core business logic (classes for tasks, state, and services).
• Modular Design – The file structure shows modularization in directories (e.g., “classes” for backend logic, “_dev” for frontend assets, “tests” for validation, and “storybook” for component demos).
• Extensibility – The use of middleware (classes/Router/Middlewares) and service classes suggests an extensible architecture that can be enhanced or customized.
• Integration-Driven – The module integrates with PrestaShop’s API, uses Composer and NPM ecosystems, and even employs Storybook for UI.
Specific Elements
• Clearly labeled components:
• CLI Command Interface (bin/console)
• Web Controllers (controllers/admin/self-managed)
• Task & Workflow Manager (classes/Task, classes/Task/Runner)
• Service Layer (classes/Services, classes/Parameters)
• State Management Components (classes/State)
• Frontend UI Components (TypeScript/SCSS components in _dev/src/ts/appUI)
• Storybook UI Component Demo (storybook project)
• Testing & Configuration Suites (tests folder, phpstan configuration, etc.)
• Inter-component Data Flow: