# lolcabanon/wp-sk-template architecture

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

- Interactive diagram: https://gitdiagram.com/lolcabanon/wp-sk-template
- Repository: https://github.com/lolcabanon/wp-sk-template

## Overview

##### Project Type and Purpose
- This project is a template for building WordPress plugins using SvelteKit.
- It includes two main SvelteKit-based components: one for the WordPress admin panel (located in the “admin” folder) and one for a WordPress shortcode (located in the “client” folder).
- There’s also shared code (“shared” folder) and configuration files (like sharedConfig.js) that are used by both parts.

##### Analyzing the File Structure
- Top-Level Files:
– Files such as index.php, svelteplugin.php, and the main package.json indicate integration with WordPress and Node.js-based toolchains.
- Admin and Client Directories:
– Each contains its own configuration (svelte.config.js, vite.config.js), source files (src folder with routes, libs, SCSS, and HTML) – a clear indicator that they are separate SvelteKit projects.
- Shared Modules:
– The “shared” folder and sharedConfig.js provide common utilities/configuration which should be depicted as a central component feeding into both admin and client modules.

a. Main Components:
– WordPress Core Environment: Represents the overall WordPress system into which the plugin integrates.
– Plugin Bootstrap & Integration Layer: Files like index.php and svelteplugin.php, which register the plugin and serve as integration points.
– Admin Panel (WordPress Admin Interface): The “admin” SvelteKit project that underpins the custom admin panel interface.
– Client/Shortcode Interface: The “client” SvelteKit project that provides front-end functionality through a shortcode.
– Shared Components: “shared” modules and sharedConfig.js that provide shared configuration and functionality across the plugin.
– Build & Deployment Tooling: Represent the build commands (pnpm install, pnpm dev, pnpm wrap:prod) and associated configuration files that drive development and production builds.

b. Relationships and Interactions:
– The WordPress Core calls the plugin’s PHP bootstrap files, which in turn integrate with both the admin panel and client interface components.
– Both the admin and client applications are independent SvelteKit projects but share code and configuration from the “shared” directory.
– There’s a development pipeline where commands (e.g., pnpm dev) concurrently launch the admin and client development servers, and there’s a production bundling process (pnpm wrap:prod) which outputs deployable builds.

c. Architectural Patterns & Design Principles:
– Separation of Concerns: Clearly separates the admin interface from the front-end client.
– Modular Design: Shared code is abstracted into its own folder, reducing duplication and fostering reuse across both SvelteKit projects.
– Integration via a Plugin Bootstrap: The PHP files ensure the SvelteKit UIs properly integrate within the WordPress ecosystem.

d. Relevant Technologies and Frameworks:
– SvelteKit for building the frontend and admin panel interfaces.
– Node.js tooling (pnpm, vite, svelte.config.js) for development and build processes.
– PHP for integration with WordPress (index.php, svelteplugin.php).
– SCSS for styling in both admin and client components.

- Clear labels for every component, including:
– WordPress Core
– Plugin Bootstrap / Integration (index.php, svelteplugin.php)
– Admin Interface (SvelteKit – admin folder)
– Client/Shortcode Interface (SvelteKit – client folder)
– Shared Code & Configuration
– Build & Deployment Pipeline
– From WordPress Core → Plugin Bootstrap → admin/client interfaces.
– From Shared Components → both admin and client projects.
- Annotations to highlight any important configuration files, build scripts, and integration flows.

## Diagram (Mermaid)

```mermaid
flowchart TD
    WP["WordPress Core"]:::wordpress
    PB["Plugin Bootstrap / Integration"]:::php
    ADM["Admin Interface (SvelteKit)"]:::svelte
    CLI["Client/Shortcode Interface (SvelteKit)"]:::svelte
    SHD["Shared Code & Configuration"]:::shared
    BLD["Build & Deployment Pipeline"]:::build

    %% Connections
    WP -->|"calls"| PB
    PB -->|"integrates"| ADM
    PB -->|"integrates"| CLI
    SHD -->|"shared with"| ADM
    SHD -->|"shared with"| CLI
    BLD -->|"builds"| ADM
    BLD -->|"builds"| CLI

    %% Click Events for Plugin Bootstrap / Integration
    click PB "https://github.com/lolcabanon/wp-sk-template/blob/main/index.php"
    click PB "https://github.com/lolcabanon/wp-sk-template/blob/main/svelteplugin.php"

    %% Click Events for Admin Interface
    click ADM "https://github.com/lolcabanon/wp-sk-template/tree/main/admin/"
    click ADM "https://github.com/lolcabanon/wp-sk-template/blob/main/admin/svelte.config.js"
    click ADM "https://github.com/lolcabanon/wp-sk-template/blob/main/admin/vite.config.js"
    click ADM "https://github.com/lolcabanon/wp-sk-template/tree/main/admin/src/"

    %% Click Events for Client/Shortcode Interface
    click CLI "https://github.com/lolcabanon/wp-sk-template/tree/main/client/"
    click CLI "https://github.com/lolcabanon/wp-sk-template/blob/main/client/svelte.config.js"
    click CLI "https://github.com/lolcabanon/wp-sk-template/blob/main/client/vite.config.js"
    click CLI "https://github.com/lolcabanon/wp-sk-template/tree/main/client/src/"

    %% Click Events for Shared Code & Configuration
    click SHD "https://github.com/lolcabanon/wp-sk-template/tree/main/shared/"
    click SHD "https://github.com/lolcabanon/wp-sk-template/blob/main/sharedConfig.js"

    %% Click Events for Build & Deployment Pipeline
    click BLD "https://github.com/lolcabanon/wp-sk-template/blob/main/package.json"
    click BLD "https://github.com/lolcabanon/wp-sk-template/blob/main/admin/package.json"
    click BLD "https://github.com/lolcabanon/wp-sk-template/blob/main/client/package.json"
    click BLD "https://github.com/lolcabanon/wp-sk-template/blob/main/bumper.cjs"
    click BLD "https://github.com/lolcabanon/wp-sk-template/blob/main/pnpm-lock.yaml"

    %% Styles
    classDef wordpress fill:#f9d8d8,stroke:#d66060,stroke-width:2px;
    classDef php fill:#fdebd0,stroke:#f39c12,stroke-width:2px;
    classDef svelte fill:#d5f5e3,stroke:#27ae60,stroke-width:2px;
    classDef shared fill:#d6eaf8,stroke:#3498db,stroke-width:2px;
    classDef build fill:#fdf2e9,stroke:#e67e22,stroke-width:2px;
```
