# dannysimfukwe/custom_php_framework architecture

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

- Interactive diagram: https://gitdiagram.com/dannysimfukwe/custom_php_framework
- Repository: https://github.com/dannysimfukwe/custom_php_framework

## Overview

##### Main Components

A. Core Framework Layer:
- Application Core (system/Application.php)
- Router (system/Router.php)
- Controller Base Class (system/Controller.php)
- Model Base Class (system/Model.php)
- View Loading System (system/Load.php)

B. Framework Services:
- Database Layer (libraries/Database.php)
- Session Management (libraries/Session.php)
- Security Services (libraries/Security.php)
- Cache System (system/Cache.php)
- Logger (system/Logger.php)

C. Supporting Components:
- Configuration Management
- Language System
- Input/Output Handling
- File Upload System
- REST API Support

**┌─────────────────────────────────────────────┐**
- Client Layer                 │
- ┘
- ↓
**┌─────────────────────────────────────────────┐**
- Front Controller              │
- (index.php/Router)             │
- ┘
- ↓
**┌─────────────────────────────────────────────┐**
- Application Core                │
- ┌──────────┐  ┌──────────┐ ┌──────────┐ │
- Controllers│  │  Models  │ │  Views   │ │
- ┘  └──────────┘ └──────────┘ │
- ┘
- ↓
**┌─────────────────────────────────────────────┐**
- Framework Services              │
- ┌────────┐ ┌─────────┐ ┌────────┐ ┌─────┐ │
- Database│ │Security │ │Session │ │Cache│ │
- ┘ └─────────┘ └────────┘ └─────┘ │
- ┘

##### Key Relationships to Highlight

a. Request Flow:
- Client Request → Front Controller → Router → Controller → Model/View

b. Service Dependencies:
- Controllers depending on Models
- Views being loaded by Controllers
- Database interactions through Models
- Security checks throughout the request lifecycle

##### Important Details

- Configuration management flow
- Database connection handling
- Session management process
- Caching mechanism
- Error handling and logging system
- Language/Internationalization support

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    Client(("Client Request"))

    %% Front Controller Layer
    subgraph FrontEnd["Front Controller Layer"]
        FrontController["Front Controller"]:::frontcontroller
        Router["Router System"]:::router
        AutoLoader["Autoloading System"]:::autoloader
    end

    %% Application Core Layer
    subgraph AppCore["Application Core Layer"]
        AppMain["Application Core"]:::appcore
        Controller["Controller Base"]:::controller
        Model["Model Base"]:::model
        ViewLoader["View Loading System"]:::viewloader
        ViewTemplates["View Templates"]:::templates
    end

    %% Framework Services Layer
    subgraph Services["Framework Services"]
        direction TB
        subgraph CoreServices["Core Services"]
            direction TB
            DB["Database Layer"]:::database
            Security["Security Services"]:::security
            Session["Session Management"]:::session
            Cache["Cache System"]:::cache
            Logger["Logger System"]:::logger
        end

        subgraph UtilityServices["Utility Services"]
            direction TB
            Config["Configuration Management"]:::config
            Language["Language System"]:::language
            IO["Input/Output Handling"]:::io
            Upload["File Upload System"]:::upload
            REST["REST API Support"]:::rest
            URL["URL Handler"]:::url
            Benchmark["Performance Monitor"]:::benchmark
            Permission["Permission System"]:::permission
        end
    end

    %% Relationships
    Client --> FrontController
    FrontController --> Router
    FrontController --> AutoLoader
    Router --> AppMain
    AppMain --> Controller
    Controller --> Model
    Controller --> ViewLoader
    ViewLoader --> ViewTemplates
    Model --> DB
    
    %% Service Dependencies
    Controller --> Security
    Controller --> Session
    Controller --> Cache
    Model --> Cache
    AppMain --> Logger
    Controller --> Config
    Model --> Config
    Controller --> Language
    Controller --> IO
    Controller --> Upload
    Controller --> REST
    Controller --> URL
    AppMain --> Benchmark
    Controller --> Permission

    %% Styling
    classDef frontcontroller fill:#f9f,stroke:#333
    classDef router fill:#f9f,stroke:#333
    classDef autoloader fill:#f9f,stroke:#333
    classDef appcore fill:#bbf,stroke:#333
    classDef controller fill:#bbf,stroke:#333
    classDef model fill:#bbf,stroke:#333
    classDef viewloader fill:#bbf,stroke:#333
    classDef templates fill:#bbf,stroke:#333
    classDef database fill:#bfb,stroke:#333
    classDef security fill:#fbb,stroke:#333
    classDef session fill:#bfb,stroke:#333
    classDef cache fill:#bfb,stroke:#333
    classDef logger fill:#bfb,stroke:#333
    classDef config fill:#ddd,stroke:#333
    classDef language fill:#ddd,stroke:#333
    classDef io fill:#ddd,stroke:#333
    classDef upload fill:#ddd,stroke:#333
    classDef rest fill:#ddd,stroke:#333
    classDef url fill:#ddd,stroke:#333
    classDef benchmark fill:#ddd,stroke:#333
    classDef permission fill:#ddd,stroke:#333

    %% Click Events
    click FrontController "https://github.com/dannysimfukwe/custom_php_framework/blob/master/index.php"
    click Router "https://github.com/dannysimfukwe/custom_php_framework/blob/master/system/Router.php"
    click AutoLoader "https://github.com/dannysimfukwe/custom_php_framework/blob/master/includes/autoload.php"
    click AppMain "https://github.com/dannysimfukwe/custom_php_framework/blob/master/system/Application.php"
    click Controller "https://github.com/dannysimfukwe/custom_php_framework/blob/master/system/Controller.php"
    click Model "https://github.com/dannysimfukwe/custom_php_framework/blob/master/system/Model.php"
    click ViewLoader "https://github.com/dannysimfukwe/custom_php_framework/blob/master/system/Load.php"
    click ViewTemplates "https://github.com/dannysimfukwe/custom_php_framework/blob/master/views/app/template.php"
    click DB "https://github.com/dannysimfukwe/custom_php_framework/blob/master/libraries/Database.php"
    click Security "https://github.com/dannysimfukwe/custom_php_framework/blob/master/libraries/Security.php"
    click Session "https://github.com/dannysimfukwe/custom_php_framework/blob/master/libraries/Session.php"
    click Cache "https://github.com/dannysimfukwe/custom_php_framework/blob/master/system/Cache.php"
    click Logger "https://github.com/dannysimfukwe/custom_php_framework/blob/master/system/Logger.php"
    click Config "https://github.com/dannysimfukwe/custom_php_framework/blob/master/includes/config.php"
    click Language "https://github.com/dannysimfukwe/custom_php_framework/blob/master/libraries/Language.php"
    click IO "https://github.com/dannysimfukwe/custom_php_framework/blob/master/libraries/Input.php"
    click Upload "https://github.com/dannysimfukwe/custom_php_framework/blob/master/libraries/Upload.php"
    click REST "https://github.com/dannysimfukwe/custom_php_framework/blob/master/libraries/REST.php"
    click URL "https://github.com/dannysimfukwe/custom_php_framework/blob/master/libraries/Url.php"
    click Benchmark "https://github.com/dannysimfukwe/custom_php_framework/blob/master/system/Benchmark.php"
    click Permission "https://github.com/dannysimfukwe/custom_php_framework/blob/master/libraries/Permission.php"
```
