# elicus/wpmozo-blocks-and-addons architecture

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

- Interactive diagram: https://gitdiagram.com/elicus/wpmozo-blocks-and-addons
- Repository: https://github.com/elicus/wpmozo-blocks-and-addons

## Overview

##### Project type and purpose
- This is a WordPress plugin (“WPMozo Addons For Gutenberg”) that adds a set of custom Gutenberg blocks to the WP editor.
- PHP code in the “includes” folder handles plugin initialization, block registration, i18n, and asset enqueuing.
- JavaScript/React code under “src” implements each block’s editor UI and save routines; a build step (npm/webpack) produces the final assets in “assets/js” and “assets/css.”

##### File structure
- Top‐level:
- wpmozo-addons-for-gutenberg.php → main plugin file
- includes/ → PHP classes for loader, hooks, i18n, block registration
- src/ → source code for individual blocks and shared React components
- assets/ → compiled CSS/JS/fonts/images served to editor and front end
- package.json & package-lock.json → npm build configuration
- Patterns:
- Modular block definitions (each block in its own subfolder in src/blocks)
- Shared UI components in src/components
- PHP “blocks” classes mirror built JS blocks for server‐side registration
- Build/deploy:
- npm run build → transpiles/concatenates src/ → assets/
- Plugin PHP enqueues those assets via WP hooks

##### README for additional insights
- Confirms WordPress plugin metadata, installation steps.

##### Elements
- Clear component labels (e.g., “Block Registration Service,” “Gutenberg Editor,” “React Block JS Bundle”)
- Build → assets
- PHP enqueue hooks → Editor load
- Editor actions → REST API → Database
- Page load → Front-end enqueue → Browser render

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Development Workflow"
        src_index["src/index.js"]:::js
        src_blocks["src/blocks/..."]:::js
        src_components["src/components"]:::js
        package_json["package.json"]:::tool
        package_json -->|"defines build"| src_index
        src_index -->|"imports blocks & components"| src_blocks
        src_index --> src_components
    end

    subgraph "Build Pipeline"
        npm["npm/webpack"]:::tool
        npm -->|"build"| js1
        npm --> js2
        npm --> js3
        npm --> css1
        npm --> css2
    end

    subgraph "Build Output"
        js1["frontend.js"]:::asset
        js2["wpmozo-common-functions.js"]:::asset
        js3["jquery.event.move.js"]:::asset
        css1["wpmozo-addons-for-gutenberg-editor.css"]:::asset
        css2["twentytwenty.css"]:::asset
    end

    subgraph "Plugin PHP Backend"
        main_plugin["wpmozo-addons-for-gutenberg.php"]:::php
        init_service["class-wpmozo-addons-for-gutenberg.php"]:::php
        loader["class-wpmozo-addons-gutenberg-loader.php"]:::php
        hooks["class-wpmozo-addons-gutenberg-init.php"]:::php
        i18n["class-wpmozo-addons-gutenberg-i18n.php"]:::php
        blocks_service["class-wpmozo-addons-gutenberg-blocks.php"]:::php
        base_block["class-wpmozo-addons-gutenberg-block.php"]:::php
        main_plugin --> init_service
        init_service --> loader
        loader --> hooks
        hooks --> i18n
        hooks --> blocks_service
        blocks_service --> base_block
    end

    subgraph "Block Server Classes"
        bafs["class-wpmozo-addons-gutenberg-block-beforeafterslider.php"]:::php
        content_toggle["class-wpmozo-addons-gutenberg-block-contenttoggle.php"]:::php
        flipbox["class-wpmozo-addons-gutenberg-block-flipbox.php"]:::php
        interactive_card["class-wpmozo-addons-gutenberg-block-interactiveimagecard.php"]:::php
        blocks_service --> bafs
        blocks_service --> content_toggle
        blocks_service --> flipbox
        blocks_service --> interactive_card
    end

    subgraph "Runtime - Editor"
        wp_core_editor["Gutenberg Editor"]:::wp
        js1 --> wp_core_editor
        js2 --> wp_core_editor
        js3 --> wp_core_editor
        css1 --> wp_core_editor
        main_plugin -->|"enqueue editor assets"| wp_core_editor
        wp_core_editor -->|"user edits blocks"| wp_rest["REST API"]:::wp
    end

    subgraph "Runtime - Frontend"
        browser["Browser"]:::browser
        js1 --> browser
        js2 --> browser
        js3 --> browser
        css2 --> browser
        main_plugin -->|"enqueue frontend assets"| browser
    end

    subgraph "External Resources"
        fontawesome["FontAwesome Webfonts"]:::external
        fontawesome -.-> browser
    end

    wp_rest -->|"saves content"| wp_db["WP Database"]:::db

    %% Click Events
    click main_plugin "https://github.com/elicus/wpmozo-blocks-and-addons/blob/main/wpmozo-addons-for-gutenberg.php"
    click init_service "https://github.com/elicus/wpmozo-blocks-and-addons/blob/main/includes/class-wpmozo-addons-for-gutenberg.php"
    click loader "https://github.com/elicus/wpmozo-blocks-and-addons/blob/main/includes/class-wpmozo-addons-gutenberg-loader.php"
    click hooks "https://github.com/elicus/wpmozo-blocks-and-addons/blob/main/includes/class-wpmozo-addons-gutenberg-init.php"
    click i18n "https://github.com/elicus/wpmozo-blocks-and-addons/blob/main/includes/class-wpmozo-addons-gutenberg-i18n.php"
    click blocks_service "https://github.com/elicus/wpmozo-blocks-and-addons/blob/main/includes/class-wpmozo-addons-gutenberg-blocks.php"
    click base_block "https://github.com/elicus/wpmozo-blocks-and-addons/blob/main/includes/class-wpmozo-addons-gutenberg-block.php"
    click bafs "https://github.com/elicus/wpmozo-blocks-and-addons/blob/main/includes/blocks/class-wpmozo-addons-gutenberg-block-beforeafterslider.php"
    click content_toggle "https://github.com/elicus/wpmozo-blocks-and-addons/blob/main/includes/blocks/class-wpmozo-addons-gutenberg-block-contenttoggle.php"
    click flipbox "https://github.com/elicus/wpmozo-blocks-and-addons/blob/main/includes/blocks/class-wpmozo-addons-gutenberg-block-flipbox.php"
    click interactive_card "https://github.com/elicus/wpmozo-blocks-and-addons/blob/main/includes/blocks/class-wpmozo-addons-gutenberg-block-interactiveimagecard.php"
    click package_json "https://github.com/elicus/wpmozo-blocks-and-addons/blob/main/package.json"
    click src_index "https://github.com/elicus/wpmozo-blocks-and-addons/blob/main/src/index.js"
    click src_blocks "https://github.com/elicus/wpmozo-blocks-and-addons/tree/main/src/blocks"
    click src_components "https://github.com/elicus/wpmozo-blocks-and-addons/tree/main/src/components"
    click js1 "https://github.com/elicus/wpmozo-blocks-and-addons/blob/main/assets/js/frontend.js"
    click js2 "https://github.com/elicus/wpmozo-blocks-and-addons/blob/main/assets/js/wpmozo-common-functions.js"
    click js3 "https://github.com/elicus/wpmozo-blocks-and-addons/blob/main/assets/js/jquery.event.move.js"
    click css1 "https://github.com/elicus/wpmozo-blocks-and-addons/blob/main/assets/css/wpmozo-addons-for-gutenberg-editor.css"
    click css2 "https://github.com/elicus/wpmozo-blocks-and-addons/blob/main/assets/css/twentytwenty.css"

    %% Styles
    classDef php fill:#f8d7da,stroke:#721c24,color:#721c24
    classDef js fill:#d1ecf1,stroke:#0c5460,color:#0c5460
    classDef tool fill:#fff3cd,stroke:#856404,color:#856404
    classDef asset fill:#d4edda,stroke:#155724,color:#155724
    classDef wp fill:#cce5ff,stroke:#004085,color:#004085
    classDef browser fill:#e2e3e5,stroke:#6c757d,color:#6c757d
    classDef external fill:none,stroke:#6f42c1,color:#6f42c1,stroke-dasharray: 5 5
    classDef db fill:#f5f5f5,stroke:#343a40,color:#343a40
```
