# tayfunerbilen/php-boilerplate architecture

> Architecture diagram of the GitHub repository tayfunerbilen/php-boilerplate, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tayfunerbilen/php-boilerplate
- Repository: https://github.com/tayfunerbilen/php-boilerplate

## Overview

This repository is a PHP application boilerplate, not a finished domain product. Its demonstrated request workflow starts at the front controller, initializes framework services, registers routes, and dispatches to controllers; the home controller supports post creation and listing, while authentication controllers handle registration, login, and logout. The README also documents routing, templates, validation, database, sessions, configuration, error handling, dates, and uploads. The graph preserves these capabilities but limits connections to those shown in the README or supplied source evidence; several utility integrations are documented rather than traced through sampled calls.

Main entry points: [`app/controllers/Home.php`](https://github.com/tayfunerbilen/php-boilerplate/blob/main/app/controllers/Home.php) (Post home), [`app/route.php`](https://github.com/tayfunerbilen/php-boilerplate/blob/main/app/route.php) (Route definitions), [`core/Bootstrap.php`](https://github.com/tayfunerbilen/php-boilerplate/blob/main/core/Bootstrap.php) (Application bootstrap), [`index.php`](https://github.com/tayfunerbilen/php-boilerplate/blob/main/index.php) (Front controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Request handling"]
  node_front["Front controller<br/>[index.php]"]
  node_routes["Route definitions<br/>[route.php]"]
end

subgraph group_domain["Application features"]
  node_home["Post home<br/>[Home.php]"]
  node_authcontroller["Authentication actions<br/>[Auth.php]"]
  node_api["Posts API<br/>[Api.php]"]
  node_authguard["Authentication checks<br/>[CheckAuth.php]"]
  node_guestguard["Guest-only checks<br/>[CheckNotAuth.php]"]
  node_post["Post records<br/>[Post.php]"]
  node_user["User records<br/>[User.php]"]
  node_homeview["Home template<br/>[home.blade.php]"]
  node_loginview["Login and registration templates"]
end

subgraph group_services["Framework services"]
  node_bootstrap["Application bootstrap<br/>[Bootstrap.php]"]
  node_authservice["Session authentication<br/>[Auth.php]"]
  node_upload["Image upload<br/>[Upload.php]"]
  node_view["Template rendering<br/>[View.php]"]
  node_controller["Controller base<br/>[Controller.php]"]
  node_modelbase["ORM base<br/>[Model.php]"]
end

subgraph group_state["Persistence"]
  node_database[("MySQL database")]
  node_postfiles[("Uploaded post images")]
end

node_visitor(("Browser user"))

node_visitor -->|"requests"| node_front
node_front -->|"initializes"| node_bootstrap
node_front -->|"loads routes"| node_routes
node_front -->|"runs router"| node_bootstrap
node_bootstrap -->|"dispatches routes"| node_routes
node_bootstrap -->|"creates renderer"| node_view
node_bootstrap -->|"configures connection"| node_database
node_routes -->|"routes requests"| node_home
node_routes -->|"routes requests"| node_authcontroller
node_routes -->|"routes requests"| node_api
node_routes -->|"guards login routes"| node_guestguard
node_home -->|"creates and lists"| node_post
node_home -->|"uploads images"| node_upload
node_home -->|"writes images"| node_postfiles
node_home -->|"renders"| node_homeview
node_home -->|"extends"| node_controller
node_authcontroller -.->|"authenticates"| node_authservice
node_authcontroller -->|"renders forms"| node_loginview
node_authcontroller -->|"extends"| node_controller
node_authservice -->|"reads and creates"| node_user
node_post -->|"extends"| node_modelbase
node_user -->|"extends"| node_modelbase
node_post -->|"belongs to"| node_user
node_user -->|"has many"| node_post
node_controller -->|"inherits services"| node_bootstrap

click node_front "https://github.com/tayfunerbilen/php-boilerplate/blob/main/index.php"
click node_bootstrap "https://github.com/tayfunerbilen/php-boilerplate/blob/main/core/Bootstrap.php"
click node_routes "https://github.com/tayfunerbilen/php-boilerplate/blob/main/app/route.php"
click node_home "https://github.com/tayfunerbilen/php-boilerplate/blob/main/app/controllers/Home.php"
click node_authcontroller "https://github.com/tayfunerbilen/php-boilerplate/blob/main/app/controllers/Auth.php"
click node_api "https://github.com/tayfunerbilen/php-boilerplate/blob/main/app/controllers/Api.php"
click node_authguard "https://github.com/tayfunerbilen/php-boilerplate/blob/main/app/middlewares/CheckAuth.php"
click node_guestguard "https://github.com/tayfunerbilen/php-boilerplate/blob/main/app/middlewares/CheckNotAuth.php"
click node_authservice "https://github.com/tayfunerbilen/php-boilerplate/blob/main/core/Auth.php"
click node_upload "https://github.com/tayfunerbilen/php-boilerplate/blob/main/core/Upload.php"
click node_view "https://github.com/tayfunerbilen/php-boilerplate/blob/main/core/View.php"
click node_controller "https://github.com/tayfunerbilen/php-boilerplate/blob/main/core/Controller.php"
click node_modelbase "https://github.com/tayfunerbilen/php-boilerplate/blob/main/core/Model.php"
click node_post "https://github.com/tayfunerbilen/php-boilerplate/blob/main/app/models/Post.php"
click node_user "https://github.com/tayfunerbilen/php-boilerplate/blob/main/app/models/User.php"
click node_postfiles "https://github.com/tayfunerbilen/php-boilerplate/tree/main/upload/posts"
click node_homeview "https://github.com/tayfunerbilen/php-boilerplate/blob/main/public/views/home.blade.php"
click node_loginview "https://github.com/tayfunerbilen/php-boilerplate/tree/main/public/views/auth"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_front,node_routes,node_visitor toneBlue
class node_home,node_authcontroller,node_api,node_authguard,node_guestguard,node_post,node_user,node_homeview,node_loginview toneAmber
class node_bootstrap,node_authservice,node_upload,node_view,node_controller,node_modelbase toneMint
class node_database,node_postfiles toneRose
```

## Components

### Request handling

- [Front controller](https://github.com/tayfunerbilen/php-boilerplate/blob/main/index.php): `index.php`
- [Route definitions](https://github.com/tayfunerbilen/php-boilerplate/blob/main/app/route.php): `app/route.php`

### Application features

- [Post home](https://github.com/tayfunerbilen/php-boilerplate/blob/main/app/controllers/Home.php): `app/controllers/Home.php`
- [Authentication actions](https://github.com/tayfunerbilen/php-boilerplate/blob/main/app/controllers/Auth.php): `app/controllers/Auth.php`
- [Posts API](https://github.com/tayfunerbilen/php-boilerplate/blob/main/app/controllers/Api.php): `app/controllers/Api.php`
- [Authentication checks](https://github.com/tayfunerbilen/php-boilerplate/blob/main/app/middlewares/CheckAuth.php): `app/middlewares/CheckAuth.php`
- [Guest-only checks](https://github.com/tayfunerbilen/php-boilerplate/blob/main/app/middlewares/CheckNotAuth.php): `app/middlewares/CheckNotAuth.php`
- [Post records](https://github.com/tayfunerbilen/php-boilerplate/blob/main/app/models/Post.php): `app/models/Post.php`
- [User records](https://github.com/tayfunerbilen/php-boilerplate/blob/main/app/models/User.php): `app/models/User.php`
- [Home template](https://github.com/tayfunerbilen/php-boilerplate/blob/main/public/views/home.blade.php): `public/views/home.blade.php`
- [Login and registration templates](https://github.com/tayfunerbilen/php-boilerplate/tree/main/public/views/auth): `public/views/auth`

### Framework services

- [Application bootstrap](https://github.com/tayfunerbilen/php-boilerplate/blob/main/core/Bootstrap.php): `core/Bootstrap.php`
- [Session authentication](https://github.com/tayfunerbilen/php-boilerplate/blob/main/core/Auth.php): `core/Auth.php`
- [Image upload](https://github.com/tayfunerbilen/php-boilerplate/blob/main/core/Upload.php): `core/Upload.php`
- [Template rendering](https://github.com/tayfunerbilen/php-boilerplate/blob/main/core/View.php): `core/View.php`
- [Controller base](https://github.com/tayfunerbilen/php-boilerplate/blob/main/core/Controller.php): `core/Controller.php`
- [ORM base](https://github.com/tayfunerbilen/php-boilerplate/blob/main/core/Model.php): `core/Model.php`

### Persistence

- **MySQL database**
- [Uploaded post images](https://github.com/tayfunerbilen/php-boilerplate/tree/main/upload/posts): `upload/posts`

### Other components

- **Browser user**

## Connections

- Browser user → Front controller: requests (evidence: `index.php`)
- Front controller → Application bootstrap: initializes (evidence: `index.php`)
- Front controller → Route definitions: loads routes (evidence: `index.php`)
- Front controller → Application bootstrap: runs router (evidence: `index.php`)
- Application bootstrap → Route definitions: dispatches routes (evidence: `app/route.php`)
- Application bootstrap → Template rendering: creates renderer (evidence: `core/Bootstrap.php`)
- Application bootstrap → MySQL database: configures connection (evidence: `core/Bootstrap.php`)
- Route definitions → Post home: routes requests (evidence: `app/route.php`)
- Route definitions → Authentication actions: routes requests (evidence: `app/route.php`)
- Route definitions → Posts API: routes requests (evidence: `app/route.php`)
- Route definitions → Guest-only checks: guards login routes (evidence: `app/route.php`)
- Post home → Post records: creates and lists (evidence: `app/controllers/Home.php`)
- Post home → Image upload: uploads images (evidence: `app/controllers/Home.php`)
- Post home → Uploaded post images: writes images (evidence: `app/controllers/Home.php`)
- Post home → Home template: renders (evidence: `app/controllers/Home.php`)
- Post home → Controller base: extends (evidence: `app/controllers/Home.php`)
- Authentication actions → Session authentication: authenticates
- Authentication actions → Login and registration templates: renders forms (evidence: `app/controllers/Auth.php`)
- Authentication actions → Controller base: extends (evidence: `app/controllers/Auth.php`)
- Session authentication → User records: reads and creates (evidence: `core/Auth.php`)
- Post records → ORM base: extends (evidence: `app/models/Post.php`)
- User records → ORM base: extends (evidence: `app/models/User.php`)
- Post records → User records: belongs to (evidence: `app/models/Post.php`)
- User records → Post records: has many (evidence: `app/models/User.php`)
- Controller base → Application bootstrap: inherits services (evidence: `core/Controller.php`)
