# dannysimfukwe/php-mvc-framework architecture

> Architecture diagram of the GitHub repository dannysimfukwe/php-mvc-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/php-mvc-framework
- Repository: https://github.com/dannysimfukwe/php-mvc-framework

## Overview

##### Project Type Analysis
This is a custom PHP MVC (Model-View-Controller) framework with Docker containerization, database migrations support, and a simple web application structure.

##### Main Components

A. Application Layer Components:
- MVC Core Components
- Models (src/App/Models)
- Views (src/views)
- Controllers (src/App/Controllers)
- Core Framework Components (src/App/Core)
- Request Handling Layer (src/App/Requests)
- Routing System (src/routes)

B. Infrastructure Components:
- Docker Container Environment
- MySQL Database
- Web Server (indicated by .htaccess)

**[Client Layer]**

**[Application Container]**
- Web Server (Apache/PHP)
- MVC Framework Core
- Router
- Controllers
- Models
- Views

**[Database Layer]**
- MySQL

##### Specific Component Relationships to Highlight

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

b. Database Interactions:
- AsyncMySQL and MySQLPool connections
- Database migration system (Phinx)

##### Important Architectural Details

a. Core Framework Features:
- Async Processing (Async.php, AsyncMySQL.php, AsyncSocket.php)
- Database Connection Pooling (MySQLPool.php)
- HTTP Request Handling (Http.php)

b. Application Structure:
- Inheritance hierarchy from base Controller and Model classes
- View rendering system
- Routing system's role

##### Additional Elements

a. Development Tools:
- Migration System (Phinx)
- Seeding Capability
- Docker Container Architecture

b. Static Assets:
- CSS and Images directories
- Font Resources

Top Section:
**[Client Browser] ←→ [Docker Container]**

Middle Section:
**[Router] → [Controller Layer]**
- ↓
**[Model Layer] ←→ [Database Pool] → [MySQL]**
- ↓
**[View Layer] → [Response]**

Bottom Section:
**[Supporting Services]**
- Migration System
- Seeding System
- Static Assets

##### Key Relationships to Emphasize
- Request lifecycle through the MVC pattern
- Async database operations
- Container orchestration
- Static asset serving
- Database migration and seeding workflows

Remember to:
- Notes about the async nature of database operations
- Containerized environment
- Separation of concerns between different layers

## Diagram (Mermaid)

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

    subgraph "Docker Container"
        WebServer["Web Server (Apache/PHP)"]:::server
        
        subgraph "MVC Framework Core"
            Router["Router"]:::core
            click Router "https://github.com/dannysimfukwe/php-mvc-framework/blob/master/src/routes/router.php"
            
            subgraph "Controller Layer"
                BaseController["Base Controller"]:::controller
                click BaseController "https://github.com/dannysimfukwe/php-mvc-framework/blob/master/src/App/Controllers/Controller.php"
                AppController["App Controller"]:::controller
                click AppController "https://github.com/dannysimfukwe/php-mvc-framework/blob/master/src/App/Core/AppController.php"
            end
            
            subgraph "Model Layer"
                BaseModel["Base Model"]:::model
                click BaseModel "https://github.com/dannysimfukwe/php-mvc-framework/blob/master/src/App/Models/Model.php"
            end
            
            subgraph "View Layer"
                ViewEngine["View Engine"]:::view
                click ViewEngine "https://github.com/dannysimfukwe/php-mvc-framework/blob/master/src/App/Views/View.php"
                Templates["Templates"]:::view
                click Templates "https://github.com/dannysimfukwe/php-mvc-framework/tree/master/src/views/pages"
            end
            
            subgraph "Core Components"
                AsyncProcessor["Async Processor"]:::core
                click AsyncProcessor "https://github.com/dannysimfukwe/php-mvc-framework/blob/master/src/App/Core/Async.php"
                HttpHandler["HTTP Handler"]:::core
                click HttpHandler "https://github.com/dannysimfukwe/php-mvc-framework/blob/master/src/App/Core/Http.php"
                RequestProcessor["Request Processor"]:::core
                click RequestProcessor "https://github.com/dannysimfukwe/php-mvc-framework/blob/master/src/App/Requests/Request.php"
            end
        end
        
        subgraph "Database Layer"
            DBPool["MySQL Pool"]:::database
            click DBPool "https://github.com/dannysimfukwe/php-mvc-framework/blob/master/src/App/Core/MySQLPool.php"
            AsyncMySQL["Async MySQL"]:::database
            click AsyncMySQL "https://github.com/dannysimfukwe/php-mvc-framework/blob/master/src/App/Core/AsyncMySQL.php"
            DBConnection["DB Connection"]:::database
            click DBConnection "https://github.com/dannysimfukwe/php-mvc-framework/blob/master/src/App/Database/getConnection.php"
        end
        
        subgraph "Development Tools"
            Migrations["Migrations"]:::tool
            click Migrations "https://github.com/dannysimfukwe/php-mvc-framework/tree/master/src/database/migrations"
            Seeds["Database Seeds"]:::tool
            click Seeds "https://github.com/dannysimfukwe/php-mvc-framework/blob/master/src/database/seeds/PostSeeder.php"
            MigrationConfig["Migration Config"]:::tool
            click MigrationConfig "https://github.com/dannysimfukwe/php-mvc-framework/blob/master/src/phinx.php"
        end
        
        subgraph "Static Assets"
            CSS["Stylesheets"]:::static
            click CSS "https://github.com/dannysimfukwe/php-mvc-framework/tree/master/src/css"
            Fonts["Fonts"]:::static
            click Fonts "https://github.com/dannysimfukwe/php-mvc-framework/tree/master/src/fonts"
            Images["Images"]:::static
            click Images "https://github.com/dannysimfukwe/php-mvc-framework/tree/master/src/images"
        end
    end
    
    subgraph "External Database"
        MySQL["MySQL Database"]:::database
    end
    
    %% Relationships
    Browser --> WebServer
    WebServer --> Router
    Router --> BaseController
    BaseController --> AppController
    BaseController --> BaseModel
    BaseModel --> DBPool
    DBPool --> AsyncMySQL
    AsyncMySQL --> DBConnection
    DBConnection --> MySQL
    BaseController --> ViewEngine
    ViewEngine --> Templates
    
    %% Core Component Relationships
    RequestProcessor --> HttpHandler
    HttpHandler --> AsyncProcessor
    AsyncProcessor --> DBPool
    
    %% Development Tool Relationships
    Migrations --> MySQL
    Seeds --> MySQL
    MigrationConfig --> Migrations
    
    %% Styles
    classDef core fill:#2374ab
    classDef controller fill:#ff7f50
    classDef model fill:#4caf50
    classDef view fill:#9c27b0
    classDef database fill:#607d8b
    classDef server fill:#795548
    classDef tool fill:#ff9800
    classDef static fill:#9e9e9e

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["Controllers"]:::controller
        L3["Models"]:::model
        L4["Views"]:::view
        L5["Database"]:::database
        L6["Server"]:::server
        L7["Tools"]:::tool
        L8["Static Assets"]:::static
    end
```
