# sobold/sb-starter architecture

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

- Interactive diagram: https://gitdiagram.com/sobold/sb-starter
- Repository: https://github.com/sobold/sb-starter

## Overview

##### Project Type and Purpose
- This is a WordPress “Starter Theme” project: it provides a theme skeleton with PHP templates, SCSS/CSS styling, JavaScript logic, AJAX/REST endpoints, and helper libraries (TGM for plugin activation, WooCommerce hooks).
- Its purpose is to serve as a starting point for WordPress site development, offering a consistent folder structure and best practices (7-1 SCSS pattern, modular components, RESTful AJAX, template parts).

##### File-Structure Analysis
Top-level:
– style.css, functions.php: core theme metadata and bootstrap of hooks, enqueueing, registrations.
– index.php, single.php, page.php, archive.php, pagebuilder.php: WordPress template hierarchy entry points.
– header.php, footer.php, sidebar/theme parts in template-parts and elements/ (layout, components, pagebuilder).
– assets/, css/main.css, js/: compiled front-end assets.
– scss/: source styling using the 7-1 folder pattern.
– inc/: theme logic split into subfolders:
- inc/app/ (custom theme logic),
- inc/ajax/ (REST endpoint registration & handlers),
- inc/* (misc. functions, customizer, woocommerce, login-page, template-tags).
– lib/tgm/: third-party plugin-activation library.

##### Key Insights from README
- Elements folder holds reusable UI pieces (components, layout, ACF pagebuilder).
- SCSS follows 7-1; main.scss imports abstracts, base, components, layout, pagebuilder, pages.
- AJAX follows WP-REST best practices (rest_api_init, WP_REST_Request/Response).
- Template parts in template-parts/ are included in hierarchy files.

##### Main Components
A. WordPress Core
– HTTP Request Handler
– Hook System (actions/filters)
– Template Loader
– WP REST API Router
– Database layer (MySQL)
B. SoBold Starter Theme
1. Entry Points: functions.php, style.css, template files (index.php, single.php, page.php, etc.)
2. Template Parts & Elements
- elements/components (reusable UI),
- elements/layout (header, footer, nav),
- elements/pagebuilder (ACF blocks)
- template-parts (content templates)
3. Logic Modules (inc/)
- inc/app (theme-specific business logic),
- inc/ajax (REST endpoint registration & handlers),
- inc/customizer, login-page, template-functions, woocommerce, etc.
4. Asset Pipeline
- SCSS source (scss/ → compiled → css/main.css),
- JavaScript modules (js/, including ajax subfolder),
5. Third-party Libs
- lib/tgm (plugin activation),
- WooCommerce integration.
C. Frontend Browser
– Loads HTML/CSS/JS, triggers interactions, fires AJAX/REST calls.
D. External Systems
– Database (MySQL),
– WP-Hosted plugins activated via TGM.

##### Relationships & Interactions
- Browser → HTTP Request → WordPress Core → Template Loader → Theme entry point (e.g., pagebuilder.php)
- Theme.functions.php registers hooks/filters → modifies WP behavior (menus, custom header, widgets, etc.)
- functions.php enqueues CSS/JS → Browser loads assets.
- JS modules call REST endpoints (registered in inc/ajax/init.php) → WordPress Core REST Router → inc/ajax handlers → return WP_REST_Response → Browser updates UI.
- Template files include elements and template-parts → render final HTML.
- SCSS compilation (developer step) produces main.css; theme uses it as primary stylesheet.

##### Architectural Patterns & Principles
- Modular UI components (elements/components, layout, pagebuilder)
- 7-1 SCSS structure for maintainable styling
- WP-REST design pattern for AJAX (versioned endpoints, HTTP verbs)
- Separation of concerns: presentation (templates, CSS, JS) vs. logic (inc/app, template-functions)
- Third-party integration via TGM and WooCommerce hooks.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client
    subgraph "Browser / Client"
        Browser["Browser UI"]:::client
    end

    %% WordPress Core
    subgraph "WordPress Core"
        HTTP["HTTP Request Handler"]:::core
        Hooks["Hook System (Actions/Filters)"]:::core
        TempLoad["Template Loader"]:::core
        RESTRouter["WP REST API Router"]:::core
        DB[(MySQL Database)]:::external
    end

    %% SoBold Starter Theme
    subgraph "SoBold Starter Theme"
        subgraph "Entry Points"
            FP["functions.php"]:::theme
            ST["style.css"]:::theme
            IDX["index.php"]:::theme
            SGL["single.php"]:::theme
            PGE["page.php"]:::theme
            ARC["archive.php"]:::theme
            PGB["pagebuilder.php"]:::theme
        end

        subgraph "Template Parts & Elements"
            COMP["elements/components/"]:::theme
            LAY["elements/layout/"]:::theme
            PBE["elements/pagebuilder/"]:::theme
            TP1["content.php"]:::theme
            TP2["content-page.php"]:::theme
            TP3["content-pagebuilder.php"]:::theme
        end

        subgraph "Logic Modules (inc/)"
            INIT_APP["/inc/app/init.php"]:::theme
            INIT_AJAX["/inc/ajax/init.php"]:::theme
            CHDR["/inc/custom-header.php"]:::theme
            CUST["/inc/customizer.php"]:::theme
            HFUN["/inc/general-functions.php"]:::theme
            LOGIN["/inc/login-page.php"]:::theme
            SBFUN["/inc/sobold-functions.php"]:::theme
            TFUN["/inc/template-functions.php"]:::theme
            TTAG["/inc/template-tags.php"]:::theme
            TGM_IN["/inc/tgm.php"]:::theme
            WC["/inc/woocommerce.php"]:::theme
            WPC["/inc/wpcom.php"]:::theme
        end

        subgraph "Asset Pipeline"
            CSS["css/main.css"]:::assets
            SCSS_MAIN["scss/main.scss"]:::assets
            SCSS_ABS["scss/abstracts/"]:::assets
            SCSS_BASE["scss/base/"]:::assets
            SCSS_COMP["scss/components/"]:::assets
            SCSS_LAY["scss/layout/"]:::assets
            SCSS_PB["scss/pagebuilder/"]:::assets
            SCSS_PG["scss/pages/"]:::assets
            JS1["js/customizer.js"]:::assets
            JS2["js/skip-link-focus-fix.js"]:::assets
            ASSETS["assets/"]:::assets
        end

        subgraph "Third-Party Libraries"
            TGM_LIB["lib/tgm/"]:::external
        end
    end

    %% Flows
    Browser -->|"HTTP Request"| HTTP
    HTTP --> Hooks
    Hooks --> TempLoad
    TempLoad --> IDX
    TempLoad --> SGL
    TempLoad --> PGE
    TempLoad --> ARC
    TempLoad --> PGB

    FP -->|"register hooks & enqueue"| Hooks
    FP -->|"enqueue_style & enqueue_script"| Browser

    Browser -->|"AJAX GET/POST /wp-json"| RESTRouter
    RESTRouter --> INIT_AJAX
    INIT_AJAX --> RESTRouter
    RESTRouter -->|Response| Browser

    TempLoad --> COMP
    TempLoad --> LAY
    TempLoad --> PBE
    TempLoad --> TP1
    TempLoad --> TP2
    TempLoad --> TP3

    SCSS_MAIN --> CSS
    CSS --> Browser
    FP --> SCSS_MAIN

    FP --> JS1
    FP --> JS2
    JS1 --> Browser
    JS2 --> Browser

    TempLoad --> DB
    RESTRouter --> DB

    TGM_LIB --> FP
    TGM_LIB --> Hooks

    %% Click Events
    click FP "https://github.com/sobold/sb-starter/blob/main//functions.php"
    click ST "https://github.com/sobold/sb-starter/blob/main//style.css"
    click IDX "https://github.com/sobold/sb-starter/blob/main//index.php"
    click SGL "https://github.com/sobold/sb-starter/blob/main//single.php"
    click PGE "https://github.com/sobold/sb-starter/blob/main//page.php"
    click ARC "https://github.com/sobold/sb-starter/blob/main//archive.php"
    click PGB "https://github.com/sobold/sb-starter/blob/main//pagebuilder.php"
    click COMP "https://github.com/sobold/sb-starter/tree/main//elements/components/"
    click LAY "https://github.com/sobold/sb-starter/tree/main//elements/layout/"
    click PBE "https://github.com/sobold/sb-starter/tree/main//elements/pagebuilder/"
    click TP1 "https://github.com/sobold/sb-starter/blob/main//template-parts/content.php"
    click TP2 "https://github.com/sobold/sb-starter/blob/main//template-parts/content-page.php"
    click TP3 "https://github.com/sobold/sb-starter/blob/main//template-parts/content-pagebuilder.php"
    click INIT_APP "https://github.com/sobold/sb-starter/blob/main//inc/app/init.php"
    click INIT_AJAX "https://github.com/sobold/sb-starter/blob/main//inc/ajax/init.php"
    click CHDR "https://github.com/sobold/sb-starter/blob/main//inc/custom-header.php"
    click CUST "https://github.com/sobold/sb-starter/blob/main//inc/customizer.php"
    click HFUN "https://github.com/sobold/sb-starter/blob/main//inc/general-functions.php"
    click LOGIN "https://github.com/sobold/sb-starter/blob/main//inc/login-page.php"
    click SBFUN "https://github.com/sobold/sb-starter/blob/main//inc/sobold-functions.php"
    click TFUN "https://github.com/sobold/sb-starter/blob/main//inc/template-functions.php"
    click TTAG "https://github.com/sobold/sb-starter/blob/main//inc/template-tags.php"
    click TGM_IN "https://github.com/sobold/sb-starter/blob/main//inc/tgm.php"
    click WC "https://github.com/sobold/sb-starter/blob/main//inc/woocommerce.php"
    click WPC "https://github.com/sobold/sb-starter/blob/main//inc/wpcom.php"
    click CSS "https://github.com/sobold/sb-starter/blob/main//css/main.css"
    click SCSS_MAIN "https://github.com/sobold/sb-starter/blob/main//scss/main.scss"
    click SCSS_ABS "https://github.com/sobold/sb-starter/tree/main//scss/abstracts/"
    click SCSS_BASE "https://github.com/sobold/sb-starter/tree/main//scss/base/"
    click SCSS_COMP "https://github.com/sobold/sb-starter/tree/main//scss/components/"
    click SCSS_LAY "https://github.com/sobold/sb-starter/tree/main//scss/layout/"
    click SCSS_PB "https://github.com/sobold/sb-starter/tree/main//scss/pagebuilder/"
    click SCSS_PG "https://github.com/sobold/sb-starter/tree/main//scss/pages/"
    click JS1 "https://github.com/sobold/sb-starter/blob/main//js/customizer.js"
    click JS2 "https://github.com/sobold/sb-starter/blob/main//js/skip-link-focus-fix.js"
    click ASSETS "https://github.com/sobold/sb-starter/tree/main//assets/"
    click TGM_LIB "https://github.com/sobold/sb-starter/tree/main//lib/tgm/"

    %% Styles
    classDef core fill:#ADD8E6,stroke:#000
    classDef theme fill:#90EE90,stroke:#000
    classDef assets fill:#FFFFE0,stroke:#000
    classDef external fill:#FFA500,stroke:#000
    classDef client fill:#F0F8FF,stroke:#000
```
