Appearance
Architecture ​
Overview ​
The Backend-API runs on Laravel 11 (laravel/framework ^11.21) but keeps the older application skeleton. The HTTP and console kernels are bound in bootstrap/app.php (App\Http\Kernel, App\Console\Kernel, App\Exceptions\Handler), routes are registered in App\Providers\RouteServiceProvider, middleware aliases live in app/Http/Kernel.php, and providers are listed in the providers array of config/app.php.
Every API surface authenticates with Laravel Passport bearer tokens. Each surface has its own guard and user provider, so the same token format maps to different user tables. Responses are mostly built with the RestResponse facade (App\RestResource\RestResponse), which returns JSON shaped as status, code, message.
Request lifecycle ​
Global middleware ​
Defined in App\Http\Kernel::$middleware, run on every request in this order:
| Order | Middleware |
|---|---|
| 1 | App\Http\Middleware\TrustProxies (TrustHosts is commented out) |
| 2 | Illuminate\Http\Middleware\HandleCors |
| 3 | App\Http\Middleware\CheckForMaintenanceMode |
| 4 | App\Http\Middleware\PreventRequestsDuringMaintenance |
| 5 | Illuminate\Foundation\Http\Middleware\ValidatePostSize |
| 6 | App\Http\Middleware\TrimStrings |
| 7 | Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull |
Middleware groups ​
| Group | Middleware |
|---|---|
web | EncryptCookies, AddQueuedCookiesToResponse, StartSession, ShareErrorsFromSession, VerifyCsrfToken, SubstituteBindings |
api | LogApiRequests, throttle:api, SubstituteBindings (EnsureFrontendRequestsAreStateful is commented out) |
The api rate limiter is set in RouteServiceProvider::configureRateLimiting(): 600 requests per minute, keyed by user id or, for guests, by IP. A second named limiter, verify-token, allows 1200 requests per minute keyed by verify-token| plus the sha1 of the bearer token (or of the IP when there is no token); only GET /api/v1/auth/verify uses it, and that route removes throttle:api (added in commit 6ac8a4f). Most authenticated route groups also add throttle:600,1 explicitly. All route aliases are listed on the Middleware page.
How route files are loaded ​
RouteServiceProvider::boot() registers everything inside $this->routes(...):
| Order | Registration | Prefix | Group | Namespace |
|---|---|---|---|---|
| 1 | Route::get('/health', [HealthController::class, 'index']) | none | none | n/a |
| 2 | routes/api.php | api | api | none (controllers imported with use) |
| 3 | routes/web.php | none | web | none |
| 4 | routes/dam-api.php | dam | api | App\Http\Controllers |
| 5 | routes/external-api.php | external | api | App\Http\Controllers |
Each of the three API files wraps its routes in Route::prefix('v1'), so real paths are /api/v1/..., /dam/v1/... and /external/v1/.... The provider also declares namespaces for mobile controllers (Mobile\PM, Mobile\DAM\Front\v1, Mobile\DAM\Front\v2, Mobile\LM) that are not used by any registered route file. routes/web2.php is not registered.
routes/channels.php is loaded by BroadcastServiceProvider, and routes/console.php by App\Console\Kernel::commands().
Guard per surface ​
| Surface | Public routes (no guard) | Authenticated group |
|---|---|---|
/api/v1 | Login, register, password reset, social login (social), passkey login, SAML SSO entry points, share-link views, file preview webhook, subscription endpoints | throttle:600,1 then auth:api. Workspace routes add checkUserWithWS; digital-assets adds checkUserWithWS, setEtag, IfNoneMatchEtag; SSO settings add checkWorkspaceOwner, checkSsoAllowed. External uploader routes use check.external (guard external-user). |
/dam/v1 | Login, login by id, password reset, invitations, public portal check, share-link views, verify-domain | auth:dam-api, dam-api, throttle:600,1, setEtag, IfNoneMatchEtag |
/external/v1 | login | auth:external-api, external-api, throttle:600,1 |
| web | /, /status, /admin/* with throttle:600,1 | Session handling is done inside the Web controllers; no auth middleware is attached in routes/web.php |
See Routes for full route tables.
Authentication guards ​
From config/auth.php. The default guard is web and the default password broker is users (table password_resets, 60 minute expiry, 60 second throttle).
| Guard | Driver | Provider | Model | Token name created at login | Used by |
|---|---|---|---|---|---|
web | session | users | App\Models\User | n/a | routes/web.php |
api | passport | users | App\Models\User | Api Token (login, register, social, passkey, support login); SSO Token (SAML) | /api/v1, broadcasting auth |
dam-api | passport | dealer_users | App\Models\DAM\DealerUsers | DAM Api Token | /dam/v1 |
external-api | passport | external_app | App\Models\DAM\DamExternalApp | External Api Token | /external/v1 |
external-user | passport | external_users | App\Models\ExternalUser | external-token | check.external routes in /api/v1; auth/verify via auth.user-or-external |
DAMAPIMiddleware and ExternalAPIMiddleware also check the token name, so a token issued for one surface cannot be reused on another even though all three are Passport tokens.
Passport reads and writes its tables on the mysql_primary connection (config/passport.php, PASSPORT_CONNECTION). config/database.php explains why: a login writes the token and the next request reads it back, and a lagging read replica would return 401. SsoLoginService sets Passport::personalAccessTokensExpireIn() from saml.token_ttl_days before it creates the SSO Token; other logins keep Passport's default lifetime.
When the auth middleware fails, App\Http\Middleware\Authenticate::unauthenticated() returns {"error": "Unauthenticated."} with status 401 and logs the reason (no token, unparseable JWT, token missing from oauth_access_tokens, revoked, expired, revoked client, or signature mismatch with storage/oauth-public.key). App\Exceptions\Handler lists OAuthServerException in $dontReport so routine 401s do not fill the error log.
Queues ​
From config/queue.php. The default connection comes from QUEUE_CONNECTION (framework default sync).
| Connection | Driver | Notes |
|---|---|---|
sync | sync | Runs jobs inline |
database | database | Table jobs, DB connection mysql_queue, default queue default, retry_after from QUEUE_RETRY_AFTER |
database_migration | database | Same table and DB connection, queue migration, retry_after 10800 seconds (kept above the 2 hour job timeout) |
beanstalkd | beanstalkd | Queue default |
sqs | sqs | Standard AWS settings |
redis | redis | Redis connection default |
Failed jobs use the database-uuids driver by default, table failed_jobs, on mysql_queue. mysql_queue is a primary-only connection (no read host) so job reservation never reads from a replica.
Queue names used with ->onQueue() in app/:
| Queue | Calls | Examples |
|---|---|---|
high | 24 | AssetUpload, AssetApplyWatermark, UserWelcomeEmailJob, SendUserInvitationEmailJob, AnnouncementEmailJob |
medium | 23 | ConvertAssetsJob, SendDamEmailSystemNotificationJob, AddDamNotificationJob, SyncSsoMetadata; also the Scout queue (config/scout.php) |
low | 1 | SendFeedBackEmailJob |
video-previews | 4 | GenerateVideoPreviewJob |
migration, migration-high, migration-video-previews | 5 | Import jobs, dispatched on database_migration |
DispatchAssetJobs prints the worker command it expects for imports: php artisan queue:work database_migration --queue=migration --tries=1 --timeout=7200 --memory=10240. Job details are on the Jobs page.
Broadcasting ​
config/broadcasting.php defines pusher, ably, redis, log and null connections; the default comes from BROADCAST_DRIVER (framework default null). BroadcastServiceProvider registers Broadcast::routes(['middleware' => ['auth:api,dam-api']]) and loads routes/channels.php, where each channel is pinned to one guard.
| Channel | Authorised when |
|---|---|
App.User.{id} | $user->id === $id |
user.{id} | $user->id === $id |
user.{user_id}.projectBatchNotification | $user->id === $user_id |
user.{user_id}.DAMFrontendAnnouncementNotification | $user->id === $user_id |
user.{user_id}.getUserSubscriptionChannel | $user->id === $user_id |
logoutDealershipUser.{user_id} | $user->id === $user_id |
Events that broadcast are covered on Events.
Storage disks ​
From config/filesystems.php. The default disk comes from FILESYSTEM_DRIVER (default local).
| Disk | Driver | Root |
|---|---|---|
local | local | storage/app |
public | local | storage/app/public |
uploads | local | public/upload/reports |
dealerships | local | public/upload/dealerships |
leads | local | public/upload/leads |
DamAssetOrder | local | public/upload/DamAssetOrder |
DamDeleteImages | local | public/upload/DamDeleteImages |
Inquiry | local | public/upload/inquiry |
downloadAsset | local | public/upload/ |
public_script | local | public/script |
s3 | s3 | Main asset bucket |
s3_backup | s3 | Root {APP_ENV}_backup |
s3Cloudfront | s3 | CloudFront-backed bucket |
Database connections ​
config/database.php defines sqlite, mysql, mysql_primary, mysql_queue, pgsql and sqlsrv. mysql supports read/write splitting (read and write hosts from DB_READ_HOST / DB_WRITE_HOST, falling back to DB_HOST). mysql_primary (Passport) and mysql_queue (queue and failed jobs) always use the write host. Redis connections default and cache are also defined there.
Caching ​
config/cache.php default store comes from CACHE_DRIVER (default file). Stores defined: apc, array, database, file, memcached, redis (connection cache, lock connection default), dynamodb, octane. Notable uses of the cache:
- WebAuthn challenges:
AppServiceProviderbindsWebAuthnChallengeRepositorytoApp\WebAuthn\CacheChallengeRepository, because the API has no session between the options and verify calls. - SSO entry checks:
App\Services\Sso\SsoEntryCheckcaches whether a workspace has an enabled SSO connection (60 second TTL per its docblock). HealthControllerwrites and reads a short-lived key to check the cache.
Logging ​
config/logging.php default channel comes from LOG_CHANNEL (default stack).
| Channel | Driver | Target |
|---|---|---|
stack | stack | single + weekly |
single | single | storage/logs/laravel.log |
daily | daily | storage/logs/laravel.log, 14 days |
weekly | custom via App\Logging\CreateWeeklyLog | storage/logs/weekly/{start}-to-{end}.log (Monday to Sunday dates) |
customlog | single | storage/logs/custom.log |
slack, papertrail, stderr, syslog, errorlog, null, emergency | framework defaults |
BigQuery request, job and cron logs ​
When bigquerylog.enabled is true (BIGQUERY_LOG_ENABLED):
LogApiRequests(in theapigroup) assigns anX-Request-Id, counts DB queries, and onterminate()writes anapi_requestsrow (path, action, workspace, user, sanitised request data, status, truncated body, duration).BigQueryLogServiceProviderregistersJobLogger(job_logs) andCronLogger(cron_runs).WebhookLogger::incoming()writeswebhook_calls.App\Services\BigQueryLog\Spoolerappends rows as NDJSON understorage/app/bigquery-spool, maskingbigquerylog.sensitive_keys.- The scheduled
bigquery:shipcommand (ShipLogsToBigQuery) rotates the spool files and loads them into the configured dataset every five minutes.
Scheduled tasks ​
The schedule is defined in App\Console\Kernel::schedule(). Commands are auto-loaded from app/Console/Commands plus PublishAnnouncements listed in $commands. Entries without ->timezone() run in the app timezone (APP_TIMEZONE, which defaults to Asia/Kolkata in config/app.php); the comments in the kernel give IST and MST equivalents for each time.
| Command class / name | Frequency |
|---|---|
ShipLogsToBigQuery (bigquery:ship) | Every five minutes, without overlapping |
NotificationCountUpdate | Daily 06:40 |
DAMRemoveTempFiles | Daily 06:50 |
DamAddWorkspaceStorage | Daily 07:20 |
TrialExpire | Daily 07:30 |
SuspendAccount | Daily 07:40 |
DAMAddTokens | Daily 07:50 |
telescope:prune | Daily 08:00, only when Laravel\Telescope\Telescope exists |
DAMRemoveAssetConvertFile | Daily 08:20 |
DAMRemoveAssetDownloadFile | Daily 08:30 |
TrialEndMail | Daily 08:40 |
PermanentDeleteAssets | Daily 09:10, without overlapping |
DAMGenerateAssetsPreview | Sundays 09:30 |
DamFilePreviewCheck | Sundays 09:40 |
TypesenseSmartSyncCommand (typesense:smart-sync) | Daily 11:50 |
DamExpiredShareUrl | Daily 12:40 |
publish:scheduled_announcements | Daily 13:30, without overlapping |
SendWeeklyPlatformReport | Mondays 09:00 America/Denver |
MonthlyWorkspaceReports | 1st of the month 09:00 America/Denver |
Commented-out entries include CheckCroneCommand, the import dispatcher, TypesenseDailySyncCommand, ScoutImportAll and TypesenseSyncDataCommand. See Console commands.
Health check ​
GET /health (HealthController@index) checks database, search (Typesense health), queue (connection size), worker (services.zip_worker.url), storage and cache. It returns status: ok with 200 when all pass, otherwise status: degraded with 503.
Service providers ​
Application providers from config/app.php (App\Providers\*):
| Provider | What it registers |
|---|---|
AppServiceProvider | Binds WebAuthnChallengeRepository to App\WebAuthn\CacheChallengeRepository. In boot(): forces HTTPS=on outside local, adds a view composer for admin_v2.partials.sidebar (nav counts), and registers the unique_attribute_values validation rule. |
AuthServiceProvider | Calls registerPolicies(); no policies are mapped. |
BroadcastServiceProvider | Broadcast auth routes with auth:api, loads routes/channels.php. |
EventServiceProvider | Listener map: Registered to SendEmailVerificationNotification; UpdateSubscriptionRestrictionEvent to UpdateSubscriptionRestrictionListener; GetUserSubscriptionEvent to GetUserSubscriptionListener; MessageSending to ApplyWorkspaceMailToMessage; SocialiteWasCalled to MicrosoftExtendSocialite. Event discovery is off. |
RouteServiceProvider | Route files, /health, and the api rate limiter. |
RestResourceProvider | Binds RestResponse to App\RestResource\RestResponse (facade alias RestResponse). |
ProjectAtivityProvider | Binds Activity to App\ProjectActivity\Activity (alias Activity). |
WorkSpaceActivityProvider | Binds WorkSpaceActivity to App\WorkSpaceActivity\WorkSpaceActivity (alias WorkSpaceActivity). |
ZipCodeServiceProvider | Binds ZipCode to App\ZipCode\ZipCode (alias ZipCode). |
PushNotificationServiceProvider | Binds PushNotification to App\PushNotification\PushNotification (alias PushNotification). Listed three times in config/app.php. |
BigQueryLogServiceProvider | When bigquerylog.enabled, registers JobLogger and CronLogger. |
SmtpServiceProvider | Binds custom.smtp.mailer, which builds a Mailer from SMTP parameters passed at resolve time (used for per-workspace SMTP). |
TelescopeServiceProvider and Laravel\Passport\PassportServiceProvider are commented out in the list (Passport is loaded through package discovery). Package providers listed explicitly: DomPDF, Excel, Vision, Intervention Image, Gravatar, Location and QrCode.