# gbti-network/better-category-manager architecture

> Architecture diagram of the GitHub repository gbti-network/better-category-manager, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gbti-network/better-category-manager
- Repository: https://github.com/gbti-network/better-category-manager

## Overview

##### Project’s Main Components
- Plugin Core: The entry point is the “better-category-manager.php” file, which integrates with WordPress.
- Modules/Classes: Look in the “includes” directory—each PHP class here (e.g., class-category-manager.php, class-import-export.php, class-settings.php, class-ajax-handler.php, class-openai-integration.php) corresponds to separate functional modules like category management, import/export, settings, AJAX handling, and AI integration.
- Assets: The “assets” folder holds JavaScript and CSS files that define the administrative behavior and style for both the plugin’s interfaces and its logging dashboards (such as admin-auth.js/css, logs-widget.css, etc.).
- Templates: The “templates” directory contains PHP files used to render admin interfaces (e.g., admin-page.php, settings-page.php, import-export-controls.php, term-modal.php).
- Development & Build Tools: The “scripts” folder (with build.js, commit.js, release scripts, and translation scripts) and the associated package.json files represent the Node.js build and release process.
- Product Documentation: The “.product” directory holds changelogs, feature descriptions, screenshots, etc. which are important for release notes and contributing guidelines.
- External Integrations: Modules for GitHub release automation (as mentioned in the README and evidenced by release scripts) and the OpenAI integration support smart term suggestions.

##### Relationships and Interactions
- Logging System: Represent the logging system with components for the dashboard widget, full-page viewer, and AJAX-based log update mechanism.
- External Services: Indicate outbound communication paths:
○ GitHub for automated update releases – show the connection from release scripts (Node.js) to the GitHub API.
○ OpenAI integration – illustrate how the OpenAI module is invoked for smart suggestions.

##### Architectural Patterns and Design Principles
- Modular Design: The separation into “includes” for functionality, “assets” for presentation, “templates” for UI, and “scripts” for development tools makes the project highly modular. Represent each module as its own component.
- Separation of Concerns: Each module (category management, logging, settings, etc.) has its clear role, which should be distinctly shown.
- Build & Release Pipeline: Demonstrate the Node.js build and release scripts’ role in automating version bumps, asset builds, and GitHub releases.

## Diagram (Mermaid)

```mermaid
flowchart TD
    WP["WordPress Environment"]:::wordpress
    PC["Plugin Core (better-category-manager.php)"]:::backend
    WP -->|"loads|hook"| PC

    subgraph "Backend Modules"
        CM["Category Management Module"]:::backend
        IE["Import/Export Module"]:::backend
        ST["Settings Module"]:::backend
        AH["AJAX Handler"]:::backend
        OA["OpenAI Integration"]:::backend
    end
    PC -->|"initiates"| CM
    PC -->|"initiates"| IE
    PC -->|"initiates"| ST
    PC -->|"initiates"| AH
    PC -->|"initiates"| OA

    subgraph "UI Layer"
        UT["UI Templates"]:::frontend
        FA["Front-end Assets"]:::frontend
    end
    PC -->|"rendersUI"| UT
    PC -->|"rendersUI"| FA
    FA -->|"AJAXcall"| AH

    subgraph "Logging System"
        LOG["Logging System"]:::logging
    end
    PC -->|"logsEvents"| LOG
    AH -->|"logUpdates"| LOG

    DT["Development & Build Tools"]:::dev
    PC -->|"packagedBy"| DT
    DT -->|"releaseScript"| GH["GitHub API"]:::external
    DT -->|"updateDocs"| PD["Product Documentation"]:::dev

    OA -->|"APIrequest"| OAPI["OpenAI API"]:::external

    %% Click Events
    click PC "https://github.com/gbti-network/better-category-manager/blob/master/better-category-manager.php"
    click CM "https://github.com/gbti-network/better-category-manager/blob/master/includes/class-category-manager.php"
    click IE "https://github.com/gbti-network/better-category-manager/blob/master/includes/class-import-export.php"
    click ST "https://github.com/gbti-network/better-category-manager/blob/master/includes/class-settings.php"
    click AH "https://github.com/gbti-network/better-category-manager/blob/master/includes/class-ajax-handler.php"
    click OA "https://github.com/gbti-network/better-category-manager/blob/master/includes/class-openai-integration.php"
    click LOG "https://github.com/gbti-network/better-category-manager/blob/master/assets/css/log-viewer.css"
    click UT "https://github.com/gbti-network/better-category-manager/tree/master/templates"
    click FA "https://github.com/gbti-network/better-category-manager/blob/master/assets/js/admin-auth.js"
    click DT "https://github.com/gbti-network/better-category-manager/tree/master/scripts"
    click PD "https://github.com/gbti-network/better-category-manager/blob/master/.product/changelog.md"

    %% Styles
    classDef wordpress fill:#AEDFF7,stroke:#333,stroke-width:2px;
    classDef backend fill:#FFF2B2,stroke:#333,stroke-width:2px;
    classDef frontend fill:#D4F1F4,stroke:#333,stroke-width:2px;
    classDef dev fill:#E2F0CB,stroke:#333,stroke-width:2px;
    classDef external fill:#F7C6C7,stroke:#333,stroke-width:2px;
    classDef logging fill:#C2E0FF,stroke:#333,stroke-width:2px;
```
