# formewp/forme-framework architecture

> Architecture diagram of the GitHub repository formewp/forme-framework, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/formewp/forme-framework
- Repository: https://github.com/formewp/forme-framework

## Overview

##### Main Architectural Components

a. HTTP Layer (Top Level)
- HTTP Handlers (Ajax, REST, Custom Routes, Templates)
- ServerRequest handling
- Middleware support

b. Core Framework Layer (Middle Level)
- Router Component
- Authentication System
- Asset Management
- Plugin/Theme Loading System

c. Database Layer (Bottom Level)
- Connection Management
- Migration System
- Model Layer

##### Key Relationships to Highlight

a. Request Flow:
- HTTP Request → Router → Handler → Controller → View → Response

b. View Engine Integration:
- Controller → View Interface → Implementation (Blade/Plates/Twig)

c. Job Queue System:
- Queue → Jobs → Database Storage → Worker Process

##### Specific Components

a. Core Framework:
- Router (src/Core/Router)
- Loader (src/Core/Loader)
- Assets (src/Core/Assets)

b. HTTP Layer:
- Request Handlers
- Middleware
- Response Factory

c. Database:
- Connection Management
- Migration System
- Models (Post, User, Comment, etc.)

d. View System:
- View Interface
- Template Engines (Blade, Plates, Twig)
- View Helpers

##### Important Architectural Patterns to Emphasize

a. MVC Pattern:
- Clear separation between Models (src/Models)
- Controllers (src/Controllers)
- Views (src/View)

b. Strategy Pattern:
- Router strategies
- View engine implementations

c. Queue System:
- Job queue implementation
- Worker process
- Database storage

##### Integration Points

Clear integration points with:
- WordPress Core
- External Plugins
- Theme System
- Database

Special Considerations:
##### Job queue system as a parallel process

This architecture should reflect the framework's goal of providing a structured, MVC-based approach to WordPress development while maintaining compatibility with the WordPress ecosystem.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph HTTP_Layer
        HTTP["HTTP Handlers"]:::http
        SR["Server Request"]:::http
        MW["Middleware"]:::http
        RF["Response Factory"]:::http
    end

    subgraph Core_Framework
        Router["Router"]:::core
        RS["Router Strategies"]:::core
        Auth["Authentication"]:::core
        Assets["Asset Management"]:::core
        Loader["Plugin/Theme Loading"]:::core
    end

    subgraph View_System
        VI["View Interface"]:::view
        BE["Blade Engine"]:::view
        PE["Plates Engine"]:::view
        TE["Twig Engine"]:::view
        VH["View Helpers"]:::view
    end

    subgraph Database_Layer
        CM["Connection Manager"]:::db
        MS["Migration System"]:::db
        Models["Models"]:::db
    end

    subgraph Job_Queue
        QI["Queue Interface"]:::queue
        QImpl["Queue Implementation"]:::queue
        QC["Queue Command"]:::queue
        QJ["Queued Job Model"]:::queue
    end

    subgraph Controllers
        BC["Base Controller"]:::controller
        CI["Controller Interface"]:::controller
    end

    subgraph WP_Models
        PM["Post Model"]:::model
        UM["User Model"]:::model
        CM2["Comment Model"]:::model
    end

    %% Relationships
    HTTP --> SR
    SR --> MW
    MW --> Router
    Router --> BC
    BC --> VI
    VI --> BE & PE & TE
    BC --> Models
    Models --> CM
    QImpl --> QJ
    QJ --> CM
    Auth --> UM

    %% Click Events
    click HTTP "https://github.com/formewp/forme-framework/tree/main/src/Http/Handlers/"
    click SR "https://github.com/formewp/forme-framework/blob/main/src/Http/ServerRequest.php"
    click MW "https://github.com/formewp/forme-framework/tree/main/src/Middleware/"
    click RF "https://github.com/formewp/forme-framework/blob/main/src/Http/ResponseFactory.php"
    click Router "https://github.com/formewp/forme-framework/blob/main/src/Core/Router.php"
    click RS "https://github.com/formewp/forme-framework/tree/main/src/Router/Strategy/"
    click Auth "https://github.com/formewp/forme-framework/tree/main/src/Auth/"
    click Assets "https://github.com/formewp/forme-framework/blob/main/src/Core/Assets.php"
    click Loader "https://github.com/formewp/forme-framework/blob/main/src/Core/Loader.php"
    click CM "https://github.com/formewp/forme-framework/blob/main/src/Database/Connection.php"
    click MS "https://github.com/formewp/forme-framework/tree/main/src/Database/Migrations/"
    click Models "https://github.com/formewp/forme-framework/tree/main/src/Models/"
    click VI "https://github.com/formewp/forme-framework/blob/main/src/View/ViewInterface.php"
    click BE "https://github.com/formewp/forme-framework/tree/main/src/View/Blade/"
    click PE "https://github.com/formewp/forme-framework/tree/main/src/View/Plates/"
    click TE "https://github.com/formewp/forme-framework/blob/main/src/View/TwigView.php"
    click QI "https://github.com/formewp/forme-framework/blob/main/src/Jobs/JobInterface.php"
    click QImpl "https://github.com/formewp/forme-framework/blob/main/src/Jobs/Queue.php"
    click QC "https://github.com/formewp/forme-framework/blob/main/src/Commands/JobQueueCommand.php"
    click QJ "https://github.com/formewp/forme-framework/blob/main/src/Models/QueuedJob.php"
    click BC "https://github.com/formewp/forme-framework/blob/main/src/Controllers/AbstractController.php"
    click CI "https://github.com/formewp/forme-framework/blob/main/src/Controllers/ControllerInterface.php"
    click PM "https://github.com/formewp/forme-framework/blob/main/src/Models/Post.php"
    click UM "https://github.com/formewp/forme-framework/blob/main/src/Models/User.php"
    click CM2 "https://github.com/formewp/forme-framework/blob/main/src/Models/Comment.php"

    %% Styles
    classDef http fill:#90EE90
    classDef core fill:#87CEEB
    classDef view fill:#DDA0DD
    classDef db fill:#FFD700
    classDef queue fill:#FFA500
    classDef controller fill:#B8860B
    classDef model fill:#20B2AA

    %% Legend
    subgraph Legend
        L1["HTTP Layer"]:::http
        L2["Core Framework"]:::core
        L3["View System"]:::view
        L4["Database Layer"]:::db
        L5["Job Queue"]:::queue
        L6["Controllers"]:::controller
        L7["WordPress Models"]:::model
    end
```
