# beikeshop/beikeshop architecture

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

- Interactive diagram: https://gitdiagram.com/beikeshop/beikeshop
- Repository: https://github.com/beikeshop/beikeshop

## Overview

#### Purpose and Runtime
BeikeShop is a self-hosted, modular ecommerce platform: storefront, admin back office, REST APIs, installation, and extensibility for payment, shipping, and integrations. It runs on PHP 8.2+ / Laravel 12 with Blade, Vue.js, Sass, and Bootstrap. Primary HTTP entry is `public/index.php`; application bootstrap is `bootstrap/app.php`; CLI entry is `artisan`.

#### HTTP Composition and Boundaries
Laravel’s HTTP kernel applies global middleware for cookies, sessions, CSRF, maintenance, locale, currency, and authentication. Separate route surfaces isolate shopper, administrator, administrator API, installer, and generic application routes:
- `app/Http/Kernel.php`
- `beike/Shop/Routes/shop.php`
- `beike/Admin/Routes/admin.php`
- `beike/AdminAPI/Routes/api.php`
- `beike/Installer/Routes/installer.php`

Shop, admin, and API authentication are distinct middleware boundaries, notably `app/Http/Middleware/ShopAuthenticate.php`, `app/Http/Middleware/AdminApiAuthenticate.php`, and `app/Http/Middleware/CheckoutAuthenticate.php`.

#### Storefront Commerce Flow
Shop controllers accept browser requests, validate inputs, and delegate business work to services. Catalog browsing resolves products/categories; cart state is persisted through repositories/models; checkout computes totals, selects payment/shipping methods, then produces orders. Key implementation points:
- `beike/Shop/Http/Controllers/CheckoutController.php`
- `beike/Shop/Services/CheckoutService.php`
- `beike/Shop/Services/CartService.php`
- `beike/Shop/Services/TotalServices/OrderTotalService.php`
- `beike/Models/Order.php`

Storefront rendering uses theme templates under `themes/default`, while shop assets and default-theme source assets reside in `resources/beike/shop/default`.

#### Administration and Operational APIs
The admin module manages catalog, customers, orders, tax, design, translations, plugins, reports, and settings through server-rendered controllers/services/repositories. Its public API counterpart exposes management endpoints separately from the HTML admin application.
- `beike/Admin/Http/Controllers/ProductController.php`
- `beike/Admin/Services/ProductService.php`
- `beike/Admin/Repositories/DashboardRepo.php`
- `beike/AdminAPI/Controllers/OrderController.php`

Admin views are under `resources/beike/admin/views`; admin services use shared domain models/repositories rather than a separate data store.

#### Shared Domain and Persistence
`beike/Models` is the central Eloquent domain layer for products, SKUs, categories, carts, customers, orders, payments, shipments, taxes, settings, plugins, and RMAs. Repository classes encapsulate common domain access, while migrations define the relational schema and seeders supply initial store data.
- `beike/Models/Product.php`
- `beike/Models/Cart.php`
- `beike/Repositories/OrderRepo.php`
- `database/migrations/2021_12_26_111435_create_tables.php`

Configured database targets are MySQL or PostgreSQL; Laravel cache, sessions, queues, logs, filesystem storage, mail, and Horizon are configured through `config/`.

#### Extensibility, Themes, and Events
Plugins are filesystem modules registered through bootstrap classes and metadata, with optional routes, migrations, views, assets, and columns. The plugin manager and Hook subsystem form the non-invasive extension boundary; payment/shipping plugins integrate into checkout service selection.
- `beike/Plugin/Manager.php`
- `beike/Hook/Hook.php`
- `plugins/Paypal/Bootstrap.php`
- `plugins/Stripe/Services/StripeService.php`

Themes are independently stored under `themes/`; design builders support configurable storefront modules via `beike/Services/DesignService.php` and `beike/Admin/View/DesignBuilders`.

#### Background Work, Installation, and Infrastructure
Console commands cover installation, order processing, sitemap generation, currency-rate fetches, migrations, and module management. Installation is a web wizard or `beikeshop:install` command. Docker deployment supports Nginx or Apache profiles; production needs a PHP web server plus database, with queue workers/Horizon when asynchronous work is enabled.
- `beike/Console/Commands/BeikeShopInstall.php`
- `beike/Console/Commands/ProcessOrder.php`
- `beike/Installer/Controllers/DatabaseController.php`
- `docker-compose.yml`

External service adapters present in-tree include PayPal, Stripe, Wintopay, SendCloud, SendGrid, Youdao translation, and UniPush.

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Laravel Runtime"]
  node_http_entry["HTTP entry<br/>PHP front controller<br/>[index.php]"]
  node_laravel_bootstrap["Application bootstrap<br/>Laravel bootstrap<br/>[app.php]"]
  node_http_kernel["HTTP middleware kernel<br/>Laravel HTTP kernel<br/>[Kernel.php]"]
end

subgraph group_shop["Storefront Commerce"]
  node_shop_routes["Shop routes<br/>route surface<br/>[shop.php]"]
  node_shop_auth["Shop auth<br/>shop middleware"]
  node_checkout["Checkout controller &amp; service<br/>commerce orchestration"]
  node_cart_service["Cart service<br/>commerce service<br/>[CartService.php]"]
  node_order_totals["Order totals<br/>total calculator"]
  node_storefront_theme["Storefront themes<br/>Blade theme templates"]
end

subgraph group_admin["Administration"]
  node_admin_routes["Admin routes<br/>route surface<br/>[admin.php]"]
  node_admin_application["Admin product management<br/>controllers and services<br/>[ProductService.php]"]
  node_admin_api["Admin API<br/>management API"]
end

subgraph group_domain["Domain &amp; Persistence"]
  node_domain_models["Eloquent domain models<br/>shared domain layer"]
  node_order_repository["Order repository<br/>domain repository<br/>[OrderRepo.php]"]
  node_relational_database[("MySQL / PostgreSQL<br/>relational database")]
end

subgraph group_extensions["Extensions &amp; Operations"]
  node_plugin_hook_system{{"Plugin manager &amp; hooks<br/>extension boundary<br/>[Manager.php]"}}
  node_payment_shipping_plugins{{"Payment &amp; shipping plugins<br/>checkout adapters<br/>[Bootstrap.php]"}}
  node_installer["Installer<br/>web installation wizard"]
  node_console_commands["Console commands<br/>Artisan operations<br/>[ProcessOrder.php]"]
  node_deployment["Docker deployment<br/>runtime infrastructure<br/>[docker-compose.yml]"]
end

node_http_entry -->|"boots"| node_laravel_bootstrap
node_laravel_bootstrap -->|"creates"| node_http_kernel
node_http_kernel -->|"dispatches"| node_shop_routes
node_http_kernel -->|"dispatches"| node_admin_routes
node_http_kernel -->|"dispatches"| node_admin_api
node_shop_routes -->|"protects routes"| node_shop_auth
node_shop_auth -->|"authorizes"| node_checkout
node_checkout -->|"uses cart"| node_cart_service
node_checkout -->|"calculates totals"| node_order_totals
node_checkout -->|"creates orders"| node_order_repository
node_checkout -->|"selects adapters"| node_payment_shipping_plugins
node_shop_routes -->|"renders"| node_storefront_theme
node_cart_service -->|"persists cart"| node_domain_models
node_order_repository -->|"accesses"| node_domain_models
node_domain_models -->|"maps to"| node_relational_database
node_admin_routes -->|"serves"| node_admin_application
node_admin_application -->|"manages"| node_domain_models
node_admin_api -->|"manages"| node_domain_models
node_plugin_hook_system -->|"registers"| node_payment_shipping_plugins
node_plugin_hook_system -.->|"extends"| node_checkout
node_installer -->|"initializes"| node_relational_database
node_console_commands -->|"processes"| node_domain_models
node_deployment -->|"serves"| node_http_entry

click node_http_entry "https://github.com/beikeshop/beikeshop/blob/master/public/index.php"
click node_laravel_bootstrap "https://github.com/beikeshop/beikeshop/blob/master/bootstrap/app.php"
click node_http_kernel "https://github.com/beikeshop/beikeshop/blob/master/app/Http/Kernel.php"
click node_shop_routes "https://github.com/beikeshop/beikeshop/blob/master/beike/Shop/Routes/shop.php"
click node_shop_auth "https://github.com/beikeshop/beikeshop/blob/master/app/Http/Middleware/ShopAuthenticate.php"
click node_checkout "https://github.com/beikeshop/beikeshop/blob/master/beike/Shop/Services/CheckoutService.php"
click node_cart_service "https://github.com/beikeshop/beikeshop/blob/master/beike/Shop/Services/CartService.php"
click node_order_totals "https://github.com/beikeshop/beikeshop/blob/master/beike/Shop/Services/TotalServices/OrderTotalService.php"
click node_storefront_theme "https://github.com/beikeshop/beikeshop/tree/master/themes/default"
click node_admin_routes "https://github.com/beikeshop/beikeshop/blob/master/beike/Admin/Routes/admin.php"
click node_admin_application "https://github.com/beikeshop/beikeshop/blob/master/beike/Admin/Services/ProductService.php"
click node_admin_api "https://github.com/beikeshop/beikeshop/blob/master/beike/AdminAPI/Controllers/OrderController.php"
click node_domain_models "https://github.com/beikeshop/beikeshop/tree/master/beike/Models"
click node_order_repository "https://github.com/beikeshop/beikeshop/blob/master/beike/Repositories/OrderRepo.php"
click node_relational_database "https://github.com/beikeshop/beikeshop/blob/master/database/migrations/2021_12_26_111435_create_tables.php"
click node_plugin_hook_system "https://github.com/beikeshop/beikeshop/blob/master/beike/Plugin/Manager.php"
click node_payment_shipping_plugins "https://github.com/beikeshop/beikeshop/blob/master/plugins/Paypal/Bootstrap.php"
click node_installer "https://github.com/beikeshop/beikeshop/blob/master/beike/Installer/Controllers/DatabaseController.php"
click node_console_commands "https://github.com/beikeshop/beikeshop/blob/master/beike/Console/Commands/ProcessOrder.php"
click node_deployment "https://github.com/beikeshop/beikeshop/blob/master/docker-compose.yml"

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_http_entry,node_laravel_bootstrap,node_http_kernel toneBlue
class node_shop_routes,node_shop_auth,node_checkout,node_cart_service,node_order_totals,node_storefront_theme toneAmber
class node_admin_routes,node_admin_application,node_admin_api toneMint
class node_domain_models,node_order_repository,node_relational_database toneRose
class node_plugin_hook_system,node_payment_shipping_plugins,node_installer,node_console_commands,node_deployment toneIndigo
```

## Components

### Laravel Runtime

- [HTTP entry](https://github.com/beikeshop/beikeshop/blob/master/public/index.php): PHP front controller · `public/index.php`
- [Application bootstrap](https://github.com/beikeshop/beikeshop/blob/master/bootstrap/app.php): Laravel bootstrap · `bootstrap/app.php`
- [HTTP middleware kernel](https://github.com/beikeshop/beikeshop/blob/master/app/Http/Kernel.php): Laravel HTTP kernel · Applies session, CSRF, locale, currency, and authentication middleware. · `app/Http/Kernel.php`

### Storefront Commerce

- [Shop routes](https://github.com/beikeshop/beikeshop/blob/master/beike/Shop/Routes/shop.php): route surface · `beike/Shop/Routes/shop.php`
- [Shop auth](https://github.com/beikeshop/beikeshop/blob/master/app/Http/Middleware/ShopAuthenticate.php): shop middleware · `app/Http/Middleware/ShopAuthenticate.php`
- [Checkout controller & service](https://github.com/beikeshop/beikeshop/blob/master/beike/Shop/Services/CheckoutService.php): commerce orchestration · Validates checkout and selects payment and shipping methods. · `beike/Shop/Services/CheckoutService.php`
- [Cart service](https://github.com/beikeshop/beikeshop/blob/master/beike/Shop/Services/CartService.php): commerce service · `beike/Shop/Services/CartService.php`
- [Order totals](https://github.com/beikeshop/beikeshop/blob/master/beike/Shop/Services/TotalServices/OrderTotalService.php): total calculator · `beike/Shop/Services/TotalServices/OrderTotalService.php`
- [Storefront themes](https://github.com/beikeshop/beikeshop/tree/master/themes/default): Blade theme templates · `themes/default`

### Administration

- [Admin routes](https://github.com/beikeshop/beikeshop/blob/master/beike/Admin/Routes/admin.php): route surface · `beike/Admin/Routes/admin.php`
- [Admin product management](https://github.com/beikeshop/beikeshop/blob/master/beike/Admin/Services/ProductService.php): controllers and services · Server-rendered administration uses the shared domain layer. · `beike/Admin/Services/ProductService.php`
- [Admin API](https://github.com/beikeshop/beikeshop/blob/master/beike/AdminAPI/Controllers/OrderController.php): management API · `beike/AdminAPI/Controllers/OrderController.php`

### Domain & Persistence

- [Eloquent domain models](https://github.com/beikeshop/beikeshop/tree/master/beike/Models): shared domain layer · Products, carts, customers, orders, payments, shipping, tax, and settings. · `beike/Models`
- [Order repository](https://github.com/beikeshop/beikeshop/blob/master/beike/Repositories/OrderRepo.php): domain repository · `beike/Repositories/OrderRepo.php`
- [MySQL / PostgreSQL](https://github.com/beikeshop/beikeshop/blob/master/database/migrations/2021_12_26_111435_create_tables.php): relational database · Schema is created by Laravel migrations. · `database/migrations/2021_12_26_111435_create_tables.php`

### Extensions & Operations

- [Plugin manager & hooks](https://github.com/beikeshop/beikeshop/blob/master/beike/Plugin/Manager.php): extension boundary · Loads filesystem plugins and exposes non-invasive hooks. · `beike/Plugin/Manager.php`
- [Payment & shipping plugins](https://github.com/beikeshop/beikeshop/blob/master/plugins/Paypal/Bootstrap.php): checkout adapters · Plugins such as PayPal and Stripe supply checkout integrations. · `plugins/Paypal/Bootstrap.php`
- [Installer](https://github.com/beikeshop/beikeshop/blob/master/beike/Installer/Controllers/DatabaseController.php): web installation wizard · `beike/Installer/Controllers/DatabaseController.php`
- [Console commands](https://github.com/beikeshop/beikeshop/blob/master/beike/Console/Commands/ProcessOrder.php): Artisan operations · Installs, processes orders, and runs operational tasks. · `beike/Console/Commands/ProcessOrder.php`
- [Docker deployment](https://github.com/beikeshop/beikeshop/blob/master/docker-compose.yml): runtime infrastructure · Runs web server, PHP, database, and optional workers/Horizon. · `docker-compose.yml`

## Connections

- HTTP entry → Application bootstrap: boots
- Application bootstrap → HTTP middleware kernel: creates
- HTTP middleware kernel → Shop routes: dispatches
- HTTP middleware kernel → Admin routes: dispatches
- HTTP middleware kernel → Admin API: dispatches
- Shop routes → Shop auth: protects routes
- Shop auth → Checkout controller & service: authorizes
- Checkout controller & service → Cart service: uses cart
- Checkout controller & service → Order totals: calculates totals
- Checkout controller & service → Order repository: creates orders
- Checkout controller & service → Payment & shipping plugins: selects adapters
- Shop routes → Storefront themes: renders
- Cart service → Eloquent domain models: persists cart
- Order repository → Eloquent domain models: accesses
- Eloquent domain models → MySQL / PostgreSQL: maps to
- Admin routes → Admin product management: serves
- Admin product management → Eloquent domain models: manages
- Admin API → Eloquent domain models: manages
- Plugin manager & hooks → Payment & shipping plugins: registers
- Plugin manager & hooks → Checkout controller & service: extends
- Installer → MySQL / PostgreSQL: initializes
- Console commands → Eloquent domain models: processes
- Docker deployment → HTTP entry: serves
