Environment Configuration
Relevant source files
The following files were used as context for generating this wiki page:
Environment configuration in the DXKB project is managed through a hierarchical system of JavaScript configuration files and integrated into the application's runtime state via the p3app initialization logic. This system allows the application to define service endpoints, authentication parameters, and application-specific metadata that vary across different deployment environments, such as development, testing, and production.
The configuration architecture relies on a base configuration (config.js) that defines standard defaults, which are then overridden or extended by environment-specific files like config-dev.js or config-test.js. These settings are ultimately consumed by the window.App object in the browser, providing a centralized global state for components to access backend APIs and internal service logic.
Configuration Architecture
The DXKB web application uses a modular configuration strategy where global variables are assigned to the window.App object during the application bootstrap process. This ensures that widgets and services have consistent access to necessary URIs and feature flags.
Configuration Layers
The system is structured into several files that define the environment:
- Base Configuration (
config.js): Defines the default values for the production environment, including primary API endpoints for data, services, and documentation. - Development Configuration (
config-dev.js): Overrides production settings to point to development servers or local instances. - Test Configuration (
config-test.js): Specialized settings for automated testing environments.
Service Endpoint Mapping
The configuration files primarily manage URIs for various microservices. Key endpoints include:
dataAPI: The primary endpoint for genomic and metadata queries.serviceAPI: The endpoint for job submission and backend task management.userServiceURL: Manages user profiles and authentication tokens.docsServiceURL: Provides access to documentation and tutorial content.
Sources: config.js , config-dev.js , config-test.js
Application Initialization and State
The p3app.js file is responsible for consuming the configured environment variables and initializing the application state. It manages authentication checks, service initialization, and the integration of the router.
Runtime Configuration Loading
During the startup phase, the application checks for an existing tokenstring in local storage to determine the login state. If valid, it populates the window.App object with user details and authorization tokens.
The diagram shows the flow of environment data into the runtime application state during startup.
Sources: public/js/p3/app/p3app.js:25-60, public/js/p3/app/p3app.js:410-450
Key Configuration Parameters
The following table summarizes the primary configuration options found across the environment files:
| Parameter | Type | Description |
|---|---|---|
dataAPI | String | URL for the Solr-based data service. |
serviceAPI | String | URL for the backend application service (job submission). |
workspaceAPI | String | URL for the workspace management service. |
userServiceURL | String | URL for user authentication and profile management. |
docsServiceURL | String | URL for the documentation system. |
appBaseURL | String | Base URL for the application's client-side routing. |
gaID | String | Google Analytics identifier. |
localStorageCheckInterval | Integer | Milliseconds between token expiration checks (default: 30000). |
Sources: config.js, public/js/p3/app/p3app.js:410-450
Authentication Environment
DXKB handles authentication by interacting with the userServiceURL defined in the configuration. The environment supports multiple login realms and token refresh logic.
Token Management
The application implements a timeout loop that periodically checks the validity of the authentication token stored in the environment. If the mouse has been active or an upload is in progress, the application attempts to refresh the token using the configured userServiceURL.
This sequence illustrates how the userServiceURL configuration is utilized to maintain user session state.
Sources: public/js/p3/app/p3app.js:400-480
Service Integration in Components
The base class for applications, AppBase.js, utilizes the global window.App configuration to provide consistent behavior across all analysis services.
Configuration Consumption in Widgets
Widgets like AppBase and its derivatives (e.g., RNA-Seq, Primer Design) rely on the following environment-derived properties:
- Authorization: Components check
window.App.authorizationTokento determine if a user has sufficient permissions to view or submit a form. - Documentation Links: The
applicationHelpandtutorialLinkproperties are joined withwindow.App.docsServiceURLto generate external help links. - API Client: The
window.App.apiobject, initialized inp3app.js, provides the RPC methods used by services to submit jobs (e.g.,AppService.start_app2).
Sources: public/js/p3/widget/app/AppBase.js:25-50, public/js/p3/widget/app/AppBase.js:250-280
Summary
The DXKB environment configuration system is a centralized mechanism that allows the web application to adapt to different deployment contexts by mapping service endpoints and authentication parameters. By leveraging a hierarchy of JavaScript configuration files and a robust initialization process in p3app.js, the project ensures that all client-side components remain synchronized with the backend service infrastructure.