# rtcamp/godam architecture

> Architecture diagram of the GitHub repository rtcamp/godam, 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/rtcamp/godam
- Repository: https://github.com/rtcamp/godam

## Overview

- Plugin Core: Represented by the main PHP files like godam.php, the inc/ directory (classes for plugin management, asset handling, taxonomy management, etc.) and the admin directory (admin UI files handling transcoder settings, REST routes, and media functionalities). Label it “WordPress Plugin Core.”
- Admin Interface: Show both “Admin” (PHP-based backend pages in admin/ and class files) and “WordPress Media Library Integration” (which hooks into the WordPress admin dashboard). Indicate the UI components provided by the plugin’s PHP classes.
- Build & Asset Pipeline: Include a component to represent the build system with Node/NPM scripts (Gruntfile.js, package.json, webpack.config.js, tailwind.config.js, etc.) and how these generate production assets for both the plugin’s admin UI and front-end blocks.
- External Integrations: Highlight external services such as:
- godam.io – used for deactivation feedback.
- app.godam.io – for media transcoding services and API key validation.
- analytics.godam.io – for collecting and processing video analytics.

##### Relationships and Data Flows
- That WordPress (and its admin dashboard) interacts with the Plugin Core to configure settings (via PHP classes and REST API endpoints defined under inc/classes/rest-api).
- Separation between the front-end video player (built with React, Redux, and JavaScript assets from pages/ and assets/src/blocks) and the back-end processing.
– Data/control flow from the WordPress dashboard to the PHP back end (plugin classes in admin/ and inc/).
– Build pipeline flow from source files (assets/src, pages) to bundled production assets.
– Communication with external services (transcoding, deactivation feedback, analytics) during key events like media upload, deactivation, and when a video is watched.

##### Architectural Patterns and Design Principles
- Separation of Concerns: Clearly distinguish between the WordPress back end (PHP, REST API endpoints, admin actions) and the front-end modern JavaScript components.
- Modularization: The file structure indicates modular components such as “admin”, “inc”, “assets”, and “pages” – each representing a particular aspect of the plugin functionality.
- Extensibility: Note how external APIs and integration points (via REST and external service calls) are abstracted and how new interactive video layers can be added.
- Build & Testing: Include components representing build automation (npm, composer, Grunt, webpack) and testing with e2e tests (located under tests/e2e-playwright).

##### Schematic Elements to be Included
– “Upload Video” event flowing from WordPress to Plugin Core to External Transcoding Service.
– “User Video Playback” event sending analytics from Frontend to analytics.godam.io.
- Use callouts or annotations for key technologies (PHP, React, Redux, Node.js, Grunt/Webpack) which are integral parts of the plugin’s architecture.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Subgraph: WordPress Admin & Plugin Core
    subgraph "WordPress Admin & Plugin Core"
        WD["WordPress Dashboard"]:::dashboard
        AUI["Admin Interface"]:::backend
        MPF["Main Plugin File"]:::backend
        CC["Core Classes (inc/)"]:::backend
        WD -->|"settings"| AUI
        AUI -->|"REST_calls"| MPF
        MPF -->|"logic"| CC
    end

    %% Subgraph: Custom Video Player & Frontend Interface
    subgraph "Custom Video Player & Frontend Interface"
        VPB["Video Player Block"]:::frontend
        VER["Video Editor (React)"]:::frontend
        VPB -->|"uses_API"| VER
    end

    %% Subgraph: Build & Asset Pipeline
    subgraph "Build & Asset Pipeline"
        BT1["Build Tools (Gruntfile.js)"]:::build
        BT2["Node Config (package.json)"]:::build
    end

    %% Subgraph: External Service Endpoints
    subgraph "External Service Endpoints"
        DS["Deactivation Feedback (godam.io)"]:::external
        TS["Transcoding Service (app.godam.io)"]:::external
        AS["Analytics Service (analytics.godam.io)"]:::external
    end

    %% Interconnections between subgraphs
    AUI -->|"transcoding"| TS
    CC -->|"feedback"| DS
    VER -->|"analytics"| AS
    BT1 -->|"build"| AUI
    BT2 -->|"build"| VPB
    CC -->|"API"| VPB

    %% Click Events for Component Mapping
    click MPF "https://github.com/rtcamp/godam/blob/master/godam.php"
    click CC "https://github.com/rtcamp/godam/tree/master/inc/"
    click AUI "https://github.com/rtcamp/godam/tree/master/admin/"
    click VPB "https://github.com/rtcamp/godam/tree/master/assets/src/blocks/godam-player"
    click VER "https://github.com/rtcamp/godam/tree/master/pages/video-editor"
    click BT1 "https://github.com/rtcamp/godam/blob/master/Gruntfile.js"
    click BT2 "https://github.com/rtcamp/godam/blob/master/package.json"

    %% Styles
    classDef dashboard fill:#f9c74f,stroke:#333,stroke-width:2px;
    classDef backend fill:#90be6d,stroke:#333,stroke-width:2px;
    classDef frontend fill:#f94144,stroke:#333,stroke-width:2px;
    classDef build fill:#577590,stroke:#333,stroke-width:2px;
    classDef external fill:#277da1,stroke:#333,stroke-width:2px;
```
