Skip to content

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:

OrderMiddleware
1App\Http\Middleware\TrustProxies (TrustHosts is commented out)
2Illuminate\Http\Middleware\HandleCors
3App\Http\Middleware\CheckForMaintenanceMode
4App\Http\Middleware\PreventRequestsDuringMaintenance
5Illuminate\Foundation\Http\Middleware\ValidatePostSize
6App\Http\Middleware\TrimStrings
7Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull

Middleware groups ​

GroupMiddleware
webEncryptCookies, AddQueuedCookiesToResponse, StartSession, ShareErrorsFromSession, VerifyCsrfToken, SubstituteBindings
apiLogApiRequests, 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(...):

OrderRegistrationPrefixGroupNamespace
1Route::get('/health', [HealthController::class, 'index'])nonenonen/a
2routes/api.phpapiapinone (controllers imported with use)
3routes/web.phpnonewebnone
4routes/dam-api.phpdamapiApp\Http\Controllers
5routes/external-api.phpexternalapiApp\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 ​

SurfacePublic routes (no guard)Authenticated group
/api/v1Login, register, password reset, social login (social), passkey login, SAML SSO entry points, share-link views, file preview webhook, subscription endpointsthrottle: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/v1Login, login by id, password reset, invitations, public portal check, share-link views, verify-domainauth:dam-api, dam-api, throttle:600,1, setEtag, IfNoneMatchEtag
/external/v1loginauth:external-api, external-api, throttle:600,1
web/, /status, /admin/* with throttle:600,1Session 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).

GuardDriverProviderModelToken name created at loginUsed by
websessionusersApp\Models\Usern/aroutes/web.php
apipassportusersApp\Models\UserApi Token (login, register, social, passkey, support login); SSO Token (SAML)/api/v1, broadcasting auth
dam-apipassportdealer_usersApp\Models\DAM\DealerUsersDAM Api Token/dam/v1
external-apipassportexternal_appApp\Models\DAM\DamExternalAppExternal Api Token/external/v1
external-userpassportexternal_usersApp\Models\ExternalUserexternal-tokencheck.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).

ConnectionDriverNotes
syncsyncRuns jobs inline
databasedatabaseTable jobs, DB connection mysql_queue, default queue default, retry_after from QUEUE_RETRY_AFTER
database_migrationdatabaseSame table and DB connection, queue migration, retry_after 10800 seconds (kept above the 2 hour job timeout)
beanstalkdbeanstalkdQueue default
sqssqsStandard AWS settings
redisredisRedis 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/:

QueueCallsExamples
high24AssetUpload, AssetApplyWatermark, UserWelcomeEmailJob, SendUserInvitationEmailJob, AnnouncementEmailJob
medium23ConvertAssetsJob, SendDamEmailSystemNotificationJob, AddDamNotificationJob, SyncSsoMetadata; also the Scout queue (config/scout.php)
low1SendFeedBackEmailJob
video-previews4GenerateVideoPreviewJob
migration, migration-high, migration-video-previews5Import 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.

ChannelAuthorised 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).

DiskDriverRoot
locallocalstorage/app
publiclocalstorage/app/public
uploadslocalpublic/upload/reports
dealershipslocalpublic/upload/dealerships
leadslocalpublic/upload/leads
DamAssetOrderlocalpublic/upload/DamAssetOrder
DamDeleteImageslocalpublic/upload/DamDeleteImages
Inquirylocalpublic/upload/inquiry
downloadAssetlocalpublic/upload/
public_scriptlocalpublic/script
s3s3Main asset bucket
s3_backups3Root {APP_ENV}_backup
s3Cloudfronts3CloudFront-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: AppServiceProvider binds WebAuthnChallengeRepository to App\WebAuthn\CacheChallengeRepository, because the API has no session between the options and verify calls.
  • SSO entry checks: App\Services\Sso\SsoEntryCheck caches whether a workspace has an enabled SSO connection (60 second TTL per its docblock).
  • HealthController writes and reads a short-lived key to check the cache.

Logging ​

config/logging.php default channel comes from LOG_CHANNEL (default stack).

ChannelDriverTarget
stackstacksingle + weekly
singlesinglestorage/logs/laravel.log
dailydailystorage/logs/laravel.log, 14 days
weeklycustom via App\Logging\CreateWeeklyLogstorage/logs/weekly/{start}-to-{end}.log (Monday to Sunday dates)
customlogsinglestorage/logs/custom.log
slack, papertrail, stderr, syslog, errorlog, null, emergencyframework defaults

BigQuery request, job and cron logs ​

When bigquerylog.enabled is true (BIGQUERY_LOG_ENABLED):

  • LogApiRequests (in the api group) assigns an X-Request-Id, counts DB queries, and on terminate() writes an api_requests row (path, action, workspace, user, sanitised request data, status, truncated body, duration).
  • BigQueryLogServiceProvider registers JobLogger (job_logs) and CronLogger (cron_runs). WebhookLogger::incoming() writes webhook_calls.
  • App\Services\BigQueryLog\Spooler appends rows as NDJSON under storage/app/bigquery-spool, masking bigquerylog.sensitive_keys.
  • The scheduled bigquery:ship command (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 / nameFrequency
ShipLogsToBigQuery (bigquery:ship)Every five minutes, without overlapping
NotificationCountUpdateDaily 06:40
DAMRemoveTempFilesDaily 06:50
DamAddWorkspaceStorageDaily 07:20
TrialExpireDaily 07:30
SuspendAccountDaily 07:40
DAMAddTokensDaily 07:50
telescope:pruneDaily 08:00, only when Laravel\Telescope\Telescope exists
DAMRemoveAssetConvertFileDaily 08:20
DAMRemoveAssetDownloadFileDaily 08:30
TrialEndMailDaily 08:40
PermanentDeleteAssetsDaily 09:10, without overlapping
DAMGenerateAssetsPreviewSundays 09:30
DamFilePreviewCheckSundays 09:40
TypesenseSmartSyncCommand (typesense:smart-sync)Daily 11:50
DamExpiredShareUrlDaily 12:40
publish:scheduled_announcementsDaily 13:30, without overlapping
SendWeeklyPlatformReportMondays 09:00 America/Denver
MonthlyWorkspaceReports1st 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\*):

ProviderWhat it registers
AppServiceProviderBinds 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.
AuthServiceProviderCalls registerPolicies(); no policies are mapped.
BroadcastServiceProviderBroadcast auth routes with auth:api, loads routes/channels.php.
EventServiceProviderListener map: Registered to SendEmailVerificationNotification; UpdateSubscriptionRestrictionEvent to UpdateSubscriptionRestrictionListener; GetUserSubscriptionEvent to GetUserSubscriptionListener; MessageSending to ApplyWorkspaceMailToMessage; SocialiteWasCalled to MicrosoftExtendSocialite. Event discovery is off.
RouteServiceProviderRoute files, /health, and the api rate limiter.
RestResourceProviderBinds RestResponse to App\RestResource\RestResponse (facade alias RestResponse).
ProjectAtivityProviderBinds Activity to App\ProjectActivity\Activity (alias Activity).
WorkSpaceActivityProviderBinds WorkSpaceActivity to App\WorkSpaceActivity\WorkSpaceActivity (alias WorkSpaceActivity).
ZipCodeServiceProviderBinds ZipCode to App\ZipCode\ZipCode (alias ZipCode).
PushNotificationServiceProviderBinds PushNotification to App\PushNotification\PushNotification (alias PushNotification). Listed three times in config/app.php.
BigQueryLogServiceProviderWhen bigquerylog.enabled, registers JobLogger and CronLogger.
SmtpServiceProviderBinds 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.