Domainatrix LogoDomainatrix

Environment Configuration

A complete guide to configuring your Domainatrix environment variables, alerts, and external APIs.

Domainatrix uses environment variables for configuration. When self-hosting, these variables can be set in a .env file at the root of the project (if running locally or via PM2) or defined under the environment section of your docker-compose.yml.


📋 Environment Variables Reference

Here is a list of all variables used by the application:

VariablePurposeExample/DefaultRequirement
NODE_ENVRunning modeproductionRecommended
PORTLocal server port8765Optional (default: 3000)
HOSTNAMELocal server host bind0.0.0.0Optional (default: 0.0.0.0)
DB_FILE_NAMEPath to SQLite database/app/data/domainatrix.sqliteOptional (default: ./data/domainatrix.sqlite)
CRON_SECRETToken for securing background tasksSee guide belowRequired for automations
NOTIFICATION_WEBHOOK_URLWebhook URL for Discord or SlackSee guide belowOptional
SMTP_HOSTOutgoing mail server hostsmtp.example.comOptional (for email alerts)
SMTP_PORTOutgoing mail server port587Optional (default: 587)
SMTP_SECUREEnable SSL/TLS (Port 465)falseOptional
SMTP_USERSMTP username / loginalerts@example.comOptional
SMTP_PASSSMTP password / app passwordmy-app-passwordOptional
NOTIFICATION_EMAIL_FROMName & Email sender headerDomainatrix <alerts@example.com>Optional
NOTIFICATION_EMAIL_TOEmail address where alerts goadmin@example.comOptional
CRUX_API_KEYGoogle Chrome UX Report API KeySee guide belowOptional (enables PageSpeed)

🔑 Generating a CRON_SECRET

The CRON_SECRET is a private password that prevents random people from triggering your background monitoring. It is verified when your cron scheduler calls Domainatrix endpoints.

To generate a secure key, run the following command in your terminal:

openssl rand -hex 32

This output is a random string (e.g., 8d2f7823ab...). Copy and paste this string as the value for CRON_SECRET in your .env or docker-compose.yml file.


💬 Setting up Discord or Slack Webhooks

Webhooks are simple links provided by chat platforms that let other applications send messages to your channels. Setting one up is fast and free.

For Discord

  1. Open Discord and go to the channel where you want Domainatrix alerts to appear.
  2. Click the Edit Channel (gear icon) next to the channel name.
  3. Click on the Integrations tab in the sidebar.
  4. Click Webhooks, then click New Webhook.
  5. Give the bot a name (e.g., "Domainatrix") and copy the URL by clicking Copy Webhook URL.
  6. Set the NOTIFICATION_WEBHOOK_URL variable to this URL:
    NOTIFICATION_WEBHOOK_URL=https://discord.com/api/webhooks/...

For Slack

  1. Open the Slack App Directory and search for "Incoming WebHooks", or go to api.slack.com/apps.
  2. Create a new app or configure an incoming webhook for your workspace.
  3. Choose the channel you want notifications posted to and click Add Incoming WebHooks Integration.
  4. Copy the Webhook URL shown on the configuration page.
  5. Set the NOTIFICATION_WEBHOOK_URL variable to this URL:
    NOTIFICATION_WEBHOOK_URL=https://hooks.slack.com/services/...

✉️ Setting up SMTP Email Notifications

If you do not want to use a Discord or Slack channel, you can configure Domainatrix to send alerts to an email address.

[!NOTE] Webhook delivery is preferred. If you define a NOTIFICATION_WEBHOOK_URL, the application will use the webhook and skip sending emails. To enable email alerts, make sure NOTIFICATION_WEBHOOK_URL is empty or commented out.

Here is a guide to configure common providers:

For Custom Mail Servers (e.g. Fastmail, Mailgun, SendGrid)

Fill in your host's information directly:

SMTP_HOST=smtp.fastmail.com
SMTP_PORT=587
SMTP_SECURE=false
SMTP_USER=your_email@fastmail.com
SMTP_PASS=your_app_password
NOTIFICATION_EMAIL_FROM="Domainatrix <your_email@fastmail.com>"
NOTIFICATION_EMAIL_TO=admin@example.com

For Gmail

Due to Google security standards, standard account passwords will not work. You must use an App Password:

  1. Go to your Google Account settings.
  2. Select Security from the left-hand menu.
  3. Enable 2-Step Verification (if not already enabled).
  4. Under "How you sign in to Google", select App passwords.
  5. Create a new app password (name it "Domainatrix") and copy the generated 16-character code.
  6. Configure your environment:
    SMTP_HOST=smtp.gmail.com
    SMTP_PORT=587
    SMTP_SECURE=false
    SMTP_USER=your_gmail@gmail.com
    SMTP_PASS=abcd-efgh-ijkl-mnop   # Paste the 16-character app password here (without spaces)
    NOTIFICATION_EMAIL_FROM="Domainatrix <your_gmail@gmail.com>"
    NOTIFICATION_EMAIL_TO=admin@example.com

📈 Getting a Chrome UX Report (CrUX) API Key

Domainatrix can pull real-world performance metrics (Core Web Vitals) for your domains directly from the Chrome User Experience Report (CrUX) and display them right on your domain details page.

  1. Go to the Google AI Studio / Google Cloud Console.
  2. Create a new project or select an existing one.
  3. In the APIs & Services library, search for and enable the Chrome UX Report API.
  4. Navigate to Credentials and click Create Credentials -> API Key.
  5. Copy your new API key and paste it as the value for CRUX_API_KEY:
    CRUX_API_KEY=AIzaSy...
  6. Once configured, a new tab or section showing LCP (Largest Contentful Paint), CLS (Cumulative Layout Shift), and INP (Interaction to Next Paint) will automatically appear under each domain's detail page!

On this page