How beikeshop/beikeshop works
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.
Components 20
Laravel Runtime
- HTTP entry
public/index.php - Application bootstrap
bootstrap/app.php - HTTP middleware kernel · Applies session, CSRF, locale, currency, and authentication middleware.
app/Http/Kernel.php
Storefront Commerce
- Shop routes
beike/Shop/Routes/shop.php - Shop auth
app/Http/Middleware/ShopAuthenticate.php - Checkout controller & service · Validates checkout and selects payment and shipping methods.
beike/Shop/Services/CheckoutService.php - Cart service
beike/Shop/Services/CartService.php - Order totals
beike/Shop/Services/TotalServices/OrderTotalService.php - Storefront themes
themes/default
Administration
- Admin routes
beike/Admin/Routes/admin.php - Admin product management · Server-rendered administration uses the shared domain layer.
beike/Admin/Services/ProductService.php - Admin API
beike/AdminAPI/Controllers/OrderController.php
Domain & Persistence
- Eloquent domain models · Products, carts, customers, orders, payments, shipping, tax, and settings.
beike/Models - Order repository
beike/Repositories/OrderRepo.php - MySQL / PostgreSQL · Schema is created by Laravel migrations.
database/migrations/2021_12_26_111435_create_tables.php
Extensions & Operations
- Plugin manager & hooks · Loads filesystem plugins and exposes non-invasive hooks.
beike/Plugin/Manager.php - Payment & shipping plugins · Plugins such as PayPal and Stripe supply checkout integrations.
plugins/Paypal/Bootstrap.php - Installer
beike/Installer/Controllers/DatabaseController.php - Console commands · Installs, processes orders, and runs operational tasks.
beike/Console/Commands/ProcessOrder.php - Docker deployment · Runs web server, PHP, database, and optional workers/Horizon.
docker-compose.yml
Connections 23
- 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