Bootstrap & Initialization

Sequence

index.html loads
  → main.ts bootstraps AppModule
  → AppModule constructor
      · tryAddNoIndex()   — adds <meta robots=noindex> for white-label hosts
      · handlePlaid()     — captures Plaid OAuth redirect state from the URL
  → APP_INITIALIZER providers run (in registration order, all awaited)
  → StoreModule.forRoot() hydrates; AuthModule's persistent meta-reducer
    restores the auth slice from localStorage
  → AuthEffects.init$ fires: if an auth token exists, dispatch login({ authToken })
  → login$ → userRequested → loadUser$ → getUserByToken()
      · EventLoggerService.identify(user)
      · dispatch userLoaded, userPermissionsRequested,
                userDashboardStatusRequested, loadBalance
  → loadedUserPermissions$ → PermissionsService.getUserPermissions(user)
      → userPermissionsLoaded({ permissions })
  → GlobalSubscriptionsService.init() mirrors permissions into NgxPermissions
    and starts all session-scoped subscriptions
  → Router activates BaseComponent (AuthGuard) and the requested lazy route

APP_INITIALIZER providers

Declared in src/app/core/initializers/app-initializer.provider.ts and registered in AppModule.providers.

Provider Effect

initializeLayoutConfigProvider

Loads LayoutConfig().configs into LayoutConfigService if no config is set.

initializePermissionsProvider

Seeds NgxPermissionsService with the bootstrap permission DASHBOARD_MODULE so the shell can render before the real permission set arrives.

initializeTranslateProvider

Sets and activates the default language, then blocks on the first onLangChange emission. Nothing renders until translations are ready.

initializePageLoadTimeTrackerProvider

Wires PageLoadTimeNotifierService to CloudWatchService so page-load durations are reported as custom metrics.

initializeDailySummaryLoadDataErrorTrackerProvider

Registers a CloudWatch counter for Daily Summary data-load failures.

initializeThemeProvider

ClientProviderService.init() — resolves the white-label / theme variant.

initializeMediaProvider

Registers the SVG icon set with PybIconRegistryService from assets/media using pybMediaRegistryConfig.

initializeAgGridLicenseProvider

LicenseManager.setLicenseKey(environment.agGridLicenseKey).

Two further providers are values rather than initializers:

initializeMatFormFieldOptionsProvider

MAT_FORM_FIELD_DEFAULT_OPTIONS = { floatLabel: 'always', appearance: 'outline' }.

setPerfectScrollbarConfigProvider

Tunes ngx-perfect-scrollbar (wheelSpeed: 0.5, no wheel propagation).

AppModule constructor behaviour

constructor(private readonly meta: Meta, private readonly oauthTokenService: OauthTokenService) {
    this.tryAddNoIndex();
    this.handlePlaid();
}
tryAddNoIndex()

If the current URL contains any of volusion, pro, lendio, neweggcapital, morecommerce, crm2, c2fo, a <meta name="robots" content="noindex"> tag is injected. These are white-label or partner-branded hosts that must not be indexed.

handlePlaid()

When the URL carries an oauth_state_id query parameter the app is returning from a Plaid OAuth redirect. The full URL is stored on OauthTokenService.oauthToken, the previously saved link_token is read out of localStorage into OauthTokenService.linkToken, and the localStorage entry is removed. PlaidModule picks these up to resume the Link session.

Third-party SDK configuration

All SDK configuration is read from environment at module-import time.

Module Configured with Notes

PybApiModule.forRoot()

apiUrl, marketplaceUrl, frontendActionsToolsApiUrl, b2bDocumentUrl, gci, frontendTaskManager, documentsApiUrl

The generated Payability API client.

MarqetaModule.forRoot()

marquetaSandbox

Seller Card issuance.

PlaidModule.forRoot()

plaidSandbox

Bank linking.

SegmentModule.forRoot()

segmentKey, debug: false, loadOnInitialization: environment.production

Segment only auto-loads in production; elsewhere it must be triggered manually.

CloudWatchModule.forRoot()

cloudWatchApiUrl

Custom metrics.

PageLoadTimeTrackerModule.forRoot(['/dashboard'])

Route allow-list

Only /dashboard is timed today.

ServiceWorkerModule.register()

enabled: environment.production, registrationStrategy: 'registerImmediately'

PWA caching is production-only.

Environment settings

config/environment.template is rendered into src/environments/environment.ts. EnvironmentService (src/environments/environment.service.ts) types it.

Key Meaning

env, version, buildTime

Build provenance, surfaced in the UI footer.

production

Toggles storeFreeze, Segment auto-load, the service worker and dev-only permissions.

isMockEnabled

Reserved for mocked data sources.

authTokenKey

The localStorage key holding the session token.

apiUrl, authUrl

Core Payability API endpoints.

marketplaceUrl

Marketplace service endpoint.

frontendActionsToolsApiUrl, frontendTaskManager

Frontend action/task services.

b2bDocumentUrl

Document service endpoint.

gci

Global client identifier passed to the API client.

airwalexBaseUrl

Airwallex card service base URL.

tabapayUrl

TabaPay iframe origin (card funding).

agGridLicenseKey

AG Grid Enterprise licence.

segmentKey

Segment write key.

referralUrl

Referral programme landing page.

marquetaSandbox, plaidSandbox

Sandbox toggles for the card and banking SDKs.

cloudWatchApiUrl

Metrics ingestion endpoint.

zendeskWidgetUrl, zendeskWidgetKey

Help centre widget.

recaptchaKey

reCAPTCHA v3 site key.

smartLookKey

Session-replay project key.