Skip to content

Engine Configuration

The Niksphere Engine supports flexible runtime configuration management. Parameters can be supplied either via Environment Variables (prefixed with NIKSPHERE_ENGINE_) or via Configuration Files (config.yaml, config.json, or config.toml).

Configuration Precedence

The Engine evaluates configuration parameters in the following priority order (highest to lowest):

  1. Command-Line Flags (--config <path>)
  2. Environment Variables (NIKSPHERE_ENGINE_*)
  3. Configuration File (config.yaml / config.json / config.toml)
  4. Default Values

Command-Line Flags

When starting the Niksphere Engine executable, the following command-line flags are supported:

FlagTypeDefault ValueDescription
--config <path>string""Path to the Engine configuration file (e.g., config.yaml, config.json, or config.toml).
--service-name <name>stringniksphere-engineCustom service registration name when running as a background service (Windows Service / systemd).
-h, --helpflagfalseDisplays executable usage instructions and available flags.

HTTP & Server Settings

Configuration KeyEnvironment VariableTypeDefault ValueDescription
http_portNIKSPHERE_ENGINE_HTTP_PORTstring3000The TCP port for the Engine HTTP API and Server-Driven UI listener.
http_base_urlNIKSPHERE_ENGINE_HTTP_BASE_URLstringhttp://localhost:<http_port>Base public URL of the Engine instance. Used for OIDC issuer metadata and callback URLs.
trusted_proxiesNIKSPHERE_ENGINE_TRUSTED_PROXIES[]string[]List of trusted proxy IP addresses or CIDR ranges (e.g. 10.0.0.0/8) allowed to set the X-Forwarded-For header. If empty, the engine trusts no proxies for security.

Database Connection Settings

Configuration KeyEnvironment VariableTypeDefault ValueDescription
db_driverNIKSPHERE_ENGINE_DB_DRIVERstringsqliteDatabase driver backend. Supported options: sqlite, postgres, postgresql.
db_hostNIKSPHERE_ENGINE_DB_HOSTstring127.0.0.1Hostname or IP address of the database server (PostgreSQL).
db_portNIKSPHERE_ENGINE_DB_PORTstring5432Network port of the database server (PostgreSQL).
db_usernameNIKSPHERE_ENGINE_DB_USERNAMEstringniksphereDatabase user account name for authentication (PostgreSQL).
db_passwordNIKSPHERE_ENGINE_DB_PASSWORDstringniksphereDatabase user account password for authentication (PostgreSQL).
db_nameNIKSPHERE_ENGINE_DB_NAMEstringniksphereName of the target database (PostgreSQL) or local database file (SQLite).

| db_url | NIKSPHERE_ENGINE_DB_URL | string | "" | Optional full connection string/DSN overriding individual host/port properties (PostgreSQL & SQLite). |

IMPORTANT

If db_host or db_port are explicitly specified, db_driver MUST be set to postgres or postgresql.

Identity & Authentication (IDP Broker) Settings

Configuration KeyEnvironment VariableTypeDefault ValueDescription
idp_token_expiry_hoursNIKSPHERE_ENGINE_IDP_TOKEN_EXPIRY_HOURSstring24Expiration time for active user access tokens (in hours).
idp_refresh_token_expiry_daysNIKSPHERE_ENGINE_IDP_REFRESH_TOKEN_EXPIRY_DAYSstring30Expiration time for user refresh tokens (in days).

Configuration Examples

Example 1: Environment Variables

powershell
# Server Configuration
$env:NIKSPHERE_ENGINE_HTTP_PORT="3000"
$env:NIKSPHERE_ENGINE_HTTP_BASE_URL="https://engine.company.internal"
$env:NIKSPHERE_ENGINE_TRUSTED_PROXIES="10.0.0.0/8,192.168.0.0/16"

# Database Configuration (PostgreSQL)
$env:NIKSPHERE_ENGINE_DB_DRIVER="postgres"
$env:NIKSPHERE_ENGINE_DB_HOST="db.company.internal"
$env:NIKSPHERE_ENGINE_DB_PORT="5432"
$env:NIKSPHERE_ENGINE_DB_USERNAME="niksphere_admin"
$env:NIKSPHERE_ENGINE_DB_PASSWORD="securepassword123"
$env:NIKSPHERE_ENGINE_DB_NAME="niksphere_prod"

# Security & Identity
$env:NIKSPHERE_ENGINE_IDP_TOKEN_EXPIRY_HOURS="12"
bash
# Server Configuration
export NIKSPHERE_ENGINE_HTTP_PORT="3000"
export NIKSPHERE_ENGINE_HTTP_BASE_URL="https://engine.company.internal"
export NIKSPHERE_ENGINE_TRUSTED_PROXIES="10.0.0.0/8,192.168.0.0/16"

# Database Configuration (PostgreSQL)
export NIKSPHERE_ENGINE_DB_DRIVER="postgres"
export NIKSPHERE_ENGINE_DB_HOST="db.company.internal"
export NIKSPHERE_ENGINE_DB_PORT="5432"
export NIKSPHERE_ENGINE_DB_USERNAME="niksphere_admin"
export NIKSPHERE_ENGINE_DB_PASSWORD="securepassword123"
export NIKSPHERE_ENGINE_DB_NAME="niksphere_prod"

# Security & Identity
export NIKSPHERE_ENGINE_IDP_TOKEN_EXPIRY_HOURS="12"
bash
# Server Configuration
export NIKSPHERE_ENGINE_HTTP_PORT="3000"
export NIKSPHERE_ENGINE_HTTP_BASE_URL="https://engine.company.internal"
export NIKSPHERE_ENGINE_TRUSTED_PROXIES="10.0.0.0/8,192.168.0.0/16"

# Database Configuration (PostgreSQL)
export NIKSPHERE_ENGINE_DB_DRIVER="postgres"
export NIKSPHERE_ENGINE_DB_HOST="db.company.internal"
export NIKSPHERE_ENGINE_DB_PORT="5432"
export NIKSPHERE_ENGINE_DB_USERNAME="niksphere_admin"
export NIKSPHERE_ENGINE_DB_PASSWORD="securepassword123"
export NIKSPHERE_ENGINE_DB_NAME="niksphere_prod"

# Security & Identity
export NIKSPHERE_ENGINE_IDP_TOKEN_EXPIRY_HOURS="12"
sh
# Server Configuration
NIKSPHERE_ENGINE_HTTP_PORT=3000
NIKSPHERE_ENGINE_HTTP_BASE_URL=https://engine.company.internal
NIKSPHERE_ENGINE_TRUSTED_PROXIES=10.0.0.0/8,192.168.0.0/16

# Database Configuration (PostgreSQL)
NIKSPHERE_ENGINE_DB_DRIVER=postgres
NIKSPHERE_ENGINE_DB_HOST=db.company.internal
NIKSPHERE_ENGINE_DB_PORT=5432
NIKSPHERE_ENGINE_DB_USERNAME=niksphere_admin
NIKSPHERE_ENGINE_DB_PASSWORD=securepassword123
NIKSPHERE_ENGINE_DB_NAME=niksphere_prod

# Security & Identity
NIKSPHERE_ENGINE_IDP_TOKEN_EXPIRY_HOURS=12

Example 2: Configuration Files (config.yaml / config.json / config.toml)

yaml
http_port: "3000"
http_base_url: "http://localhost:3000"
trusted_proxies:
  - "10.0.0.0/8"
  - "192.168.0.0/16"

db_driver: "postgres"
db_host: "localhost"
db_port: "5432"
db_username: "niksphere"
db_password: "secretpassword"
db_name: "nikspheredb"

idp_token_expiry_hours: "24"
idp_refresh_token_expiry_days: "30"
json
{
  "http_port": "3000",
  "http_base_url": "http://localhost:3000",
  "trusted_proxies": [
    "10.0.0.0/8",
    "192.168.0.0/16"
  ],
  "db_driver": "postgres",
  "db_host": "localhost",
  "db_port": "5432",
  "db_username": "niksphere",
  "db_password": "secretpassword",
  "db_name": "nikspheredb",
  "idp_token_expiry_hours": "24",
  "idp_refresh_token_expiry_days": "30"
}
toml
http_port = "3000"
http_base_url = "http://localhost:3000"
trusted_proxies = ["10.0.0.0/8", "192.168.0.0/16"]

db_driver = "postgres"
db_host = "localhost"
db_port = "5432"
db_username = "niksphere"
db_password = "secretpassword"
db_name = "nikspheredb"

idp_token_expiry_hours = "24"
idp_refresh_token_expiry_days = "30"