# shipwebdotjp/lineconnect architecture

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

- Interactive diagram: https://gitdiagram.com/shipwebdotjp/lineconnect
- Repository: https://github.com/shipwebdotjp/lineconnect

## Overview

The LINE Connect project is a WordPress plugin designed to integrate LINE official accounts with your WordPress installation. It provides features like linking WordPress and LINE users, sending post notifications, supporting rich menu tap events, and handling automated messaging based on received messages. The overall architecture splits concerns between backend functionality (core plugin logic, WordPress hooks, and interactions with LINE APIs) and frontend/client-side components (JavaScript assets, styles, and interactive elements).

##### Main Components
- Plugin Core & Backend:
- WordPress Plugin Hooks: Central integration point with WordPress (activation, deactivation, dashboard settings).
- Core PHP Modules: Located in directories like “include” and “src” (e.g., ActionExecute, ActionFlow, Scenario, and Utilities) which handle actions, admin management, webhook processing, and business logic such as linking users or processing rich menus.
- External API & Event Handling: Components that manage communication with LINE’s messaging/webhook APIs (for rich menu events, notifications and triggers).
- Client-side & Frontend Modules:
- Frontend Directories: Separate “frontend” folders (e.g., “frontend/action-execute”, “line-dm”, “line-bulkmessage”, “line-richmenu”) contain build outputs (JavaScript bundles, CSS assets) for interactive web pages or administrative interfaces.
- JavaScript Components: Built using frameworks like Tailwind, webpack, and react-jsonschema-form (indicating dynamic UI forms and event handling for managing LINE interactions).
- Documentation and Localization:
- Documentation: “docs” and “document” directories include detailed usage, technical guides, and schema definitions.
- i18n / Languages: Localization files (like .po, .json) to support multi-language capabilities for the plugin.
- Testing & CI:
- Tests: A comprehensive “tests” directory which covers backend PHP functionality (unit tests for scenarios, audience, messaging, etc.).
- CI/CD: GitHub workflows in “.github/workflows” for deployment and generating installable zip packages.

##### Relationships and Interactions
- The Plugin Core interfaces with WordPress via hooks and menu actions and interacts with the frontend assets (e.g., JavaScript components for action execution, rich menu management).
- Incoming events, such as LINE webhooks, are routed to specific PHP modules (e.g., in “include” and “src”) to process messages, update logs, and trigger appropriate notifications.
- Client-side components (bundled in the “frontend” and “line-*” directories) provide the UI for administrators or end users to manage various LINE Connect features. These assets consume backend APIs implemented by the plugin.
- External dependencies (e.g., LINE’s official API endpoints and third-party libraries through Composer for PHP and NPM for front-end code) form part of the communication pipeline.

##### Architectural Patterns and Design Principles
- Separation of Concerns: Clear separation between the WordPress integration (plugin core), business logic (PHP modules), and user interface (frontend assets and dynamic JS forms).
- Modularization: Each functionality (action execution, action flow, scenario processing, rich menu handling) has its own dedicated module (as seen in the directory names), making it easier to extend or maintain.
- Event-Driven Interactions: Use of webhooks and event logs suggests an event-driven design where events trigger specific code paths.
- Use of Standard Build Tools: Frontend assets are built using webpack, Tailwind CSS, and work with localization & schema-based form generators (react-jsonschema-form).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Backend Components
    subgraph "Backend Components"
        WP["WordPress Plugin Hooks"] 
        subgraph "Core PHP Modules"
            AE["ActionExecute Module"]
            AF["ActionFlow Module"]
            SC["Scenario Module"]
            UT["Utilities Module"]
        end
        API["External API & Webhook Handlers"]
    end

    %% Frontend Components
    subgraph "Frontend Components"
        FE["Frontend Action Execution"]
        DM["LINE DM Frontend"]
        BM["Bulk Messaging Frontend"]
        RM["Rich Menu Frontend"]
        JS["JavaScript Components & Assets"]
    end

    %% Documentation and Localization
    subgraph "Documentation and Localization"
        DOC["Documentation"]
        I18n["Localization Files"]
    end

    %% Testing & CI
    subgraph "Testing & CI"
        TEST["Tests"]
        CI["CI/CD Pipelines"]
    end

    %% Relationships within Backend
    WP -->|"triggers"| AE
    WP -->|"triggers"| AF
    WP -->|"triggers"| SC
    WP -->|"triggers"| UT
    API -->|"processes"| AE
    API -->|"processes"| AF
    API -->|"processes"| SC
    API -->|"processes"| UT
    AE -->|"utilizes"| UT
    AF -->|"utilizes"| UT

    %% Relationships between Backend and Frontend
    WP -->|"interfacesWith"| FE
    AE -->|"exposesAPI"| FE
    AF -->|"exposesAPI"| FE
    SC -->|"exposesAPI"| FE
    API -->|"sendsNotifs"| FE

    DM -->|"communicatesWith"| WP
    BM -->|"communicatesWith"| WP
    RM -->|"richMenuEvents"| WP

    %% Internal Frontend Asset relationship
    FE -.-> JS
    DM -.-> JS
    BM -.-> JS
    RM -.-> JS

    %% Documentation links
    WP -->|"documentedIn"| DOC
    SC -->|"describedIn"| DOC

    %% Testing & CI interactions
    TEST -->|"validates"| AE
    TEST -->|"validates"| AF
    TEST -->|"validates"| SC
    TEST -->|"validates"| UT
    CI -->|"automatesTests"| TEST
    CI -->|"deploys"| FE

    %% Click Events
    click WP "https://github.com/shipwebdotjp/lineconnect/blob/master/accountlink.php"
    click AE "https://github.com/shipwebdotjp/lineconnect/blob/master/src/ActionExecute/ActionExecute.php"
    click AF "https://github.com/shipwebdotjp/lineconnect/blob/master/src/ActionFlow/ActionFlow.php"
    click SC "https://github.com/shipwebdotjp/lineconnect/blob/master/src/Scenario/Scenario.php"
    click UT "https://github.com/shipwebdotjp/lineconnect/tree/master/src/Utilities"
    click API "https://github.com/shipwebdotjp/lineconnect/blob/master/include/botlog.php"
    click FE "https://github.com/shipwebdotjp/lineconnect/tree/master/frontend/action-execute"
    click DM "https://github.com/shipwebdotjp/lineconnect/tree/master/line-dm"
    click BM "https://github.com/shipwebdotjp/lineconnect/tree/master/line-bulkmessage"
    click RM "https://github.com/shipwebdotjp/lineconnect/tree/master/line-richmenu"
    click JS "https://github.com/shipwebdotjp/lineconnect/tree/master/js"
    click DOC "https://github.com/shipwebdotjp/lineconnect/tree/master/docs"
    click I18n "https://github.com/shipwebdotjp/lineconnect/tree/master/languages"
    click TEST "https://github.com/shipwebdotjp/lineconnect/tree/master/tests"
    click CI "https://github.com/shipwebdotjp/lineconnect/tree/master/.github/workflows"

    %% Styles
    classDef backend fill:#fdb,stroke:#333,stroke-width:2px;
    classDef frontend fill:#bdf,stroke:#333,stroke-width:2px;
    classDef docs fill:#dfd,stroke:#333,stroke-width:2px;
    classDef testing fill:#fdd,stroke:#333,stroke-width:2px;

    class WP,AE,AF,SC,UT,API backend;
    class FE,DM,BM,RM,JS frontend;
    class DOC,I18n docs;
    class TEST,CI testing;
```
