# z-song/laravel-admin architecture

> Architecture diagram of the GitHub repository z-song/laravel-admin, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/z-song/laravel-admin
- Repository: https://github.com/z-song/laravel-admin

## Overview

#### Purpose and Runtime
`laravel-admin` is a Composer package for Laravel (PHP 7+, Laravel 5.5+) that supplies a configurable, server-rendered administrative CRUD interface. It is installed into a host Laravel application, rather than run as a standalone app. Core package bootstrap and public API are in `src/AdminServiceProvider.php`, `src/Admin.php`, and `src/Facades/Admin.php`.

#### Bootstrap, Installation, and Entry Points
The service provider publishes configuration/assets and integrates package behavior with Laravel’s container, routing, views, middleware, and Artisan. Installation and scaffolding enter through package commands, principally `src/Console/InstallCommand.php` and `src/Console/AdminCommand.php`. Host applications configure mount path, database connection/table names, and behavior through `config/admin.php`; installation creates package-owned tables through `database/migrations/2016_01_04_173148_create_admin_tables.php`.

#### Request Pipeline and Admin Boundary
Admin requests pass through package middleware for session setup, authentication, permissions, PJAX behavior, and audit logging: `src/Middleware/Bootstrap.php`, `src/Middleware/Authenticate.php`, and `src/Middleware/Permission.php`. This separates the protected admin surface from application routes. Controllers implement dashboard, login, administrative identity/authorization management, and generic resource endpoints: `src/Controllers/Dashboard.php`, `src/Controllers/AuthController.php`, and `src/Controllers/HasResourceActions.php`. `src/Middleware/LogOperation.php` records privileged operations.

#### Identity, Authorization, Navigation, and Audit Data
The package persists its own administrator, role, permission, menu, and operation-log domain in Eloquent-style models: `src/Auth/Database/Administrator.php`, `src/Auth/Database/Role.php`, and `src/Auth/Database/Menu.php`. Permission assignment/checking is encapsulated by `src/Auth/Permission.php` and `src/Auth/Database/HasPermissions.php`. The menu model provides navigation structure; operation logs are persisted through `src/Auth/Database/OperationLog.php`.

#### CRUD UI Builders
Application developers define back-office resources through fluent PHP builders rather than manually authoring CRUD pages. `src/Grid.php` produces paginated/filterable tabular listings over models; query filtering, columns, inline editing, actions, and exports are organized under `src/Grid/Filter.php`, `src/Grid/Column.php`, and `src/Grid/Exporter.php`. `src/Form.php` and `src/Form/Builder.php` construct create/update workflows, including relational and upload fields. `src/Show.php` handles read-only detail views, while `src/Tree.php` supports hierarchical model management.

#### Rendering and Browser Interaction
Builder objects render Blade templates into the AdminLTE/Bootstrap shell. Primary view boundaries are `resources/views/index.blade.php`, `resources/views/grid/table.blade.php`, and `resources/views/form.blade.php`. Packaged browser dependencies and package scripts/styles reside in `resources/assets/AdminLTE`, `resources/assets/laravel-admin/laravel-admin.js`, and `resources/assets/laravel-admin/laravel-admin.css`. The UI uses jQuery/PJAX and bundled controls for partial navigation and interactive grids/forms; map form capabilities connect to Google Maps or Tencent Maps when selected.

#### Extensibility and Actions
Extensions integrate through the package extension abstraction in `src/Extension.php`; generated extension skeletons are provided under `src/Console/stubs/extension`. Reusable page layout and widgets are built via `src/Layout/Content.php`, `src/Widgets/Widget.php`, and related Blade templates. Grid/row/batch actions use a common action-response layer (`src/Actions/Action.php`, `src/Actions/RowAction.php`, `src/Actions/Response.php`) to return UI effects such as dialogs and toast notifications.

Main entry points: [`src/Admin.php`](https://github.com/z-song/laravel-admin/blob/master/src/Admin.php) (Admin facade and API), [`resources/views/index.blade.php`](https://github.com/z-song/laravel-admin/blob/master/resources/views/index.blade.php) (Blade admin views), [`src/AdminServiceProvider.php`](https://github.com/z-song/laravel-admin/blob/master/src/AdminServiceProvider.php) (Admin service provider), [`src/Middleware/Bootstrap.php`](https://github.com/z-song/laravel-admin/blob/master/src/Middleware/Bootstrap.php) (Admin middleware)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_host["Host Laravel app"]
  node_host_app{{"Laravel application<br/>host runtime"}}
  node_admin_config["Admin configuration<br/>package config<br/>[admin.php]"]
end

subgraph group_runtime["Package runtime"]
  node_service_provider["Admin service provider<br/>Laravel provider"]
  node_admin_api["Admin facade and API<br/>public API<br/>[Admin.php]"]
  node_admin_routes["Protected admin routes<br/>route surface"]
  node_admin_middleware["Admin middleware<br/>middleware pipeline<br/>[Bootstrap.php]"]
  node_admin_controllers["Admin controllers<br/>controller layer"]
  node_audit_middleware["Operation audit middleware<br/>[LogOperation.php]"]
end

subgraph group_domain["Admin domain"]
  node_admin_models[("Admin identity models<br/>Eloquent models<br/>[Administrator.php]")]
  node_permission_service["Permission checks<br/>authorization service<br/>[Permission.php]"]
  node_admin_schema[("Admin tables<br/>database schema")]
end

subgraph group_ui["Builders and UI"]
  node_grid_builder["Grid builder<br/>CRUD builder<br/>[Grid.php]"]
  node_form_builder["Form builder<br/>CRUD builder<br/>[Form.php]"]
  node_detail_tree_builders["Show and tree builders<br/>CRUD builders<br/>[Show.php]"]
  node_action_response["Action response layer<br/>UI actions<br/>[Action.php]"]
  node_layout_widgets["Layouts and widgets<br/>presentation API<br/>[Content.php]"]
  node_blade_views["Blade admin views<br/>server-rendered views<br/>[index.blade.php]"]
  node_browser_assets["Browser assets<br/>JS/CSS bundle<br/>[laravel-admin.js]"]
end

subgraph group_tooling["Installation and extensions"]
  node_install_commands["Install and scaffold commands<br/>Artisan commands<br/>[InstallCommand.php]"]
  node_extension_api["Extension API<br/>extension framework<br/>[Extension.php]"]
end

node_host_app -->|"boots"| node_service_provider
node_admin_config -->|"configures"| node_service_provider
node_service_provider -->|"registers"| node_admin_routes
node_service_provider -->|"exposes"| node_admin_api
node_admin_routes -->|"passes through"| node_admin_middleware
node_admin_middleware -->|"authorizes with"| node_permission_service
node_permission_service -->|"evaluates"| node_admin_models
node_admin_middleware -->|"dispatches to"| node_admin_controllers
node_admin_controllers -.->|"audited by"| node_audit_middleware
node_audit_middleware -->|"writes operation logs"| node_admin_models
node_admin_models -->|"persists in"| node_admin_schema
node_admin_api -->|"creates"| node_grid_builder
node_admin_api -->|"creates"| node_form_builder
node_admin_api -->|"creates"| node_detail_tree_builders
node_grid_builder -->|"uses actions"| node_action_response
node_grid_builder -->|"renders"| node_blade_views
node_form_builder -->|"renders"| node_blade_views
node_detail_tree_builders -->|"renders"| node_blade_views
node_layout_widgets -->|"composes"| node_blade_views
node_blade_views -->|"loads"| node_browser_assets
node_install_commands -->|"installs"| node_admin_schema
node_extension_api -->|"extends"| node_admin_api

click node_admin_config "https://github.com/z-song/laravel-admin/blob/master/config/admin.php"
click node_service_provider "https://github.com/z-song/laravel-admin/blob/master/src/AdminServiceProvider.php"
click node_admin_api "https://github.com/z-song/laravel-admin/blob/master/src/Admin.php"
click node_admin_middleware "https://github.com/z-song/laravel-admin/blob/master/src/Middleware/Bootstrap.php"
click node_admin_controllers "https://github.com/z-song/laravel-admin/blob/master/src/Controllers/HasResourceActions.php"
click node_audit_middleware "https://github.com/z-song/laravel-admin/blob/master/src/Middleware/LogOperation.php"
click node_admin_models "https://github.com/z-song/laravel-admin/blob/master/src/Auth/Database/Administrator.php"
click node_permission_service "https://github.com/z-song/laravel-admin/blob/master/src/Auth/Permission.php"
click node_admin_schema "https://github.com/z-song/laravel-admin/blob/master/database/migrations/2016_01_04_173148_create_admin_tables.php"
click node_grid_builder "https://github.com/z-song/laravel-admin/blob/master/src/Grid.php"
click node_form_builder "https://github.com/z-song/laravel-admin/blob/master/src/Form.php"
click node_detail_tree_builders "https://github.com/z-song/laravel-admin/blob/master/src/Show.php"
click node_action_response "https://github.com/z-song/laravel-admin/blob/master/src/Actions/Action.php"
click node_layout_widgets "https://github.com/z-song/laravel-admin/blob/master/src/Layout/Content.php"
click node_blade_views "https://github.com/z-song/laravel-admin/blob/master/resources/views/index.blade.php"
click node_browser_assets "https://github.com/z-song/laravel-admin/blob/master/resources/assets/laravel-admin/laravel-admin.js"
click node_install_commands "https://github.com/z-song/laravel-admin/blob/master/src/Console/InstallCommand.php"
click node_extension_api "https://github.com/z-song/laravel-admin/blob/master/src/Extension.php"

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_host_app,node_admin_config toneBlue
class node_service_provider,node_admin_api,node_admin_routes,node_admin_middleware,node_admin_controllers,node_audit_middleware toneAmber
class node_admin_models,node_permission_service,node_admin_schema toneMint
class node_grid_builder,node_form_builder,node_detail_tree_builders,node_action_response,node_layout_widgets,node_blade_views,node_browser_assets toneRose
class node_install_commands,node_extension_api toneIndigo
```

## Components

### Host Laravel app

The package is installed and configured by a Laravel application.

- **Laravel application**: host runtime · Supplies the container, routes, database, and application models.
- [Admin configuration](https://github.com/z-song/laravel-admin/blob/master/config/admin.php): package config · Defines mount path, storage names, and package behavior. · `config/admin.php`

### Package runtime

- [Admin service provider](https://github.com/z-song/laravel-admin/blob/master/src/AdminServiceProvider.php): Laravel provider · Publishes assets and wires package services into Laravel. · `src/AdminServiceProvider.php`
- [Admin facade and API](https://github.com/z-song/laravel-admin/blob/master/src/Admin.php): public API · Primary package API used by applications and builders. · `src/Admin.php`
- **Protected admin routes**: route surface · Mounted administrative request boundary.
- [Admin middleware](https://github.com/z-song/laravel-admin/blob/master/src/Middleware/Bootstrap.php): middleware pipeline · Bootstraps session/PJAX and enforces authentication and permissions. · `src/Middleware/Bootstrap.php`
- [Admin controllers](https://github.com/z-song/laravel-admin/blob/master/src/Controllers/HasResourceActions.php): controller layer · Handles dashboard, login, identity management, and resource endpoints. · `src/Controllers/HasResourceActions.php`
- [Operation audit middleware](https://github.com/z-song/laravel-admin/blob/master/src/Middleware/LogOperation.php): audit middleware · Records privileged admin operations. · `src/Middleware/LogOperation.php`

### Admin domain

- [Admin identity models](https://github.com/z-song/laravel-admin/blob/master/src/Auth/Database/Administrator.php): Eloquent models · Administrators, roles, permissions, menus, and logs. · `src/Auth/Database/Administrator.php`
- [Permission checks](https://github.com/z-song/laravel-admin/blob/master/src/Auth/Permission.php): authorization service · Encapsulates assignment and authorization evaluation. · `src/Auth/Permission.php`
- [Admin tables](https://github.com/z-song/laravel-admin/blob/master/database/migrations/2016_01_04_173148_create_admin_tables.php): database schema · Package-owned persistence schema. · `database/migrations/2016_01_04_173148_create_admin_tables.php`

### Builders and UI

- [Grid builder](https://github.com/z-song/laravel-admin/blob/master/src/Grid.php): CRUD builder · Builds listings, filters, columns, actions, and exports. · `src/Grid.php`
- [Form builder](https://github.com/z-song/laravel-admin/blob/master/src/Form.php): CRUD builder · Builds create/update and relational/upload workflows. · `src/Form.php`
- [Show and tree builders](https://github.com/z-song/laravel-admin/blob/master/src/Show.php): CRUD builders · Provide detail and hierarchical resource management views. · `src/Show.php`
- [Action response layer](https://github.com/z-song/laravel-admin/blob/master/src/Actions/Action.php): UI actions · Grid, row, and batch actions return dialogs and notifications. · `src/Actions/Action.php`
- [Layouts and widgets](https://github.com/z-song/laravel-admin/blob/master/src/Layout/Content.php): presentation API · Reusable content layout and widget composition. · `src/Layout/Content.php`
- [Blade admin views](https://github.com/z-song/laravel-admin/blob/master/resources/views/index.blade.php): server-rendered views · Render builders within the AdminLTE shell. · `resources/views/index.blade.php`
- [Browser assets](https://github.com/z-song/laravel-admin/blob/master/resources/assets/laravel-admin/laravel-admin.js): JS/CSS bundle · AdminLTE, jQuery/PJAX, and interactive controls. · `resources/assets/laravel-admin/laravel-admin.js`

### Installation and extensions

- [Install and scaffold commands](https://github.com/z-song/laravel-admin/blob/master/src/Console/InstallCommand.php): Artisan commands · Installs package resources and generates admin scaffolding. · `src/Console/InstallCommand.php`
- [Extension API](https://github.com/z-song/laravel-admin/blob/master/src/Extension.php): extension framework · Provides extension integration and generated skeletons. · `src/Extension.php`

## Connections

- Laravel application → Admin service provider: boots
- Admin configuration → Admin service provider: configures
- Admin service provider → Protected admin routes: registers
- Admin service provider → Admin facade and API: exposes
- Protected admin routes → Admin middleware: passes through
- Admin middleware → Permission checks: authorizes with
- Permission checks → Admin identity models: evaluates
- Admin middleware → Admin controllers: dispatches to
- Admin controllers → Operation audit middleware: audited by
- Operation audit middleware → Admin identity models: writes operation logs
- Admin identity models → Admin tables: persists in
- Admin facade and API → Grid builder: creates
- Admin facade and API → Form builder: creates
- Admin facade and API → Show and tree builders: creates
- Grid builder → Action response layer: uses actions
- Grid builder → Blade admin views: renders
- Form builder → Blade admin views: renders
- Show and tree builders → Blade admin views: renders
- Layouts and widgets → Blade admin views: composes
- Blade admin views → Browser assets: loads
- Install and scaffold commands → Admin tables: installs
- Extension API → Admin facade and API: extends
