# fran-f/yolk architecture

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

- Interactive diagram: https://gitdiagram.com/fran-f/yolk
- Repository: https://github.com/fran-f/yolk

## Overview

##### Main Components

a) Core Components:
- Request Handler (App.php as the entry point)
- Router (Routes.php)
- Dispatcher (Dispatcher.php)
- Middleware System (Middleware.php)
- Request/Response System
- View Renderer Interface

b) Supporting Components:
- Exception Handlers
- Controller Layer (shown as an external integration)
- Dependency Injection System

##### Detailed Component Relationships

- How App orchestrates Router, Dispatcher, and Middleware
- How Request objects flow through the system
- How Response objects are generated and transformed
- Where exception handling occurs

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Browser["Web Browser"]
        Apache["Apache Server"]
    end

    subgraph "Framework Core"
        App["Application Handler"]:::core
        Router["Router System"]:::core
        Dispatcher["Request Dispatcher"]:::core
        Middleware["Middleware Chain"]:::core
        
        subgraph "Request System"
            BaseReq["Base Request"]:::request
            HttpReq["HTTP Request"]:::request
            ApacheReq["Apache HTTP Request"]:::request
        end
        
        subgraph "Response System"
            BaseRes["Base Response"]:::response
            ViewRes["View Response"]:::response
        end
        
        subgraph "Exception Handlers"
            InvalidRes["Invalid Response"]:::error
            MethodNA["Method Not Allowed"]:::error
            MissingParam["Missing Parameter"]:::error
            RouteNF["Route Not Found"]:::error
        end
    end

    subgraph "Integration Layer"
        Controller["Controller Layer"]:::external
        ViewRenderer["View Renderer"]:::external
        DI["Dependency Injection"]:::external
    end

    %% Flow
    Browser --> Apache
    Apache --> ApacheReq
    ApacheReq --> App
    App --> Router
    App --> Middleware
    Middleware --> Dispatcher
    Dispatcher --> Controller
    Controller --> BaseRes
    BaseRes --> ViewRes
    ViewRes --> ViewRenderer
    ViewRenderer --> Browser

    %% Exception flows
    Router -.-> RouteNF
    Dispatcher -.-> MethodNA
    Controller -.-> MissingParam
    Controller -.-> InvalidRes

    %% Styles
    classDef core fill:#a8d1f0,stroke:#333
    classDef request fill:#ffe4b5,stroke:#333
    classDef response fill:#98fb98,stroke:#333
    classDef error fill:#ffb6c1,stroke:#333
    classDef external fill:#dcdcdc,stroke:#333

    %% Click events
    click App "https://github.com/fran-f/yolk/blob/main/src/App.php"
    click Router "https://github.com/fran-f/yolk/blob/main/src/Routes.php"
    click Dispatcher "https://github.com/fran-f/yolk/blob/main/src/Dispatcher.php"
    click Middleware "https://github.com/fran-f/yolk/blob/main/src/Middleware.php"
    click BaseReq "https://github.com/fran-f/yolk/blob/main/src/Request.php"
    click HttpReq "https://github.com/fran-f/yolk/blob/main/src/HttpRequest.php"
    click ApacheReq "https://github.com/fran-f/yolk/blob/main/src/ApacheHttpRequest.php"
    click BaseRes "https://github.com/fran-f/yolk/blob/main/src/Response.php"
    click ViewRes "https://github.com/fran-f/yolk/blob/main/src/Responses/View.php"
    click InvalidRes "https://github.com/fran-f/yolk/blob/main/src/Exceptions/InvalidResponse.php"
    click MethodNA "https://github.com/fran-f/yolk/blob/main/src/Exceptions/MethodNotAllowed.php"
    click MissingParam "https://github.com/fran-f/yolk/blob/main/src/Exceptions/MissingParameter.php"
    click RouteNF "https://github.com/fran-f/yolk/blob/main/src/Exceptions/RouteNotFound.php"
```
