# rajeshmk/laravel-db-explorer architecture

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

- Interactive diagram: https://gitdiagram.com/rajeshmk/laravel-db-explorer
- Repository: https://github.com/rajeshmk/laravel-db-explorer

## Overview

1. **What this repo is**
   - This is a **Laravel package**, not a standalone app.
   - Its purpose is to mount a **database schema/data explorer** into a host Laravel application at a route like `/db-explorer`.

2. **Package bootstrap**
   - `src/DbExplorerServiceProvider.php` is the integration hub.
   - It likely registers the package’s **routes, config, views, migrations, commands, and frontend assets** into the host app.
   - The package is controlled by `config/db-explorer.php`.

3. **Access control boundary**
   - `src/Http/Middleware/EnsureDbExplorerIsAllowed.php` is the main security gate.
   - The README indicates it blocks access unless:
     - the explorer is enabled, and
     - the current environment is in the allowed list.
   - The route middleware stack is configurable, defaulting to `web` and `auth`.

4. **HTTP/API layer**
   - `routes/web.php` defines the public package routes.
   - `src/Http/Controllers/ExplorerController.php` is the main request handler.
   - The controller likely serves:
     - the dashboard/table list,
     - schema/table detail pages,
     - table browsing/search,
     - and optionally write actions when write mode is enabled.

5. **Database inspection layer**
   - `src/Inspectors/MySqlInspector.php` is the core metadata/data access component.
   - It is responsible for reading **tables, columns, indexes, foreign keys, and rows** from the database.
   - The name strongly suggests the package is currently **MySQL-focused** rather than database-agnostic.

6. **Presentation metadata layer**
   - `src/Models/ColumnPresentation.php` plus the migration in `database/migrations/...create_db_explorer_column_presentations_table.php` provide persistence for **per-column UI presentation settings**.
   - This is how the package can remember things like text, textarea, number, date/time, boolean, dropdown, foreign-key dropdown, or color picker presentation choices.

7. **Type-resolution helpers**
   - `src/Support/PresentationTypeResolver.php` converts column metadata into a UI control type.
   - `src/Support/EnumValueExtractor.php` suggests the package also derives selectable values from **PHP enums or enum-like column definitions**.
   - Together these helpers sit between schema inspection and frontend form rendering.

8. **Frontend application**
   - `resources/js/app.js` boots a Vue app defined in `resources/js/App.vue`.
   - The main screens are `resources/js/views/Dashboard.vue` and `resources/js/views/Explorer.vue`.
   - These views provide the interactive explorer experience: table browsing, metadata display, record grids, and editing controls.

9. **Blade shell and server-rendered wrappers**
   - `resources/views/layout.blade.php` is the main host layout.
   - `resources/views/schema.blade.php`, `table.blade.php`, `tables.blade.php`, and `pagination.blade.php` are server-rendered templates that wrap or complement the Vue-driven UI.
   - This suggests a **hybrid architecture**: Laravel renders the shell and page structure, while Vue powers richer in-page interactions.

10. **Compiled assets and build pipeline**
   - The distributable frontend lives in `resources/dist/db-explorer.css` and `resources/dist/db-explorer.iife.js`.
   - `vite.config.js` and `package.json` indicate the package is built with **Vite** and ships precompiled browser assets for installation into a host app.
   - The installer command and publish tags exist largely to copy these assets into the consuming project.

11. **Installation/update workflow**
   - `src/Console/Commands/InstallCommand.php` and `UpdateCommand.php` automate publishing assets/config/views/migrations.
   - This package is designed to be installed via Artisan commands as well as through normal Laravel vendor publishing.
   - If write mode is enabled, database migrations become part of the runtime requirements.

12. **Runtime data flow**
   - Browser request hits the Laravel route.
   - Middleware checks whether the explorer is allowed.
   - Controller delegates to the MySQL inspector and presentation helpers.
   - Results are passed to Blade/Vue to render schemas, tables, rows, and forms.
   - If write mode is enabled, user actions feed back through the controller into the database.

13. **Architectural boundary to note**
   - There is a clean split between:
     - **package infrastructure** (service provider, commands, config, middleware),
     - **schema/data access** (MySQL inspector, column presentation model),
     - **UI/rendering** (Vue + Blade + compiled assets).
   - That separation is what you would want to show on an architecture diagram.

14. **Operational posture**
   - The README emphasizes that the explorer is **disabled by default**, restricted by environment, and optional write support is off unless explicitly enabled.
   - This is a deliberately security-sensitive admin tool layered into an existing Laravel app rather than a general-purpose public UI.

Main entry points: [`src/Http/Controllers/ExplorerController.php`](https://github.com/rajeshmk/laravel-db-explorer/blob/main/src/Http/Controllers/ExplorerController.php) (Explorer controller), [`src/DbExplorerServiceProvider.php`](https://github.com/rajeshmk/laravel-db-explorer/blob/main/src/DbExplorerServiceProvider.php) (Service provider), [`vite.config.js`](https://github.com/rajeshmk/laravel-db-explorer/blob/main/vite.config.js) (Vite build), [`resources/js/views/Explorer.vue`](https://github.com/rajeshmk/laravel-db-explorer/blob/main/resources/js/views/Explorer.vue) (Explorer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_infra["Package infra"]
  node_node_service_provider["Service provider<br/>laravel bootstrap"]
  node_node_config["Config<br/>[db-explorer.php]"]
  node_node_install_command["Install cmd<br/>artisan command<br/>[InstallCommand.php]"]
  node_node_update_command["Update cmd<br/>artisan command<br/>[UpdateCommand.php]"]
end

subgraph group_group_http["HTTP access"]
  node_node_routes["Web routes<br/>route map<br/>[web.php]"]
  node_node_middleware["Allow gate<br/>access middleware"]
  node_node_controller["Explorer controller<br/>http controller"]
end

subgraph group_group_data["Data inspection"]
  node_node_inspector[("MySQL inspector<br/>db inspector<br/>[MySqlInspector.php]")]
  node_node_column_presentation["Column presentation<br/>persisted model"]
  node_node_migration["Presentation migration<br/>db migration"]
  node_node_type_resolver["Type resolver<br/>ui mapping helper"]
  node_node_enum_extractor["Enum extractor<br/>schema helper"]
end

subgraph group_group_ui["UI layer"]
  node_node_blade_layout["Layout shell<br/>blade layout<br/>[layout.blade.php]"]
  node_node_blade_tables["Tables view<br/>blade view<br/>[tables.blade.php]"]
  node_node_blade_schema["Schema view<br/>blade view<br/>[schema.blade.php]"]
  node_node_blade_table["Table view<br/>blade view<br/>[table.blade.php]"]
  node_node_blade_pagination["Pagination<br/>blade partial"]
  node_node_vue_app["Vue app<br/>frontend entry<br/>[app.js]"]
  node_node_vue_root["App shell<br/>vue root<br/>[App.vue]"]
  node_node_vue_dashboard["Dashboard<br/>vue view<br/>[Dashboard.vue]"]
  node_node_vue_explorer["Explorer<br/>vue view<br/>[Explorer.vue]"]
  node_node_css["Explorer CSS<br/>compiled asset<br/>[db-explorer.css]"]
  node_node_js_bundle["Explorer bundle<br/>compiled asset"]
end

subgraph group_group_build["Build pipeline"]
  node_node_vite["Vite build<br/>build config<br/>[vite.config.js]"]
  node_node_package_json["Package manifest<br/>npm manifest<br/>[package.json]"]
end

node_node_service_provider -->|"loads"| node_node_config
node_node_service_provider -->|"registers"| node_node_routes
node_node_service_provider -->|"binds"| node_node_middleware
node_node_service_provider -->|"wires"| node_node_controller
node_node_service_provider -->|"exposes"| node_node_install_command
node_node_service_provider -->|"exposes"| node_node_update_command
node_node_install_command -->|"publishes"| node_node_vite
node_node_update_command -->|"refreshes"| node_node_vite
node_node_routes -->|"protects"| node_node_middleware
node_node_routes -->|"dispatches"| node_node_controller
node_node_middleware -->|"checks"| node_node_config
node_node_controller -->|"reads"| node_node_inspector
node_node_controller -->|"loads"| node_node_column_presentation
node_node_controller -->|"maps"| node_node_type_resolver
node_node_controller -->|"derives"| node_node_enum_extractor
node_node_column_presentation -->|"stored by"| node_node_migration
node_node_type_resolver -->|"consults"| node_node_enum_extractor
node_node_controller -->|"renders"| node_node_blade_layout
node_node_blade_layout -->|"wraps"| node_node_blade_tables
node_node_blade_layout -->|"wraps"| node_node_blade_schema
node_node_blade_layout -->|"wraps"| node_node_blade_table
node_node_blade_tables -->|"includes"| node_node_blade_pagination
node_node_vue_app -->|"boots"| node_node_vue_root
node_node_vue_root -->|"navigates"| node_node_vue_dashboard
node_node_vue_root -->|"navigates"| node_node_vue_explorer
node_node_vue_explorer -->|"consumes"| node_node_inspector
node_node_vue_explorer -->|"applies"| node_node_column_presentation
node_node_vue_explorer -->|"renders"| node_node_type_resolver
node_node_vue_explorer -->|"offers"| node_node_enum_extractor
node_node_vue_app -->|"loads"| node_node_css
node_node_vue_app -->|"bundles"| node_node_js_bundle
node_node_vite -->|"builds"| node_node_vue_app
node_node_vite -->|"outputs"| node_node_css
node_node_vite -->|"outputs"| node_node_js_bundle
node_node_package_json -->|"scripts"| node_node_vite

click node_node_service_provider "https://github.com/rajeshmk/laravel-db-explorer/blob/main/src/DbExplorerServiceProvider.php"
click node_node_config "https://github.com/rajeshmk/laravel-db-explorer/blob/main/config/db-explorer.php"
click node_node_install_command "https://github.com/rajeshmk/laravel-db-explorer/blob/main/src/Console/Commands/InstallCommand.php"
click node_node_update_command "https://github.com/rajeshmk/laravel-db-explorer/blob/main/src/Console/Commands/UpdateCommand.php"
click node_node_routes "https://github.com/rajeshmk/laravel-db-explorer/blob/main/routes/web.php"
click node_node_middleware "https://github.com/rajeshmk/laravel-db-explorer/blob/main/src/Http/Middleware/EnsureDbExplorerIsAllowed.php"
click node_node_controller "https://github.com/rajeshmk/laravel-db-explorer/blob/main/src/Http/Controllers/ExplorerController.php"
click node_node_inspector "https://github.com/rajeshmk/laravel-db-explorer/blob/main/src/Inspectors/MySqlInspector.php"
click node_node_column_presentation "https://github.com/rajeshmk/laravel-db-explorer/blob/main/src/Models/ColumnPresentation.php"
click node_node_migration "https://github.com/rajeshmk/laravel-db-explorer/blob/main/database/migrations/2026_02_12_000001_create_db_explorer_column_presentations_table.php"
click node_node_type_resolver "https://github.com/rajeshmk/laravel-db-explorer/blob/main/src/Support/PresentationTypeResolver.php"
click node_node_enum_extractor "https://github.com/rajeshmk/laravel-db-explorer/blob/main/src/Support/EnumValueExtractor.php"
click node_node_blade_layout "https://github.com/rajeshmk/laravel-db-explorer/blob/main/resources/views/layout.blade.php"
click node_node_blade_tables "https://github.com/rajeshmk/laravel-db-explorer/blob/main/resources/views/tables.blade.php"
click node_node_blade_schema "https://github.com/rajeshmk/laravel-db-explorer/blob/main/resources/views/schema.blade.php"
click node_node_blade_table "https://github.com/rajeshmk/laravel-db-explorer/blob/main/resources/views/table.blade.php"
click node_node_blade_pagination "https://github.com/rajeshmk/laravel-db-explorer/blob/main/resources/views/pagination.blade.php"
click node_node_vue_app "https://github.com/rajeshmk/laravel-db-explorer/blob/main/resources/js/app.js"
click node_node_vue_root "https://github.com/rajeshmk/laravel-db-explorer/blob/main/resources/js/App.vue"
click node_node_vue_dashboard "https://github.com/rajeshmk/laravel-db-explorer/blob/main/resources/js/views/Dashboard.vue"
click node_node_vue_explorer "https://github.com/rajeshmk/laravel-db-explorer/blob/main/resources/js/views/Explorer.vue"
click node_node_css "https://github.com/rajeshmk/laravel-db-explorer/blob/main/resources/dist/db-explorer.css"
click node_node_js_bundle "https://github.com/rajeshmk/laravel-db-explorer/blob/main/resources/dist/db-explorer.iife.js"
click node_node_vite "https://github.com/rajeshmk/laravel-db-explorer/blob/main/vite.config.js"
click node_node_package_json "https://github.com/rajeshmk/laravel-db-explorer/blob/main/package.json"

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_node_service_provider,node_node_config,node_node_install_command,node_node_update_command toneBlue
class node_node_routes,node_node_middleware,node_node_controller toneAmber
class node_node_inspector,node_node_column_presentation,node_node_migration,node_node_type_resolver,node_node_enum_extractor toneMint
class node_node_blade_layout,node_node_blade_tables,node_node_blade_schema,node_node_blade_table,node_node_blade_pagination,node_node_vue_app,node_node_vue_root,node_node_vue_dashboard,node_node_vue_explorer,node_node_css,node_node_js_bundle toneRose
class node_node_vite,node_node_package_json toneIndigo
```

## Components

### Package infra

Laravel package bootstrap, config, and install/update workflow.

- [Service provider](https://github.com/rajeshmk/laravel-db-explorer/blob/main/src/DbExplorerServiceProvider.php): laravel bootstrap · Registers the package into the host Laravel app. · `src/DbExplorerServiceProvider.php`
- [Config](https://github.com/rajeshmk/laravel-db-explorer/blob/main/config/db-explorer.php): package config · Feature flags, route/middleware settings, and explorer behavior. · `config/db-explorer.php`
- [Install cmd](https://github.com/rajeshmk/laravel-db-explorer/blob/main/src/Console/Commands/InstallCommand.php): artisan command · Publishes package resources for first-time setup. · `src/Console/Commands/InstallCommand.php`
- [Update cmd](https://github.com/rajeshmk/laravel-db-explorer/blob/main/src/Console/Commands/UpdateCommand.php): artisan command · Republishes or refreshes package assets and resources. · `src/Console/Commands/UpdateCommand.php`

### HTTP access

Route entrypoints, middleware, and controller boundary.

- [Web routes](https://github.com/rajeshmk/laravel-db-explorer/blob/main/routes/web.php): route map · Public package routes mounted into the host app. · `routes/web.php`
- [Allow gate](https://github.com/rajeshmk/laravel-db-explorer/blob/main/src/Http/Middleware/EnsureDbExplorerIsAllowed.php): access middleware · Blocks the explorer unless it is enabled and the environment is allowed. · `src/Http/Middleware/EnsureDbExplorerIsAllowed.php`
- [Explorer controller](https://github.com/rajeshmk/laravel-db-explorer/blob/main/src/Http/Controllers/ExplorerController.php): http controller · Handles dashboard, schema, table browsing, and write actions. · `src/Http/Controllers/ExplorerController.php`

### Data inspection

Database metadata and persisted presentation settings.

- [MySQL inspector](https://github.com/rajeshmk/laravel-db-explorer/blob/main/src/Inspectors/MySqlInspector.php): db inspector · Reads tables, columns, indexes, foreign keys, and rows from MySQL. · `src/Inspectors/MySqlInspector.php`
- [Column presentation](https://github.com/rajeshmk/laravel-db-explorer/blob/main/src/Models/ColumnPresentation.php): persisted model · Stores per-column UI presentation preferences. · `src/Models/ColumnPresentation.php`
- [Presentation migration](https://github.com/rajeshmk/laravel-db-explorer/blob/main/database/migrations/2026_02_12_000001_create_db_explorer_column_presentations_table.php): db migration · Creates the storage table for column presentation settings. · `database/migrations/2026_02_12_000001_create_db_explorer_column_presentations_table.php`
- [Type resolver](https://github.com/rajeshmk/laravel-db-explorer/blob/main/src/Support/PresentationTypeResolver.php): ui mapping helper · Maps schema metadata to a form control type. · `src/Support/PresentationTypeResolver.php`
- [Enum extractor](https://github.com/rajeshmk/laravel-db-explorer/blob/main/src/Support/EnumValueExtractor.php): schema helper · Derives selectable values from PHP enums or enum-like definitions. · `src/Support/EnumValueExtractor.php`

### UI layer

Blade wrappers, Vue app, and compiled frontend assets.

- [Layout shell](https://github.com/rajeshmk/laravel-db-explorer/blob/main/resources/views/layout.blade.php): blade layout · Main server-rendered wrapper for the explorer. · `resources/views/layout.blade.php`
- [Tables view](https://github.com/rajeshmk/laravel-db-explorer/blob/main/resources/views/tables.blade.php): blade view · Server-rendered table and schema wrappers. · `resources/views/tables.blade.php`
- [Schema view](https://github.com/rajeshmk/laravel-db-explorer/blob/main/resources/views/schema.blade.php): blade view · Server-rendered schema page wrapper. · `resources/views/schema.blade.php`
- [Table view](https://github.com/rajeshmk/laravel-db-explorer/blob/main/resources/views/table.blade.php): blade view · Server-rendered table detail wrapper. · `resources/views/table.blade.php`
- [Pagination](https://github.com/rajeshmk/laravel-db-explorer/blob/main/resources/views/pagination.blade.php): blade partial · Pagination fragment used by the server-rendered tables. · `resources/views/pagination.blade.php`
- [Vue app](https://github.com/rajeshmk/laravel-db-explorer/blob/main/resources/js/app.js): frontend entry · Boots the interactive explorer application. · `resources/js/app.js`
- [App shell](https://github.com/rajeshmk/laravel-db-explorer/blob/main/resources/js/App.vue): vue root · Top-level Vue component for the explorer UI. · `resources/js/App.vue`
- [Dashboard](https://github.com/rajeshmk/laravel-db-explorer/blob/main/resources/js/views/Dashboard.vue): vue view · Overview screen for databases, schemas, or tables. · `resources/js/views/Dashboard.vue`
- [Explorer](https://github.com/rajeshmk/laravel-db-explorer/blob/main/resources/js/views/Explorer.vue): vue view · Interactive table browsing and editing screen. · `resources/js/views/Explorer.vue`
- [Explorer CSS](https://github.com/rajeshmk/laravel-db-explorer/blob/main/resources/dist/db-explorer.css): compiled asset · Distributed stylesheet for the packaged UI. · `resources/dist/db-explorer.css`
- [Explorer bundle](https://github.com/rajeshmk/laravel-db-explorer/blob/main/resources/dist/db-explorer.iife.js): compiled asset · Distributed browser bundle for the packaged UI. · `resources/dist/db-explorer.iife.js`

### Build pipeline

Frontend build and package metadata.

- [Vite build](https://github.com/rajeshmk/laravel-db-explorer/blob/main/vite.config.js): build config · Build configuration for the distributable frontend assets. · `vite.config.js`
- [Package manifest](https://github.com/rajeshmk/laravel-db-explorer/blob/main/package.json): npm manifest · Frontend package metadata and scripts. · `package.json`

## Connections

- Service provider → Config: loads · Service provider consumes package configuration.
- Service provider → Web routes: registers · Publishes the package route entrypoints.
- Service provider → Allow gate: binds · Makes the access gate available to route middleware.
- Service provider → Explorer controller: wires · Registers the HTTP controller into the package stack.
- Service provider → Install cmd: exposes · Registers install automation commands.
- Service provider → Update cmd: exposes · Registers update automation commands.
- Install cmd → Vite build: publishes · Uses build/package metadata when publishing assets.
- Update cmd → Vite build: refreshes · Relies on the build output and publish flow.
- Web routes → Allow gate: protects · Routes apply the allow-list middleware.
- Web routes → Explorer controller: dispatches · HTTP requests are routed to the explorer controller.
- Allow gate → Config: checks · Reads enablement and environment rules from config.
- Explorer controller → MySQL inspector: reads · Controller delegates schema and row access to the inspector.
- Explorer controller → Column presentation: loads · Reads saved presentation preferences for columns.
- Explorer controller → Type resolver: maps · Converts column metadata into UI control types.
- Explorer controller → Enum extractor: derives · Extracts selectable values for editor controls.
- Column presentation → Presentation migration: stored by · Migration creates the backing table for presentation settings.
- Type resolver → Enum extractor: consults · Type resolution may use enum-derived values.
- Explorer controller → Layout shell: renders · Server-side shell for the explorer pages.
- Layout shell → Tables view: wraps · Layout hosts table-oriented views.
- Layout shell → Schema view: wraps · Layout hosts schema views.
- Layout shell → Table view: wraps · Layout hosts table detail views.
- Tables view → Pagination: includes · Tables view uses pagination partials.
- Vue app → App shell: boots · Entry file initializes the main Vue component.
- App shell → Dashboard: navigates · Root app contains or routes to the dashboard view.
- App shell → Explorer: navigates · Root app contains or routes to the explorer view.
- Explorer → MySQL inspector: consumes · Interactive UI depends on database metadata and rows.
- Explorer → Column presentation: applies · Uses saved presentation settings to render editors.
- Explorer → Type resolver: renders · Uses type mapping to choose controls.
- Explorer → Enum extractor: offers · Populates selectable controls from extracted values.
- Vue app → Explorer CSS: loads · Frontend entry is styled by the distributed CSS.
- Vue app → Explorer bundle: bundles · Entry contributes to the shipped browser bundle.
- Vite build → Vue app: builds · Vite compiles the Vue application.
- Vite build → Explorer CSS: outputs · Build produces the distributed stylesheet.
- Vite build → Explorer bundle: outputs · Build produces the distributable JS bundle.
- Package manifest → Vite build: scripts · Package scripts drive the Vite build.
