# rjchauhan/rjgallery-for-octobercms architecture

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

- Interactive diagram: https://gitdiagram.com/rjchauhan/rjgallery-for-octobercms
- Repository: https://github.com/rjchauhan/rjgallery-for-octobercms

## Overview

##### Project type and purpose
- This is an OctoberCMS plugin (“Light Gallery Plugin”) written in PHP.
- It provides both front-end components for displaying responsive, touch-friendly photo galleries (assets + components) and back-end administration UIs (controllers + models + updates) for managing galleries and categories.

##### File structure
- Top level
- Plugin.php: plugin registration point in OctoberCMS
- Readme.md: feature overview & usage
- assets/: client-side CSS, JavaScript, fonts, images for the gallery UI
- components/: front-end “Gallery”, “GalleriesList”, “GallerySlug” classes + their partial templates (.htm)
- controllers/: back-end (OctoberCMS “backend” area) controllers for Galleries and Categories. Each has YAML config for list/form, toolbar partials, and HTML templates for create/edit/preview.
- models/: Eloquent-style models (Gallery.php, Category.php) plus YAML definitions of database columns and form fields
- updates/: migration scripts that create and modify DB tables (create_galleries_table.php etc.) and version.yaml
- lang/: localization files for multiple languages

##### README for additional insights
- Provides feature list (zoom, fullscreen, 32 transitions, mobile support, etc.)
- Shows how to include the `{% gallery %}` component on pages and configure its properties
- Notes the need for `{% styles %}`/`{% scripts %}` in the layout

a. Main components
- Client Browser (HTTP request, receives HTML/CSS/JS)
- OctoberCMS Core (routing, component engine, backend modules)
- Plugin Layer
– Front-end Components (Gallery, GalleriesList, GallerySlug)
– Assets (CSS/JS/Fonts/Images)
– Back-end Controllers (Categories, Galleries)
– Models (Gallery, Category)
– Database Migrations (updates/)
- Database (MySQL, Postgres, etc.)
b. Relationships and data flow
1. Browser → HTTP GET → OctoberCMS router
2. If front-end page includes `[gallery]` component → CMS invokes Gallery component class → component loads data from Model → Model queries DB → returns image records → component renders partial templates + injects assets → CMS compiles Twig & returns HTML + CSS + JS to browser
3. Admin user → OctoberCMS Backend → clicks “Galleries” or “Categories” menu (registered by Plugin.php) → Controller class loads YAML config for List/Form → renders backend UI → user actions (Create/Update/Delete) invoke Model → Model writes to Database
4. On plugin version change or install → CMS runs update scripts to create/modify tables
c. Architectural patterns/design principles
- MVC for both front-end components (Component class + partial view) and back-end (Controller + YAML-driven Form/Lists + Models)
- YAML-configuration for scaffolding admin UIs
- Asset bundling under plugin namespace
- Plugin modularity: self-contained migration, translations, models, controllers, components
d. Key technologies/frameworks
- OctoberCMS (Laravel based)
- PHP 7+, Twig template engine
- jQuery + custom lightgallery.js plugins
- CSS transitions (falls back to JS)
- YAML for configuration (backend lists/forms, model definitions)
- MySQL/PostgreSQL/SQLite

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client
    Browser["Browser"]:::client

    %% OctoberCMS Core
    subgraph "OctoberCMS Core"
        Router["Router"]:::core
        ComponentEngine["Component Engine"]:::core
        BackendUI["Backend UI Framework"]:::core
        MigrationRunner["Update Runner"]:::core
    end

    %% Plugin Layer
    subgraph "Light Gallery Plugin"
        PluginReg["Plugin Registration"]:::plugin
        subgraph "Front-end Components"
            GalleryComp["Gallery Component"]:::plugin
            GalleriesListComp["GalleriesList Component"]:::plugin
            GallerySlugComp["GallerySlug Component"]:::plugin
        end
        subgraph "Assets"
            CSS["CSS Files"]:::plugin
            JS["JS Files"]:::plugin
            Fonts["Font Files"]:::plugin
            Images["Image Files"]:::plugin
        end
        subgraph "Back-end Controllers"
            GalleriesCtrl["Galleries Controller"]:::plugin
            CategoriesCtrl["Categories Controller"]:::plugin
        end
        subgraph "Models"
            GalleryModel["Gallery Model"]:::plugin
            CategoryModel["Category Model"]:::plugin
        end
        subgraph "Updates"
            M1["create_galleries_table.php"]:::plugin
            M2["create_categories_table.php"]:::plugin
            M3["galleries_add_desc_field_table.php"]:::plugin
            VersionFile["version.yaml"]:::plugin
        end
        subgraph "Translations"
            LangEN["lang/en/lang.php"]:::plugin
            LangCS["lang/cs/lang.php"]:::plugin
            LangES["lang/es/lang.php"]:::plugin
            LangFA["lang/fa/lang.php"]:::plugin
            LangRU["lang/ru/lang.php"]:::plugin
            LangTR["lang/tr/lang.php"]:::plugin
        end
    end

    %% Database
    DB["Database"]:::db

    %% Data Flows
    Browser -->|HTTP GET| Router
    Router -->|route request| ComponentEngine
    ComponentEngine -->|invoke| GalleryComp
    GalleryComp -->|queries| GalleryModel
    GalleryModel -->|reads/writes| DB
    GalleryComp -->|serves assets| CSS
    GalleryComp -->|serves assets| JS
    GalleryComp -->|serves assets| Fonts
    GalleryComp -->|serves assets| Images
    CSS -->|delivers| Browser
    JS -->|delivers| Browser
    Fonts -->|delivers| Browser
    Images -->|delivers| Browser

    Browser -->|admin access| BackendUI
    BackendUI -->|invoke| GalleriesCtrl
    BackendUI -->|invoke| CategoriesCtrl
    GalleriesCtrl -->|config forms/lists| DB
    CategoriesCtrl -->|config forms/lists| DB

    PluginReg -->|registers plugin| Router
    PluginReg -->|registers backend menus| BackendUI
    PluginReg -->|registers components| ComponentEngine
    PluginReg -->|triggers migrations| MigrationRunner
    MigrationRunner -->|runs| M1
    MigrationRunner -->|runs| M2
    MigrationRunner -->|runs| M3
    MigrationRunner -->|reads version| VersionFile
    M1 -->|creates tables| DB
    M2 -->|creates tables| DB
    M3 -->|alters tables| DB

    %% Click Events
    click PluginReg "https://github.com/rjchauhan/rjgallery-for-octobercms/blob/master/Plugin.php"
    click CSS "https://github.com/rjchauhan/rjgallery-for-octobercms/tree/master/assets/"
    click JS "https://github.com/rjchauhan/rjgallery-for-octobercms/tree/master/assets/"
    click Fonts "https://github.com/rjchauhan/rjgallery-for-octobercms/blob/master/assets/fonts/lg.eot"
    click Images "https://github.com/rjchauhan/rjgallery-for-octobercms/tree/master/assets/img/"
    click GalleryComp "https://github.com/rjchauhan/rjgallery-for-octobercms/blob/master/components/Gallery.php"
    click GalleriesListComp "https://github.com/rjchauhan/rjgallery-for-octobercms/blob/master/components/GalleriesList.php"
    click GallerySlugComp "https://github.com/rjchauhan/rjgallery-for-octobercms/blob/master/components/GallerySlug.php"
    click GalleriesCtrl "https://github.com/rjchauhan/rjgallery-for-octobercms/blob/master/controllers/Galleries.php"
    click CategoriesCtrl "https://github.com/rjchauhan/rjgallery-for-octobercms/blob/master/controllers/Categories.php"
    click GalleryModel "https://github.com/rjchauhan/rjgallery-for-octobercms/blob/master/models/Gallery.php"
    click CategoryModel "https://github.com/rjchauhan/rjgallery-for-octobercms/blob/master/models/Category.php"
    click M1 "https://github.com/rjchauhan/rjgallery-for-octobercms/blob/master/updates/create_galleries_table.php"
    click M2 "https://github.com/rjchauhan/rjgallery-for-octobercms/blob/master/updates/create_categories_table.php"
    click M3 "https://github.com/rjchauhan/rjgallery-for-octobercms/blob/master/updates/galleries_add_desc_field_table.php"
    click VersionFile "https://github.com/rjchauhan/rjgallery-for-octobercms/blob/master/updates/version.yaml"
    click LangEN "https://github.com/rjchauhan/rjgallery-for-octobercms/blob/master/lang/en/lang.php"
    click LangCS "https://github.com/rjchauhan/rjgallery-for-octobercms/blob/master/lang/cs/lang.php"
    click LangES "https://github.com/rjchauhan/rjgallery-for-octobercms/blob/master/lang/es/lang.php"
    click LangFA "https://github.com/rjchauhan/rjgallery-for-octobercms/blob/master/lang/fa/lang.php"
    click LangRU "https://github.com/rjchauhan/rjgallery-for-octobercms/blob/master/lang/ru/lang.php"
    click LangTR "https://github.com/rjchauhan/rjgallery-for-octobercms/blob/master/lang/tr/lang.php"

    %% Styles
    classDef client fill:#cccccc,stroke:#333,stroke-width:1px
    classDef core fill:#87CEFA,stroke:#333,stroke-width:1px
    classDef plugin fill:#90EE90,stroke:#333,stroke-width:1px
    classDef db fill:#FFD700,stroke:#333,stroke-width:1px
```
