# marufwp/plugeguard architecture

> Architecture diagram of the GitHub repository marufwp/plugeguard, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/marufwp/plugeguard
- Repository: https://github.com/marufwp/plugeguard

## Overview

##### Project type and purpose
- This is a WordPress security plugin (PHP) that scans PHP files for hard-coded credentials and provides an admin UI for review and removal.
- It integrates with the WordPress admin dashboard under Tools > PlugeGuard Settings.

##### File structure
- plugeguard.php: the plugin bootstrap and core scanner logic; registers hooks, menus and handles AJAX calls.
- assets/css/plugeguard.css: styling for the admin pages.
- assets/js/plugeguard.js & plugeguard-editor.js: client-side code for triggering scans, handling results, and inline editing/removal.
- templates/modal-preloader.php: the HTML fragment used by JS to show a loading modal during scans.
- license.txt and readme.txt: documentation and open-source license metadata.

##### README for additional insights
- Describes features (deep scan, secure file viewing/removal).
- Gives installation steps (upload, activate, navigate to Tools > Settings).

a. Main components
- WordPress Core
- PlugeGuard Plugin
- Scanner Module (PHP code that reads files, applies regex/pattern matching)
- UI Module (admin page renderer, AJAX endpoints)
- Asset Module (CSS/JS files)
- Template Module (modal preloader, result lists)
- File System (all PHP files in wp-content and core)
- WordPress Database (stores plugin settings, scan history if any)
- Admin User (interacts via browser)

b. Relationships and interactions
- Admin User → Browser → WordPress Admin UI (with PlugeGuard menu)
- UI Module → AJAX request → Scanner Module
- Scanner Module → reads File System → detects credential patterns
- Scanner Module → returns scan results to UI Module
- UI Module → renders results, allows removal → sends removal requests back to Scanner Module
- Scanner Module → writes changes to File System
- Plugin reads/writes settings to the WP Database

c. Architectural patterns and design principles
- Hook-based architecture (leverages WP actions/filters)
- Separation of concerns:
- Core plugin logic (plugeguard.php)
- Presentation layer (templates + CSS/JS)
- Scanner engine (pattern matching, file I/O)
- Graceful fallbacks: only PHP 8.0+ required, but backward compatible to 5.6

d. Key technologies, frameworks, libraries
- PHP (WordPress plugin API)
- JavaScript (AJAX, DOM manipulation for scan UI)
- CSS (admin styling)
- WordPress hooks (add_menu_page, wp_ajax_*)

##### Essential details checklist
- All plugin modules (scanner, UI, assets, templates)
- WordPress hook integration points (menu registration, AJAX endpoints)
- Data flows: scan initiation, result delivery, file modification
- External dependencies: file system and database
- User interaction flow from browser to plugin and back

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User and Browser
    User((Admin User)):::user
    Browser["Browser"]:::user

    %% WordPress Core
    subgraph "WordPress Core"
        WPAdmin["WP Admin UI"]:::wordpress
    end

    %% PlugeGuard Plugin Components
    subgraph "PlugeGuard Plugin"
        CoreLogic["Plugin Bootstrap & Core Logic"]:::plugin
        Scanner["Scanner Module"]:::plugin
        UIModule["UI Module"]:::plugin
        subgraph "Asset Module"
            CSS["plugeguard.css"]:::plugin
            JS1["plugeguard.js"]:::plugin
            JS2["plugeguard-editor.js"]:::plugin
        end
        Template["modal-preloader.php"]:::plugin
        Doc1["license.txt"]:::plugin
        Doc2["readme.txt"]:::plugin
    end

    %% External Systems
    FileSys["File System"]:::external
    DB["WordPress Database"]:::external

    %% Interactions and Flows
    User -->|"Interacts"| Browser
    Browser -->|"Access Admin UI"| WPAdmin
    WPAdmin -->|"Displays Plugin Menu"| UIModule
    UIModule -->|"Registers Hooks"| CoreLogic
    UIModule -->|"AJAX request"| Scanner
    Scanner -->|"Reads files"| FileSys
    Scanner -->|"Returns scan results"| UIModule
    UIModule -->|"Renders UI"| Browser
    UIModule -->|"Removal request"| Scanner
    Scanner -->|"Writes files"| FileSys
    CoreLogic -->|"Read/Write settings"| DB

    %% Click Events
    click CoreLogic "https://github.com/marufwp/plugeguard/blob/main/plugeguard.php"
    click CSS "https://github.com/marufwp/plugeguard/blob/main/assets/css/plugeguard.css"
    click JS1 "https://github.com/marufwp/plugeguard/blob/main/assets/js/plugeguard.js"
    click JS2 "https://github.com/marufwp/plugeguard/blob/main/assets/js/plugeguard-editor.js"
    click Template "https://github.com/marufwp/plugeguard/blob/main/templates/modal-preloader.php"
    click Doc1 "https://github.com/marufwp/plugeguard/blob/main/license.txt"
    click Doc2 "https://github.com/marufwp/plugeguard/blob/main/readme.txt"

    %% Styles
    classDef wordpress fill:#D0E8FF,stroke:#0050B3;
    classDef plugin fill:#E6FFEA,stroke:#008A00;
    classDef external fill:#F0F0F0,stroke:#A0A0A0;
    classDef user fill:#FFE7CC,stroke:#B35900;
```
