# netx/netx-wordpress-plugin architecture

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

- Interactive diagram: https://gitdiagram.com/netx/netx-wordpress-plugin
- Repository: https://github.com/netx/netx-wordpress-plugin

## Overview

##### Project type and purpose
- This is a WordPress plugin (“netx-wordpress-plugin”) whose job is to integrate a WordPress site with the external NetX digital asset management system via its REST API.
- Key features:
- Server-side PHP code that hooks into WP (admin pages, media manager)
- A REST-client library (under includes/netx_rest)
- Proxy and custom endpoints to surface NetX assets in WP
- A small front-end (JS/CSS) to power the asset-picker UI

##### File structure
- Top-level plugin entry points:
- admin.php (admin UI bootstrap)
- netx-client.php / netx-media-manager.php / netx-media.php (main plugin hooks and media-manager integration)
- proxy.php (asset proxy to avoid CORS, cache control)
- endpoints/asset.php: an AJAX‐style endpoint used by the front end or WP Ajax to fetch assets
- includes/:
- netxRestWrapper.php / netxWordPressAssetLoader.php – high-level wrappers
- netx_rest/: a full REST client, factories, beans, caching proxy, connection, logging via PEAR::Log
- scripts/: client-side JavaScript (clientScript.js, script.js), CSS (style.css) for the asset-picker modal

##### README for additional insights
- Minimal readme: confirms “WordPress plugin for NetX.”

## Diagram (Mermaid)

```mermaid
graph TB
    %% External Client
    Browser["Browser"]:::client

    %% External Service
    NetXAPI["NetX REST API"]:::external

    %% WordPress Core Container
    subgraph "WordPress Core"
        WPHooks["Hooks & Filters"]:::wp
        subgraph "NetX WordPress Plugin" 
            %% Main Entrypoint
            MainEntry["NetX Plugin Hooks (netx-client.php)"]:::plugin
            AdminUI["Admin UI Module (admin.php)"]:::plugin
            subgraph "Media Manager Integration"
                MediaMgr["netx-media-manager.php"]:::plugin
                MediaExt["netx-media.php"]:::plugin
            end
            subgraph "Endpoints"
                AssetEP["AJAX Asset Endpoint (endpoints/asset.php)"]:::plugin
                ProxyEP["Asset Proxy (proxy.php)"]:::plugin
            end
            subgraph "REST Client Library"
                Connection["netxConnection"]:::rest
                RestClient["netxRestClient"]:::rest
                CachingProxy["netxCachingProxy"]:::rest
                Beans["netxBean"]:::rest
                Factory["netxBeanFactory"]:::rest
                HttpLayer["netxHttp"]:::rest
                Config["netxConfig"]:::rest
                Facade["netxNetX"]:::rest
                Domain["Domain Classes"]:::rest
            end
            subgraph "High-Level Wrappers"
                Wrapper["netxRestWrapper"]:::plugin
                AssetLoader["WP Asset Loader"]:::plugin
            end
            subgraph "Logging"
                PEARLog["PEAR::Log Bootstrap"]:::log
                Handlers["Log Handlers"]:::log
                LogFiles["Log Files"]:::log
            end
            subgraph "Front-End Assets"
                JSClient["clientScript.js"]:::scripts
                JSScript["script.js"]:::scripts
                CSS["style.css"]:::scripts
            end
        end
    end

    %% Connections Browser to Plugin
    Browser -->|"Admin Page Load"| AdminUI
    Browser -->|"AJAX GET /endpoints/asset.php"| AssetEP
    Browser -->|"GET /proxy.php"| ProxyEP
    AssetLoader -->|"enqueue JS/CSS"| Browser

    %% WordPress Core and Plugin Hooks
    WPHooks -->|"invoke"| MainEntry
    MainEntry -->|includes| AdminUI
    MainEntry -->|includes| MediaMgr
    MainEntry -->|includes| ProxyEP

    %% Plugin Modules to REST Client
    AdminUI -->|"calls"| RestClient
    MediaMgr -->|"calls"| RestClient
    AssetEP -->|"uses"| RestClient
    ProxyEP -->|"uses"| CachingProxy

    %% REST Client to External API
    RestClient -->|"HTTPS JSON"| NetXAPI
    CachingProxy -->|"cache / fetch"| NetXAPI

    %% REST Client Internal
    RestClient -->|injects| Connection
    RestClient -->|uses| HttpLayer
    RestClient -->|logs via| PEARLog
    Connection -->|creates| Beans
    Factory -->|builds| Domain

    %% Wrappers
    Wrapper -->|"wraps"| RestClient
    AssetLoader -->|"wraps"| Wrapper

    %% Logging relationships
    PEARLog -->|handles| Handlers
    Handlers -->|writes| LogFiles

    %% Styling
    classDef client fill:#d3f8e2,stroke:#333
    classDef external fill:#f5cba7,stroke:#333
    classDef wp fill:#e0e0e0,stroke:#333
    classDef plugin fill:#aed6f1,stroke:#333
    classDef rest fill:#d7bde2,stroke:#333
    classDef log fill:#fadbd8,stroke:#333
    classDef scripts fill:#fcf3cf,stroke:#333

    %% Click Events
    click MainEntry "https://github.com/netx/netx-wordpress-plugin/blob/master/netx-client.php"
    click AdminUI "https://github.com/netx/netx-wordpress-plugin/blob/master/admin.php"
    click MediaMgr "https://github.com/netx/netx-wordpress-plugin/blob/master/netx-media-manager.php"
    click MediaExt "https://github.com/netx/netx-wordpress-plugin/blob/master/netx-media.php"
    click ProxyEP "https://github.com/netx/netx-wordpress-plugin/blob/master/proxy.php"
    click AssetEP "https://github.com/netx/netx-wordpress-plugin/blob/master/endpoints/asset.php"
    click Connection "https://github.com/netx/netx-wordpress-plugin/blob/master/includes/netx_rest/netxConnection.php"
    click RestClient "https://github.com/netx/netx-wordpress-plugin/blob/master/includes/netx_rest/netxRestClient.php"
    click CachingProxy "https://github.com/netx/netx-wordpress-plugin/blob/master/includes/netx_rest/netxCachingProxy.php"
    click Beans "https://github.com/netx/netx-wordpress-plugin/blob/master/includes/netx_rest/netxBean.php"
    click Factory "https://github.com/netx/netx-wordpress-plugin/blob/master/includes/netx_rest/netxBeanFactory.php"
    click HttpLayer "https://github.com/netx/netx-wordpress-plugin/blob/master/includes/netx_rest/netxHttp.php"
    click Config "https://github.com/netx/netx-wordpress-plugin/blob/master/includes/netx_rest/netxConfig.php"
    click Facade "https://github.com/netx/netx-wordpress-plugin/blob/master/includes/netx_rest/netxNetX.php"
    click PEARLog "https://github.com/netx/netx-wordpress-plugin/blob/master/includes/netx_rest/lib/PEAR/Log.php"
    click Handlers "https://github.com/netx/netx-wordpress-plugin/blob/master/includes/netx_rest/lib/PEAR/Log/*.php"
    click LogFiles "https://github.com/netx/netx-wordpress-plugin/blob/master/includes/netx_rest/logs/netx_api.log"
    click Wrapper "https://github.com/netx/netx-wordpress-plugin/blob/master/includes/netxRestWrapper.php"
    click AssetLoader "https://github.com/netx/netx-wordpress-plugin/blob/master/includes/netxWordpressAssetLoader.php"
    click JSClient "https://github.com/netx/netx-wordpress-plugin/blob/master/scripts/clientScript.js"
    click JSScript "https://github.com/netx/netx-wordpress-plugin/blob/master/scripts/script.js"
    click CSS "https://github.com/netx/netx-wordpress-plugin/blob/master/scripts/style.css"
```
