# jonasbirkelof/beets-php architecture

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

- Interactive diagram: https://gitdiagram.com/jonasbirkelof/beets-php
- Repository: https://github.com/jonasbirkelof/beets-php

## Overview

Beets PHP is a REST-style MVC microframework with a bundled user-administration application. A browser request enters the front controller and route table, passes authentication/permission gates, reaches login, profile, or user-account actions, and renders a view or redirects with session feedback. Models validate and persist user/profile and role data through the database layer. The README also describes a designed, replaceable UI and optional Docker/local development integrations; source excerpts do not establish detailed runtime wiring for those capabilities.

Main entry points: [`src/App/Http/Controllers/ProfileController.php`](https://github.com/jonasbirkelof/beets-php/blob/master/src/App/Http/Controllers/ProfileController.php) (Profile actions), [`src/App/Http/Controllers/UserController.php`](https://github.com/jonasbirkelof/beets-php/blob/master/src/App/Http/Controllers/UserController.php) (User administration), [`src/App/Models/User.php`](https://github.com/jonasbirkelof/beets-php/blob/master/src/App/Models/User.php) (User records), [`src/App/Core/Router.php`](https://github.com/jonasbirkelof/beets-php/blob/master/src/App/Core/Router.php) (Router)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Request framework"]
  node_front["Front controller<br/>[index.php]"]
  node_routes["REST route table<br/>[web.php]"]
  node_router["Router<br/>[Router.php]"]
  node_app["View and errors<br/>[App.php]"]
  node_database["PDO database<br/>[Database.php]"]
end

subgraph group_identity["Identity and access"]
  node_auth["Authentication state<br/>[Authenticate.php]"]
  node_login_controller["Login actions"]
  node_login_model["Login and session<br/>[Login.php]"]
  node_roles["Role and permissions<br/>[Role.php]"]
  node_permissions["Permission rules<br/>[Permission.php]"]
end

subgraph group_accounts["Account administration"]
  node_profile_controller["Profile actions"]
  node_profile_model["Profile data<br/>[Profile.php]"]
  node_user_controller["User administration<br/>[UserController.php]"]
  node_user_model["User records<br/>[User.php]"]
  node_form["Form validation<br/>[Form.php]"]
  node_csrf["CSRF protection<br/>[CSRF.php]"]
end

subgraph group_interface["Application interface"]
  node_feedback["Session feedback<br/>[Feedback.php]"]
  node_views["Application views"]
  node_navigation["Navigation and sidebar<br/>[navigation.php]"]
  node_layout_js["Beets Layout UI<br/>[beets-layout.js]"]
end

subgraph group_deployment["Runtime integrations"]
  node_web_server(("PHP web server"))
  node_mysql[("MySQL database")]
  node_docker_mailhog["MailHog"]
end

node_browser(("Browser user"))

node_browser -->|"sends request"| node_web_server
node_web_server -.->|"serves PHP"| node_front
node_front -->|"loads routes"| node_routes
node_routes -->|"registers routes"| node_router
node_router -->|"dispatches login"| node_login_controller
node_router -->|"dispatches profile"| node_profile_controller
node_router -->|"dispatches users"| node_user_controller
node_routes -->|"checks access"| node_auth
node_login_controller -->|"attempts login"| node_login_model
node_login_model -->|"sets identity"| node_auth
node_login_model -->|"queries accounts"| node_database
node_login_model -->|"loads role"| node_roles
node_roles -->|"loads permissions"| node_permissions
node_profile_controller -->|"updates profile"| node_profile_model
node_profile_controller -->|"manages image"| node_user_model
node_profile_controller -->|"validates token"| node_csrf
node_user_controller -->|"manages accounts"| node_user_model
node_user_controller -->|"loads role options"| node_roles
node_user_controller -->|"validates token"| node_csrf
node_user_model -->|"queries records"| node_database
node_profile_model -->|"delegates lookup"| node_user_model
node_profile_model -->|"updates record"| node_database
node_user_model -->|"validates fields"| node_form
node_profile_model -->|"validates fields"| node_form
node_login_controller -->|"renders login"| node_app
node_profile_controller -->|"renders profile"| node_app
node_user_controller -->|"renders user views"| node_app
node_app -->|"renders template"| node_views
node_login_controller -->|"configures feedback"| node_feedback
node_profile_controller -->|"configures feedback"| node_feedback
node_user_controller -->|"configures feedback"| node_feedback
node_navigation -->|"reads user data"| node_user_model
node_browser -.->|"uses interface"| node_layout_js
node_web_server -.->|"connects database"| node_mysql
node_web_server -.->|"optional mail service"| node_docker_mailhog

click node_front "https://github.com/jonasbirkelof/beets-php/blob/master/src/index.php"
click node_routes "https://github.com/jonasbirkelof/beets-php/blob/master/src/routes/web.php"
click node_router "https://github.com/jonasbirkelof/beets-php/blob/master/src/App/Core/Router.php"
click node_app "https://github.com/jonasbirkelof/beets-php/blob/master/src/App/Core/App.php"
click node_database "https://github.com/jonasbirkelof/beets-php/blob/master/src/App/Core/Database.php"
click node_auth "https://github.com/jonasbirkelof/beets-php/blob/master/src/App/Core/Authenticate.php"
click node_login_controller "https://github.com/jonasbirkelof/beets-php/blob/master/src/App/Http/Controllers/Authenticate/LoginController.php"
click node_login_model "https://github.com/jonasbirkelof/beets-php/blob/master/src/App/Models/Authenticate/Login.php"
click node_roles "https://github.com/jonasbirkelof/beets-php/blob/master/src/App/Models/Authenticate/Role.php"
click node_permissions "https://github.com/jonasbirkelof/beets-php/blob/master/src/App/Models/Authenticate/Permission.php"
click node_profile_controller "https://github.com/jonasbirkelof/beets-php/blob/master/src/App/Http/Controllers/ProfileController.php"
click node_profile_model "https://github.com/jonasbirkelof/beets-php/blob/master/src/App/Models/Profile.php"
click node_user_controller "https://github.com/jonasbirkelof/beets-php/blob/master/src/App/Http/Controllers/UserController.php"
click node_user_model "https://github.com/jonasbirkelof/beets-php/blob/master/src/App/Models/User.php"
click node_form "https://github.com/jonasbirkelof/beets-php/blob/master/src/App/Core/Form.php"
click node_csrf "https://github.com/jonasbirkelof/beets-php/blob/master/src/App/Core/CSRF.php"
click node_feedback "https://github.com/jonasbirkelof/beets-php/blob/master/src/App/Http/Feedback.php"
click node_views "https://github.com/jonasbirkelof/beets-php/tree/master/src/public/views"
click node_navigation "https://github.com/jonasbirkelof/beets-php/blob/master/src/public/partials/navigation.php"
click node_layout_js "https://github.com/jonasbirkelof/beets-php/blob/master/src/resources/beets-layout-v1.1.0-src/js/beets-layout/beets-layout.js"

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_router,node_app,node_database,node_browser toneBlue
class node_auth,node_login_controller,node_login_model,node_roles,node_permissions toneAmber
class node_profile_controller,node_profile_model,node_user_controller,node_user_model,node_form,node_csrf toneMint
class node_feedback,node_views,node_navigation,node_layout_js toneRose
class node_web_server,node_mysql,node_docker_mailhog toneIndigo
```

## Components

### Request framework

- [Front controller](https://github.com/jonasbirkelof/beets-php/blob/master/src/index.php): `src/index.php`
- [REST route table](https://github.com/jonasbirkelof/beets-php/blob/master/src/routes/web.php): `src/routes/web.php`
- [Router](https://github.com/jonasbirkelof/beets-php/blob/master/src/App/Core/Router.php): `src/App/Core/Router.php`
- [View and errors](https://github.com/jonasbirkelof/beets-php/blob/master/src/App/Core/App.php): `src/App/Core/App.php`
- [PDO database](https://github.com/jonasbirkelof/beets-php/blob/master/src/App/Core/Database.php): `src/App/Core/Database.php`

### Identity and access

- [Authentication state](https://github.com/jonasbirkelof/beets-php/blob/master/src/App/Core/Authenticate.php): `src/App/Core/Authenticate.php`
- [Login actions](https://github.com/jonasbirkelof/beets-php/blob/master/src/App/Http/Controllers/Authenticate/LoginController.php): `src/App/Http/Controllers/Authenticate/LoginController.php`
- [Login and session](https://github.com/jonasbirkelof/beets-php/blob/master/src/App/Models/Authenticate/Login.php): `src/App/Models/Authenticate/Login.php`
- [Role and permissions](https://github.com/jonasbirkelof/beets-php/blob/master/src/App/Models/Authenticate/Role.php): `src/App/Models/Authenticate/Role.php`
- [Permission rules](https://github.com/jonasbirkelof/beets-php/blob/master/src/App/Models/Authenticate/Permission.php): `src/App/Models/Authenticate/Permission.php`

### Account administration

- [Profile actions](https://github.com/jonasbirkelof/beets-php/blob/master/src/App/Http/Controllers/ProfileController.php): `src/App/Http/Controllers/ProfileController.php`
- [Profile data](https://github.com/jonasbirkelof/beets-php/blob/master/src/App/Models/Profile.php): `src/App/Models/Profile.php`
- [User administration](https://github.com/jonasbirkelof/beets-php/blob/master/src/App/Http/Controllers/UserController.php): `src/App/Http/Controllers/UserController.php`
- [User records](https://github.com/jonasbirkelof/beets-php/blob/master/src/App/Models/User.php): `src/App/Models/User.php`
- [Form validation](https://github.com/jonasbirkelof/beets-php/blob/master/src/App/Core/Form.php): `src/App/Core/Form.php`
- [CSRF protection](https://github.com/jonasbirkelof/beets-php/blob/master/src/App/Core/CSRF.php): `src/App/Core/CSRF.php`

### Application interface

- [Session feedback](https://github.com/jonasbirkelof/beets-php/blob/master/src/App/Http/Feedback.php): `src/App/Http/Feedback.php`
- [Application views](https://github.com/jonasbirkelof/beets-php/tree/master/src/public/views): `src/public/views`
- [Navigation and sidebar](https://github.com/jonasbirkelof/beets-php/blob/master/src/public/partials/navigation.php): `src/public/partials/navigation.php`
- [Beets Layout UI](https://github.com/jonasbirkelof/beets-php/blob/master/src/resources/beets-layout-v1.1.0-src/js/beets-layout/beets-layout.js): `src/resources/beets-layout-v1.1.0-src/js/beets-layout/beets-layout.js`

### Runtime integrations

- **PHP web server**
- **MySQL database**
- **MailHog**

### Other components

- **Browser user**

## Connections

- Browser user → PHP web server: sends request
- PHP web server → Front controller: serves PHP
- Front controller → REST route table: loads routes (evidence: `src/index.php`)
- REST route table → Router: registers routes (evidence: `src/routes/web.php`)
- Router → Login actions: dispatches login (evidence: `src/routes/web.php`)
- Router → Profile actions: dispatches profile (evidence: `src/routes/web.php`)
- Router → User administration: dispatches users (evidence: `src/routes/web.php`)
- REST route table → Authentication state: checks access (evidence: `src/routes/web.php`)
- Login actions → Login and session: attempts login (evidence: `src/App/Http/Controllers/Authenticate/LoginController.php`)
- Login and session → Authentication state: sets identity (evidence: `src/App/Models/Authenticate/Login.php`)
- Login and session → PDO database: queries accounts (evidence: `src/App/Models/Authenticate/Login.php`)
- Login and session → Role and permissions: loads role (evidence: `src/App/Models/Authenticate/Login.php`)
- Role and permissions → Permission rules: loads permissions (evidence: `src/App/Models/Authenticate/Role.php`)
- Profile actions → Profile data: updates profile (evidence: `src/App/Http/Controllers/ProfileController.php`)
- Profile actions → User records: manages image (evidence: `src/App/Http/Controllers/ProfileController.php`)
- Profile actions → CSRF protection: validates token (evidence: `src/App/Http/Controllers/ProfileController.php`)
- User administration → User records: manages accounts (evidence: `src/App/Http/Controllers/UserController.php`)
- User administration → Role and permissions: loads role options (evidence: `src/App/Http/Controllers/UserController.php`)
- User administration → CSRF protection: validates token (evidence: `src/App/Http/Controllers/UserController.php`)
- User records → PDO database: queries records (evidence: `src/App/Models/User.php`)
- Profile data → User records: delegates lookup (evidence: `src/App/Models/Profile.php`)
- Profile data → PDO database: updates record (evidence: `src/App/Models/Profile.php`)
- User records → Form validation: validates fields (evidence: `src/App/Models/User.php`)
- Profile data → Form validation: validates fields (evidence: `src/App/Models/Profile.php`)
- Login actions → View and errors: renders login (evidence: `src/App/Http/Controllers/Authenticate/LoginController.php`)
- Profile actions → View and errors: renders profile (evidence: `src/App/Http/Controllers/ProfileController.php`)
- User administration → View and errors: renders user views (evidence: `src/App/Http/Controllers/UserController.php`)
- View and errors → Application views: renders template (evidence: `src/App/Core/App.php`)
- Login actions → Session feedback: configures feedback (evidence: `src/App/Http/Controllers/Authenticate/LoginController.php`)
- Profile actions → Session feedback: configures feedback (evidence: `src/App/Http/Controllers/ProfileController.php`)
- User administration → Session feedback: configures feedback (evidence: `src/App/Http/Controllers/UserController.php`)
- Navigation and sidebar → User records: reads user data (evidence: `src/public/partials/navigation.php`)
- Browser user → Beets Layout UI: uses interface
- PHP web server → MySQL database: connects database
- PHP web server → MailHog: optional mail service
