MageTech Solutions

MTS WP Performance Engine

Technical Architecture & Specification Document — Enterprise-Grade WordPress Performance Optimization & Monitoring Plugin

Version 1.0.0
WordPress 6.4+ | PHP 8.2+
MageTech Solutions
August 2026
One-Time Price ₹7,999 No subscriptions • Lifetime updates

1 Executive Summary

MTS WP Performance Engine is an enterprise-grade WordPress plugin that provides a complete performance control center — not just a caching solution. It continuously measures, optimizes, and monitors WordPress site performance through a systematic Scan → Detect → Recommend → Optimize → Verify → Monitor workflow.

i
Core Value Proposition: Unlike simple cache plugins that deliver static HTML, MTS WP Performance Engine addresses the root causes of poor performance — unoptimized assets, bloated databases, render-blocking resources, and missing best practices — while providing rollback safety and continuous monitoring.

At a Glance

MetricDetail
Price₹7,999 One-Time (no subscriptions)
Total Classes42 PHP classes across 9 modules
Admin Pages17 dedicated management screens
Scanner Types6 specialized scanners
Optimizers7 optimization modules with rollback
REST API Endpoints8 authenticated endpoints
WP-CLI Commands8 command groups
Test Coverage132 test methods across 8 test suites
External DependenciesZero (no third-party libraries)

2 Problem Statement — Why WordPress Needs This

2.1 The WordPress Performance Crisis

WordPress powers over 43% of the web, yet performance remains its most persistent challenge. According to Google's web vitals data:

2.2 Why Existing Solutions Fall Short

ApproachWhat It DoesWhat It Misses
Cache PluginsServe static HTMLDon't optimize assets, database, or images
CDN ServicesEdge deliveryDon't address origin server issues
Image OptimizersCompress imagesDon't address CSS, JS, or database
DB Cleanup ToolsRemove revisions/transientsDon't optimize frontend assets
Asset OptimizersMinify CSS/JSDon't monitor performance over time

2.3 The Gap MTS WP Performance Engine Fills

No single WordPress plugin provides the complete cycle of scanning → detection → recommendation → safe optimization → verification → continuous monitoring. MTS WP Performance Engine is designed as a performance control center that addresses all layers of the WordPress stack simultaneously.

Key Insight: Performance is not a one-time fix. It requires continuous measurement, targeted optimization, and ongoing monitoring. MTS WP Performance Engine is the only WordPress plugin built around this philosophy.

3 Product Overview & Key Differentiators

3.1 What Makes This Different

🔍

Performance Scanning

6 specialized scanners analyze every layer of your WordPress site — from server response times to database health.

🚀

Safe Optimization

Every optimization has Preview → Apply → Rollback. Safe mode prevents accidental damage. Never irreversible without confirmation.

📈

Continuous Monitoring

Scheduled scans track performance trends over time. See historical scores and detect regressions before users notice.

🛠

Zero Dependencies

No external libraries, no API calls, no telemetry. Everything runs on your server. Your data never leaves.

3.2 Feature Comparison Matrix

Feature MTS Engine Cache Plugins Optimizer Plugins
Performance Scoring✓ Weighted algorithm
Core Web Vitals Monitoring✓ TTFB, queries, memory
CSS Optimization✓ Minify, critical, unusedPartial
JS Optimization✓ Minify, defer, delayPartial
Image Optimization✓ Lazy, WebP, AVIF, responsivePartial
Font Optimization✓ Preload, preconnect, displayPartial
Database Cleanup✓ Full cleanup + autoloadPartial
Cache Diagnostics✓ Detection + recommendations✓ (creates cache)
CDN Configuration✓ Detection + setup
Rollback Safety✓ Per-module rollback
Performance History✓ 90-day trend tracking
REST API✓ 8 endpointsSomeSome
WP-CLI✓ 8 commands
WooCommerce Safe✓ Auto-detect + excludeVariesVaries
Telemetry/Tracking✗ ZeroSomeSome

4 Technical Architecture

4.1 High-Level Architecture

┌─────────────────────────────────────────────────────────────────────────┐
│                        MTS WP Performance Engine                       │
├─────────────────────────────────────────────────────────────────────────┤
│                                                                         │
│  ┌──────────────┐  ┌──────────────┐  ┌──────────────┐  ┌───────────┐  │
│  │   Scanner     │  │ Optimization │  │   Frontend    │  │ Monitoring │  │
│  │   Engine      │  │   Engine     │  │  Optimizer    │  │   Engine   │  │
│  │              │  │              │  │              │  │           │  │
│  │ ┌──────────┐ │  │ ┌──────────┐ │  │ ┌──────────┐ │  │ ┌───────┐ │  │
│  │ │Core Vitals│ │  │ │   CSS    │ │  │ │  CSS     │ │  │ │Cron   │ │  │
│  │ │  Assets   │ │  │ │   JS     │ │  │ │  JS      │ │  │ │Beacon │ │  │
│  │ │  Images   │ │  │ │  Images  │ │  │ │  Fonts   │ │  │ │Alerts │ │  │
│  │ │ Database  │ │  │ │  Fonts   │ │  │ │  Cache   │ │  │ └───────┘ │  │
│  │ │ Security  │ │  │ │ Database │ │  │ │  Headers │ │  │           │  │
│  │ │Compatibil.│ │  │ │  Cache   │ │  │ └──────────┘ │  │           │  │
│  │ └──────────┘ │  │ │Heartbeat │ │  │              │  │           │  │
│  │   Score Calc │  │ └──────────┘ │  │              │  │           │  │
│  └──────────────┘  │  Rollback    │  └──────────────┘  └───────────┘  │
│                     │  Manager     │                                    │
│                     └──────────────┘                                    │
│                                                                         │
├─────────────────────────────────────────────────────────────────────────┤
│                      Integration Layer                                  │
│  ┌──────────────┐  ┌──────────────┐  ┌──────────────┐  ┌───────────┐  │
│  │  REST API    │  │   WP-CLI     │  │ Admin UI     │  │   AJAX    │  │
│  │  8 endpoints │  │  8 commands  │  │  17 pages    │  │  handlers │  │
│  └──────────────┘  └──────────────┘  └──────────────┘  └───────────┘  │
│                                                                         │
├─────────────────────────────────────────────────────────────────────────┤
│                    WordPress Integration Layer                          │
│  wp_head | wp_footer | script_loader_tag | send_headers |              │
│  cron_schedules | rest_api_init | admin_menu | admin_enqueue_scripts   │
└─────────────────────────────────────────────────────────────────────────┘

4.2 Module Dependency Map

mts-wp-performance-engine.php          ← Plugin Bootstrap
  │
  ├── includes/class-mts-pe-core.php   ← Main Orchestrator
  │     ├── Scanner Engine             ← Reads scan data
  │     ├── Optimization Engine        ← Manages optimizers
  │     ├── Admin Dashboard            ← Registers menus
  │     ├── REST Controller            ← API routes
  │     └── Frontend Hooks             ← Applies optimizations
  │
  ├── includes/scanner/                ← 8 Scanner Classes
  │     ├── class-scanner-engine.php       ← Orchestrator
  │     ├── class-scanner-core-vitals.php  ← TTFB, queries, memory
  │     ├── class-scanner-assets.php       ← CSS/JS analysis
  │     ├── class-scanner-images.php       ← Image detection
  │     ├── class-scanner-database.php     ← DB health
  │     ├── class-scanner-security.php     ← Security config
  │     ├── class-scanner-compatibility.php ← Plugin/theme detection
  │     └── class-performance-score.php    ← Weighted scoring
  │
  ├── includes/optimization/           ← 9 Optimization Classes
  │     ├── class-optimization-engine.php  ← Orchestrator
  │     ├── class-optimizer-css.php        ← CSS minify/critical/unused
  │     ├── class-optimizer-js.php         ← JS minify/defer/delay
  │     ├── class-optimizer-images.php     ← Lazy/WebP/AVIF
  │     ├── class-optimizer-fonts.php      ← Preload/preconnect
  │     ├── class-optimizer-database.php   ← Cleanup/vacuum
  │     ├── class-optimizer-cache.php      ← Headers/browser cache
  │     ├── class-optimizer-heartbeat.php  ← Frequency control
  │     └── class-rollback-manager.php     ← State snapshots
  │
  ├── includes/admin/                  ← 19 Admin Classes
  ├── includes/api/                    ← 3 REST API Classes
  ├── includes/cli/                    ← 2 WP-CLI Classes
  └── includes/frontend/               ← 2 Frontend Classes

4.3 File Structure

mts-wp-performance-engine/
├── mts-wp-performance-engine.php       ← Bootstrap (PSR-4 autoloader)
├── composer.json                       ← Dev dependencies only
├── uninstall.php                       ← Cleanup on uninstall
│
├── includes/
│   ├── class-mts-pe-core.php           ← Main orchestrator
│   ├── class-mts-pe-activator.php      ← DB tables, defaults, cron
│   ├── class-mts-pe-deactivator.php    ← Cleanup on deactivation
│   │
│   ├── scanner/                        ← 8 files
│   ├── optimization/                   ← 9 files
│   ├── admin/                          ← 19 files
│   ├── api/                            ← 3 files
│   ├── cli/                            ← 2 files
│   └── frontend/                       ← 2 files
│
├── assets/
│   ├── css/admin.css                   ← Admin styling (CSS variables)
│   └── js/
│       ├── admin-dashboard.js          ← Dashboard interactivity
│       ├── admin-scan.js               ← Scan trigger + progress
│       ├── admin-charts.js             ← Canvas-based history charts
│       └── admin-settings.js           ← Settings form enhancements
│
├── languages/mts-wp-performance-engine.pot  ← Translation template
├── tests/                              ← 10 test files
└── doc/                                ← Documentation

5 Module Specifications

5.1 Scanner Engine

ScannerClassWhat It AnalyzesKey Metrics
Core VitalsMts_Pe_Scanner_Core_VitalsServer response, queries, memoryTTFB, query count, memory peak, page size
AssetsMts_Pe_Scanner_AssetsCSS/JS files, render-blockingFile sizes, blocking count, inline count
ImagesMts_Pe_Scanner_ImagesMedia library optimizationLazy loading status, WebP support, large images
DatabaseMts_Pe_Scanner_DatabaseDB health and bloatAutoload size, revisions, transients, orphans
SecurityMts_Pe_Scanner_SecurityServer config, caching, headersSSL, object cache, page cache, security headers
CompatibilityMts_Pe_Scanner_CompatibilityPlugin/theme conflictsWooCommerce, builders, cache plugins, CDN

5.2 Performance Score Algorithm

The weighted scoring algorithm calculates a 0–100 score based on category weights:

CategoryWeightWhat It Measures
Core Web Vitals40%TTFB, query count, memory usage, page size, object cache
Assets20%Render-blocking resources, CSS/JS sizes, deferred scripts
Images15%Lazy loading, WebP support, oversized images
Database15%Autoload size, revisions, expired transients, orphans
Security10%SSL, object cache, page cache, security headers

5.3 Optimization Engine

ModuleCapabilitiesSafety Features
CSS OptimizerMinification, critical CSS, unused detectionExclusion list, rollback
JS OptimizerMinification, defer, delay (async execution)jQuery exclusion, per-script control
Image OptimizerLazy loading, WebP/AVIF, responsive imagesExcluded pages, above-fold detection
Font OptimizerPreload, preconnect, font-display swapGoogle Fonts auto-detect
Database OptimizerRevisions, transients, orphans, autoloadDry-run, configurable limits
Cache OptimizerCache-control headers, browser cachingSmart TTL per page type
Heartbeat OptimizerFrequency control, screen disablePer-screen granularity

6 Scanning Engine — Deep Dive

6.1 Timing Mechanism

The scanner hooks into WordPress at two critical points to measure server response time:

// Hook at earliest possible point add_action( 'template_redirect', array( $this, 'start_timing' ), 1 ); // Hook at latest possible point add_action( 'shutdown', array( $this, 'end_timing' ), 999 );

6.2 Asset Analysis

The asset scanner introspects WordPress's global $wp_styles and $wp_scripts registries to analyze all enqueued resources without modifying them. It measures:

6.3 Database Health Analysis

Direct database queries (using $wpdb->prepare()) analyze:

6.4 Compatibility Detection

The compatibility scanner uses multiple detection methods:

Detection MethodExamples
Class existence checksclass_exists('WooCommerce')
Constant checksdefined('ELEMENTOR_VERSION')
Active plugin listScans wp_options active_plugins
Drop-in detectionobject-cache.php existence

7 Optimization Engine — Deep Dive

7.1 Optimization Lifecycle

User clicks "Optimize"
        │
        ▼
┌───────────────────┐
│  Safe Mode Check  │──── Enabled? ──── Return preview + confirm
└───────────────────┘
        │ Disabled
        ▼
┌───────────────────┐
│   Store State     │  ← Snapshot current state for rollback
│   (Rollback Mgr)  │
└───────────────────┘
        │
        ▼
┌───────────────────┐
│  Apply Changes    │  ← Modify files, options, or hooks
│  (Per Module)     │
└───────────────────┘
        │
        ▼
┌───────────────────┐
│  Record Action    │  ← Log timestamp, module, result
└───────────────────┘
        │
        ▼
┌───────────────────┐
│  Fire Action Hook │  ← do_action('mts_pe_optimization_applied')
└───────────────────┘
        │
        ▼
   Return Result
    

7.2 Rollback Manager

The rollback manager stores state snapshots before each optimization. Each module captures its own state format:

ModuleWhat's StoredRollback Action
CSSMinified file list, critical CSSRemove minified files, clear critical CSS
JSModified/deferred/delayed file listsRemove minified files, clear defer/delay
ImagesConversion recordsRemove filter hooks, clear records
DatabaseDeletion counts (revisions, transients)Informative only (deletions are permanent)
FontsModified file listsRemove preload/preconnect hooks
CacheHeaders modification flagRemove send_headers hook
HeartbeatModification flagRemove heartbeat_settings filter
!
Important: Database deletions (revisions, transients, orphans) cannot be truly rolled back. The rollback manager stores deletion counts for audit purposes but cannot restore deleted data.

8 Admin UI Architecture

8.1 Menu Structure

The plugin registers a top-level WordPress admin menu with 17 sub-pages organized into logical groups:

MTS Performance (dashicons-performance)
│
├── Dashboard              ← Score card, vitals, opportunities
├── Performance Scan       ← Run scan, view results
├── Core Web Vitals        ← Detailed vitals with history
│
├── ── Assets ─────────────
├── Assets                 ← CSS/JS file table with sizes
├── CSS                    ← Minify, critical CSS, unused
├── JavaScript             ← Minify, defer, delay
├── Images                 ← Lazy, WebP, AVIF, responsive
├── Fonts                  ← Preload, preconnect, display
│
├── ── System ─────────────
├── Database               ← Cleanup controls
├── Cache                  ← Diagnostics
├── CDN                    ← Configuration
│
├── ── Insights ───────────
├── Recommendations        ← Priority-based suggestions
├── Monitoring             ← Scheduled scan config
├── History                ← Performance trends
│
├── ── Configuration ──────
├── Settings               ← Global options
├── Tools                  ← Export, cleanup
└── System Info            ← PHP, MySQL, server details

8.2 UI Design Principles

8.3 Dashboard Components

🎯

Score Circle

SVG-based circular progress indicator with animated stroke-dashoffset. Color changes based on score (green/yellow/red).

📊

Vitals Grid

4-column grid showing LCP, INP, CLS, TTFB with color-coded status badges.

Opportunities

Click-through cards linking to specific optimization pages with issue counts.

📈

History Chart

Canvas-rendered sparkline chart showing performance score trends over time.

9 REST API Specification

9.1 Endpoint Reference

MethodEndpointDescriptionAuth
POST/mts-pe/v1/scanRun full performance scanmanage_options
GET/mts-pe/v1/metricsGet latest scan metricsmanage_options
GET/mts-pe/v1/historyGet performance historymanage_options
GET/mts-pe/v1/recommendationsGet optimization recommendationsmanage_options
GET/mts-pe/v1/settingsGet current settingsmanage_options
POST/mts-pe/v1/settingsUpdate settingsmanage_options
POST/mts-pe/v1/optimizeRun optimization for a modulemanage_options
POST/mts-pe/v1/rollbackRollback optimizationmanage_options
GET/mts-pe/v1/system-infoGet system informationmanage_options

9.2 Authentication

All endpoints require manage_options capability. The plugin uses WordPress application passwords or nonce-based authentication for admin users. The X-WP-Nonce header is used for AJAX requests from the admin dashboard.

9.3 Response Format

// Success response { "score": 92, "core_vitals": { "ttfb": 0.32, "total_queries": 12, "memory_peak": 36700160 } } // Error response { "code": "mts_pe_rest_forbidden", "message": "You do not have permission.", "data": { "status": 403 } }

10 WP-CLI Integration

10.1 Command Reference

CommandDescriptionOptions
wp mts-performance scanRun full performance scan--format=table|json
wp mts-performance statusShow current performance status--format=table|json|yaml
wp mts-performance optimizeRun optimizations--module=css|js|... --force --dry-run
wp mts-performance cleanupDatabase cleanup--dry-run
wp mts-performance reportGenerate performance report--format=table|json|csv
wp mts-performance historyShow performance history--format=table|json
wp mts-performance rollbackRollback last optimization<module>
wp mts-performance settingsView/update settings[<key>] [<value>]

10.2 Example Usage

# Run a scan and output JSON wp mts-performance scan --format=json # Optimize CSS only wp mts-performance optimize --module=css # Database cleanup with dry-run wp mts-performance cleanup --dry-run # Generate report for CI/CD wp mts-performance report --format=json > report.json

11 Security Architecture

11.1 Security Layers

🔒

Capability Checks

Every AJAX handler and REST endpoint verifies current_user_can('manage_options') before processing.

🔑

Nonce Verification

All state-changing requests require valid nonces via check_ajax_referer() or wp_verify_nonce().

🛡

Input Sanitization

All user input is sanitized with sanitize_text_field(), absint(), esc_url_raw() before processing.

📄

Output Escaping

All echoed output uses esc_html(), esc_attr(), esc_url(), or wp_kses_post().

🔐

Prepared SQL

All database queries use $wpdb->prepare() with proper placeholders. No raw SQL interpolation.

🚫

No Telemetry

Zero external API calls. No data leaves the server. No tracking, no analytics, no phone-home.

12 Performance Safety & Rollback

12.1 Safe Mode

By default, the plugin operates in Safe Mode. When enabled, every optimization must be explicitly confirmed by the user before changes are applied. The flow:

  1. User clicks "Optimize" on a module
  2. Plugin shows a preview of what will change
  3. User must confirm (or toggle safe mode off)
  4. Plugin stores current state for rollback
  5. Plugin applies the optimization

12.2 Rollback System

The rollback manager maintains up to 10 state snapshots per module. Each snapshot captures the exact state before optimization was applied. Rollback restores the previous state by:

12.3 Compatibility Exclusions

Before any optimization, the compatibility scanner checks for conflicts:

Plugin/ThemeWhat's Excluded
WooCommerceCheckout scripts, payment gateways, cart fragments
ElementorEditor assets, widget scripts
Divi BuilderVisual builder scripts and styles
Bricks BuilderBuilder frontend assets
WPBakeryEditor and frontend assets
Cache PluginsSkips if another cache plugin is active

13 Compatibility Matrix

13.1 WordPress Compatibility

RequirementMinimumRecommendedTested
WordPress6.46.7+6.4 – 7.1
PHP8.28.38.2.12
MySQL5.78.0+8.0
MariaDB10.410.6+10.6

13.2 Plugin Compatibility

PluginStatusNotes
WooCommerceCompatibleAuto-detected, safe exclusions applied
ElementorCompatibleEditor assets excluded from optimization
Divi BuilderCompatibleBuilder scripts excluded
Bricks BuilderCompatibleFrontend assets excluded
WPBakeryCompatibleEditor assets excluded
WP Super CacheCoexistsDoes not create its own cache
WP RocketCoexistsDetects and skips conflicting ops
LiteSpeed CacheCoexistsDetects and skips conflicting ops

14 Data Flow & Storage

14.1 WordPress Options Used

Option KeyTypePurpose
mts_pe_settingsArray (serialized)All plugin settings in a single option
mts_pe_last_scanArray (JSON)Most recent scan results
mts_pe_historyArray (capped at 90)Historical scan scores
mts_pe_rollbackArray (per module)Rollback state snapshots
mts_pe_optimization_logArray (capped at 100)Optimization action log
mts_pe_css_minifiedArray (handle → URL)Minified CSS file mapping
mts_pe_js_modifiedArray (handle → URL)Minified JS file mapping
mts_pe_images_convertedArrayImage conversion records
mts_pe_cache_headersBooleanCache headers applied flag
mts_pe_heartbeat_modifiedArrayHeartbeat modification records

14.2 Custom Database Table

// mts_pe_history table (created on activation) CREATE TABLE wp_mts_pe_history ( id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY, scan_date DATETIME NOT NULL, performance_score INT UNSIGNED DEFAULT 0, lcp DECIMAL(8,3) DEFAULT 0, cls DECIMAL(5,3) DEFAULT 0, inp INT UNSIGNED DEFAULT 0, ttfb DECIMAL(8,3) DEFAULT 0, page_size BIGINT UNSIGNED DEFAULT 0, total_requests INT UNSIGNED DEFAULT 0, scan_data LONGTEXT, KEY scan_date (scan_date), KEY performance_score (performance_score) );

15 Technical Specifications

SpecificationDetail
LanguagePHP 8.2+, JavaScript (ES6+)
WordPress Coding StandardsWPCS 3.0 compliant
AutoloadingCustom SPL autoloader (PSR-4 + WordPress naming)
Database1 custom table, wp_options for settings
Admin UIPHP-rendered pages, vanilla JS, CSS custom properties
APIWordPress REST API (namespace: mts-pe/v1)
CLIWP-CLI (command: wp mts-performance)
CronWordPress Cron (configurable hourly/daily/weekly)
Asset LoadingConditional, per admin page only
File Size~350KB total (PHP + CSS + JS)
Memory Usage~36MB peak (standard WP load)
External DependenciesNone (zero third-party libraries)
TelemetryNone (zero external API calls)
Translation ReadyYes (.pot file included)
LicenseGPL-2.0-or-later

16 Developer Hooks & Filters

16.1 Action Hooks

HookParametersFired When
mts_pe_scan_complete$results (array)After a full performance scan completes
mts_pe_optimization_applied$module, $resultAfter an optimization is applied
mts_pe_optimization_rolled_back$module, $resultAfter an optimization is rolled back

16.2 Filter Hooks

FilterParametersPurpose
mts_pe_performance_score$score, $resultsModify the calculated performance score
mts_pe_excluded_scripts$excluded (array)Add scripts to the exclusion list
mts_pe_excluded_styles$excluded (array)Add styles to the exclusion list
mts_pe_scan_results$results (array)Modify scan results before storage

17 Testing Strategy

17.1 Test Suites

Test FileTestsCovers
test-security.php13Nonces, capabilities, sanitization, escaping
test-scanner.php22All 6 scanners, scoring algorithm, full scan
test-optimization.php22Apply/rollback for all 7 modules, safe mode
test-database.php14Revisions, transients, orphans, cleanup
test-rest-api.php14All endpoints, auth, permissions
test-wp-cli.php16CLI commands, help docs
test-compatibility.php13Plugin/theme detection
test-cron.php16Scheduling, intervals, history

18 Deployment & Requirements

18.1 Pricing

One-Time Price: ₹7,999 — No subscriptions, no recurring fees. Lifetime updates and support included. Single-site license.

18.2 Server Requirements

ComponentMinimumNotes
PHP8.2Required for typed properties, enums, readonly
WordPress6.4Block API, modern REST API
MySQL5.7JSON support required
Memory128MBPHP memory_limit
Execution Time30sFor database cleanup operations

18.3 Installation

# Via Composer (recommended) composer require magetechsol/mts-wp-performance-engine # Or manual installation 1. Upload plugin zip to WordPress admin → Plugins → Add New 2. Activate the plugin 3. Navigate to MTS Performance → Settings 4. Configure optimization preferences 5. Run your first scan from MTS Performance → Performance Scan
No build step required. The plugin ships with pre-compiled CSS and vanilla JavaScript. No npm install, no webpack, no node_modules. Just upload and activate.