Core runtime and application boundaries
Handbook · Coverage · Code reference
Pulse is a Laravel application with engine services, a plugin loader and two Vue applications. Laravel supplies routing, the service container, Eloquent, queues, configuration and middleware. Pulse adds engine contracts on top of those facilities. Understanding which layer owns a behavior makes changes smaller and debugging more predictable.
This chapter follows startup and one HTTP request. Use configuration for settings, data for persistence, operations for processes, and testing for verification.
Where code belongs
| Location | Responsibility | Typical change |
|---|---|---|
backend/bootstrap/app.php |
Laravel application wiring, middleware aliases, exception reporting | Framework-wide request integration |
backend/bootstrap/providers.php |
Engine provider registration | Provider order and availability |
backend/app/Core |
Reusable engine models, services, controllers, middleware, console commands | Generic capability usable without a game kit |
backend/app/Plugins/<slug> |
Installed plugin PHP code and manifests | Optional game feature |
backend/routes/api.php |
Core API routes | Core authenticated or public endpoint |
backend/routes/web.php |
Installer, SPA entry pages, health routes | Server-rendered entry behavior |
backend/routes/console.php |
Console route and scheduler definitions | Scheduled engine jobs |
backend/config/core.php |
Downstream provider seam | Product-only bindings |
frontend |
Player/public Vue shell and shared plugin host | Player-facing UI |
backend/resources/admin |
Separate admin Vue application | Operator-facing UI |
Core must run without Gamekit or another concrete optional plugin. Import core
models such as App\Core\Models\PlayerStat. Resolve a documented interface,
service binding or hook when the implementation belongs to a plugin.
A core fix belongs in pulse-engine; distributable optional mechanics belong
in pulse-plugins; game recipes and presentation belong in game-kits.
Core can download signed packages from the configured marketplace service
without becoming that marketplace server.
Startup sequence
- Laravel enters through
backend/public/index.phpfor HTTP orbackend/artisanfor CLI and loads Composer's autoloader. bootstrap/app.phpconfigures the application, core route files, broadcasting channel routes and the/upframework health endpoint.- Providers in
bootstrap/providers.phpregister container bindings and then boot services. Register bindings before attempting to use them in boot logic. - Plugin discovery registers namespaces, configuration and optional plugin class bindings. Boot applies database state, mounts resources and boots enabled plugin classes.
AutoPluginHookLoaderloads pluginhooks.phpfiles. Request routing or command execution then uses the initialized application.
The registered engine providers, in source order, are:
| Provider | Registration / boot responsibilities |
|---|---|
App\Core\Providers\AppServiceProvider |
Text formatter and studio bindings, product providers, commands; strict models, policies, rate limiter, hook schemas, product migration path |
App\Core\Providers\HookServiceProvider |
Singleton hook service and class alias; baseline callbacks and hook metadata |
App\Core\Providers\PluginServiceProvider |
Discovery, autoload mapping, dependency ordering, plugin config/classes; registry state and resources |
App\Core\Providers\AutoPluginHookLoader |
Load plugin hook files once per application container |
App\Providers\HorizonServiceProvider |
Horizon integration and access configuration |
This order explains why a provider should not dispatch an application event
prematurely in register(): plugin listeners may not yet be loaded. Register
services in register(), prepare application integrations in boot(), and
perform business work in a controller, command or explicit service operation.
Container access and lifetime
The service container maps names/classes to objects. Constructor injection is preferred for services you own because dependencies are visible and testable:
<?php
namespace App\Core\Services;
final class JournalPreviewService
{
public function __construct(private readonly HookService $hooks) {}
public function title(string $title): string
{
return (string) $this->hooks->filter('journal.preview.title', $title);
}
}
This illustrative class would live at
backend/app/Core/Services/JournalPreviewService.php if the feature were a core
capability. A plugin-specific version belongs in the plugin namespace instead.
Resolving it with app(JournalPreviewService::class) asks Laravel to inject
HookService. It returns the original title until a listener transforms it.
| Binding | Access | Lifetime / purpose |
|---|---|---|
hook, alias HookService::class |
app('hook') or class injection |
Singleton within application container |
text-formatter |
app('text-formatter') |
Singleton TextFormatterService |
FormulaEngineService::class |
Class injection | Singleton studio formula evaluator |
GameEntityStudioService::class |
Class injection | Singleton entity studio service |
SlotLayoutStudioService::class |
Class injection | Singleton slot layout service |
plugins |
app('plugins') after provider boot |
Discovered metadata with registry state |
modules |
app('modules') |
Compatibility alias for metadata, not a second engine |
| Declared plugin class | Class injection | Singleton created using its plugin directory |
A singleton is not a global object shared by all server processes. In ordinary requests, it belongs to that application instance. Long running workers need particular care with mutable in-memory state. Do not retain a current user in a singleton service field. See operations for worker lifecycle.
Do not assume app('economy'), app('inventory') or app('combat') are always
available: the provider comments assign those names to plugin hook bindings.
Class names, binding availability and business service contracts are separate
questions. Economy explains the actual core ledger APIs.
HTTP route families
withRouting(api: ...) gives backend/routes/api.php the /api prefix.
The file itself adds /v1 for most core client endpoints. Plugin routes use a
separate unversioned namespace.
| URL family | Source / use |
|---|---|
/api/v1/... |
Core client API, including auth and admin route groups |
/api/plugins/enabled, /slots, /menus, /status/{plugin} |
Frontend plugin registry |
/api/plugins/{slug}/... |
Canonical plugin API namespace |
/api/plugins/{slug}/admin/... |
Plugin API with admin/moderator role middleware |
/api/license/callback |
Stable server-to-server callback path |
/install/... |
Browser installer and step APIs |
/admin/{any?} |
Admin SPA entry HTML |
/up |
Laravel framework health route |
/api/v1/healthz/live, /api/v1/healthz/ready |
Engine health controller |
Do not prepend /api/v1 to plugin URLs. Conversely, use the version prefix for
core endpoints. Read the route's middleware group before deciding it is public.
The registry's permissions endpoint, for example, requires Sanctum auth even
though some discovery endpoints are public.
Request pipeline
For a typical authenticated API request:
- The web server forwards the request to Laravel's public entry point.
- Global middleware runs, including IP ban checking and installation detection.
- The API stack applies installation detection and Sanctum's stateful request support. Route middleware then applies authentication and any role, permission, ban, password-change or plugin access requirements.
- Laravel resolves the controller and its dependencies from the container.
- The controller validates input, calls a domain service and returns a response.
- Exceptions are rendered by Laravel; eligible errors are also reported to
Pulse's
ErrorLogmodel when the application is booted.
statefulApi() enables Sanctum's browser/session integration. APIs also accept
the bearer tokens used by Pulse's clients. This does not make all routes
protected: a route must still request authentication. See
security for credentials, CSRF and authorization.
Middleware aliases and exact roles
| Alias | Class / effect |
|---|---|
role |
Spatie RoleMiddleware |
permission |
Spatie PermissionMiddleware |
role_or_permission |
Spatie combined middleware |
force.password.change |
Core ForcePasswordChange |
plugin.access |
Installed/enabled/licensed plugin check |
ip.ban |
Core CheckIpBan |
user.banned |
Core CheckUserBanned |
installer |
Core InstallerLocked |
The bootstrap config returns HTTP 401 for unauthenticated guests rather than redirecting API clients to a login page. Route-specific validation and exception rendering still determine the final JSON response.
Installer paths install/* are excluded from CSRF verification. This is a
specific bootstrapping rule, not a pattern to copy into game feature routes.
Installation detection is present in multiple configured stacks; use its source
to understand exact exemptions rather than removing it when setup fails.
The API limiter defined by AppServiceProvider is 60 per minute, keyed by user
ID or IP. Defining a limiter and applying middleware are separate steps. Auth
routes additionally show explicit throttle:10,1 groups in routes/api.php.
Product seams: extend without editing engine internals
A downstream application can add three backend extension points:
| Seam | Exact discovery behavior |
|---|---|
backend/routes/product.php |
If present, mounted with api middleware and /api prefix |
backend/database/migrations/product |
If directory exists, registered as a migration path |
config('core.product_providers') |
Each provider is registered by core AppServiceProvider |
For a downstream-only status endpoint, put this in
backend/routes/product.php:
<?php
use Illuminate\Support\Facades\Route;
Route::get('/v1/product/status', fn () => response()->json([
'success' => true,
'product' => 'my-game',
]));
Expected URL: GET /api/v1/product/status. The response is the given JSON.
There is no automatic auth:sanctum on the product group: add it explicitly for
private data. Do not repeat /api in the file or it becomes /api/api/....
For a downstream service provider, add its fully qualified class to
backend/config/core.php's product_providers array. Use the provider to bind
interfaces or attach hooks. Do not run migrations, seeders or external requests
on every provider boot.
The public frontend has the corresponding
frontend/src/router/product-routes.ts seam. It is part of the SPA build;
adding backend routes does not automatically create a Vue screen.
CLI and test boot behavior
Artisan uses the same application bootstrap. Commands can therefore fail before
handle() if a provider performs unavailable database/network work. Keep boot
resilient to an uninitialized installation.
PluginServiceProvider explicitly returns early from registration and boot
when Laravel is running unit tests. Ordinary RefreshDatabase tests therefore
do not automatically load every installed plugin's routes and migrations.
Tests requiring plugin integration must initialize the relevant pieces; see
testing and PluginKernelTest.
Useful inspection commands, run in the local backend environment:
php artisan list
php artisan route:list --path=api/plugins
php artisan route:list --path=api/v1
php artisan about
These inspect runtime registrations. Do not guess at a command from another
engine. There is no general plugin:* management namespace; pulse:package
currently declares a narrow legacy plugin:package alias, which does not imply
other plugin:* commands exist.
Errors and runtime limits
Non-production boot enables Eloquent strict behavior, which can surface lazy loading, discarded attributes and missing attributes. Fix the query or model contract instead of assuming a production-only success proves correctness.
Exception reporting skips authentication, validation, not-found and method-not- allowed exception classes in its listed cases. Database logging itself is wrapped in a catch, so an unavailable error table should not replace the original exception. Reporting does not guarantee every exception is persisted.
Outside production, bootstrap suppresses E_DEPRECATED from the active PHP
error reporting mask to prevent newer local PHP notices contaminating API
responses. Production and local PHP versions still need deliberate alignment.
A missing SPA bundle is a serving/build problem. The root route prefers
public/index.html, then public/admin/index.html, then a basic HTML fallback.
The /admin catchall reads its own built index. A 200 response serving HTML is
not proof that an API endpoint exists; inspect response content type and URL.
Sources: bootstrap (backend/bootstrap),
AppServiceProvider (backend/app/Core/Providers/AppServiceProvider.php),
routes (backend/routes),
core configuration (backend/config/core.php).