# kiranpotphode/easy-charts architecture

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

- Interactive diagram: https://gitdiagram.com/kiranpotphode/easy-charts
- Repository: https://github.com/kiranpotphode/easy-charts

## Overview

- Plugin Core – Highlight the main plugin file (easy-charts.php) and related core files in the “includes” folder. This block contains the main classes:
– Activator/Deactivator (handle plugin lifecycle)
– Loader and I18n classes (plugin bootstrapping and language support)
– Integration with WordPress hooks.
- Admin Module – Represent everything under the “admin” directory. This area includes:
– Admin interface PHP files (e.g., class-easy-charts-admin.php and index.php).
– CSS and JavaScript assets (including custom stylesheets, Handsontable components for table-like interactions, and chart insertion functionalities).
– Partial views (metabox templates and settings displays).
- Public Module – Represent the “public” folder. This encapsulates:
– PHP files for rendering public views (class-easy-charts-public.php).
– Public CSS and JS files that control the front-end display and interactivity of the charts.
– Template partials for how charts appear to end users.
– Third-party JavaScript libraries (uvCharts, d3.js, canvg.js, canvas-toblob.js, filesaver.js).
– Additional assets like fonts and additional CSS for Handsontable and others which are used by the admin UI.
- WordPress Integration – Show the overall context where this plugin hooks into WordPress through shortcodes, admin pages, and front-end rendering.

##### Interactions and Data Flow
- From the Plugin Core, branch out to the Admin Module and Public Module to highlight that the core classes load the appropriate functionalities depending on whether the user is in the Admin dashboard or viewing the site contents.
- For the Public Module, illustrate how the chart display is achieved by using PHP partials which inject the necessary HTML, CSS, and JavaScript that interoperate with the external chart libraries.

##### Architectural Patterns and Design Principles
- Separation of Concerns – Clearly show how administrative functions are isolated from public display logic.
- Modular Component Design – Each major directory (admin, includes, public) represents a self-contained module with its own assets and responsibilities.
- Reusability – Point out the use of third-party libraries and the fact that configuration options allow the same data to be used across multiple chart types.
- Extensibility – Note that the plugin is designed to allow changes in chart type or style without altering the underlying data, which is a key architectural principle.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Components
    WP["WordPress Integration\n(Hooks, Shortcodes, Activation)"]:::integration

    %% Plugin Core Subgraph
    subgraph "Plugin Core"
        EMF["Main Plugin File"]:::core
        CC["Core Classes & Functions"]:::core
        CJ["Core JS Dependencies"]:::core
    end

    %% Admin Module Subgraph
    subgraph "Admin Module"
        API["Admin PHP Interface"]:::admin
        ACSS["Admin Assets – CSS"]:::admin
        AJS["Admin Assets – JavaScript"]:::admin
        ATPL["Admin Template Partials"]:::admin
        AF["Admin Additional Resources\n(Fonts & Images)"]:::admin
    end

    %% Public Module Subgraph
    subgraph "Public Module"
        PPR["Public PHP Renderer"]:::public
        PCSS["Public Assets – CSS"]:::public
        PJ["Public Assets – JavaScript"]:::public
        PTPL["Public Template Partials"]:::public
    end

    %% External Libraries & Dependencies Subgraph
    subgraph "External Libraries & Dependencies"
        TJ["Third-party JS Libraries"]:::external
        HTA["Handsontable Assets"]:::external
    end

    %% Data Flows
    WP -->|"activates"| EMF
    EMF -->|"loads_Admin_Module"| API
    EMF -->|"loads_Public_Module"| PPR
    API -->|"sends_config"| CC
    CC -->|"passes_config"| PPR
    PPR -->|"renders_with"| TJ
    AJS -->|"utilizes"| HTA

    %% Click Events for Plugin Core
    click EMF "https://github.com/kiranpotphode/easy-charts/blob/master/easy-charts.php"
    click CC "https://github.com/kiranpotphode/easy-charts/tree/master/includes/"
    click CJ "https://github.com/kiranpotphode/easy-charts/tree/master/includes/js/"

    %% Click Events for Admin Module
    click API "https://github.com/kiranpotphode/easy-charts/blob/master/admin/class-easy-charts-admin.php"
    click ACSS "https://github.com/kiranpotphode/easy-charts/tree/master/admin/css/"
    click AJS "https://github.com/kiranpotphode/easy-charts/tree/master/admin/js/"
    click ATPL "https://github.com/kiranpotphode/easy-charts/tree/master/admin/partials/"
    click AF "https://github.com/kiranpotphode/easy-charts/tree/master/admin/fonts/"

    %% Click Events for Public Module
    click PPR "https://github.com/kiranpotphode/easy-charts/blob/master/public/class-easy-charts-public.php"
    click PCSS "https://github.com/kiranpotphode/easy-charts/tree/master/public/css/"
    click PJ "https://github.com/kiranpotphode/easy-charts/tree/master/public/js/"
    click PTPL "https://github.com/kiranpotphode/easy-charts/tree/master/public/partials/"

    %% Click Events for External Libraries
    click TJ "https://github.com/kiranpotphode/easy-charts/blob/master/includes/js/d3.js"
    click HTA "https://github.com/kiranpotphode/easy-charts/tree/master/admin/css/handsontable/"

    %% Styles
    classDef integration fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef core fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef admin fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef public fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
    classDef external fill:#f8d7da,stroke:#721c24,stroke-width:2px;
```
