# Architecture Overview

This document describes the technical structure and data flow of the DazeStack Bulk Plugin Manager.

## Core Components

### 1. Plugin Entry Point (`bulk-plugin-manager.php`)

Defines global constants and bootstraps the `DSBPM_Admin` class.

### 2. Admin Logic (`includes/class-dsbpm-admin.php`)

The central controller of the plugin. It handles:

- **UI Rendering**: Dashboard and Manager pages.
- **AJAX Handlers**: Over 20 handlers for pre-flight, installment, deactivation, etc.
- **REST API**: Health and ability endpoints.
- **Remote Fetching**: Logic to pull stacks from CSV/JSON URLs.

### 3. Upgrader Skin (`includes/class-dsbpm-skin.php`)

A custom implementation of `WP_Upgrader_Skin` that captures installation messages without outputting them directly, allowing for a clean, AJAX-driven feedback loop.

## Data Flow: Bulk Installation

1. **User Input**: User provides slugs or uploads a file via the UI.
2. **Pre-Flight**: (Optional) System checks for existing plugins and potential conflicts.
3. **Queue Creation**: Plugins are added to a JavaScript-managed queue.
4. **Execution**:
   - For each plugin in the queue, an AJAX request is sent to `dsbpm_install`.
   - `DSBPM_Admin` uses `Plugin_Upgrader` with `DSBPM_Upgrader_Skin`.
   - Success/Failure stats are returned and updated in the UI.
5. **Completion**: Metrics are refreshed to reflect the new state of the site.

## Security Engine

Vulnerability checks are performed by integrating with external APIs (like WPScan) when configured. The `Security Bouncer` logic prevents the installation of critical-risk plugins.

## Future Roadmap

- **Performance Canvas**: Real-time performance impact analysis.
- **Stack Guard**: Automatic uptime monitoring for plugin stacks.
- **Multi-site Support**: Simplified rollout for WordPress networks.
