Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/LENINMORENO13/OpsMind/llms.txt

Use this file to discover all available pages before exploring further.

OpsMind is configured entirely through environment variables — there are no config files to edit and no database rows to seed before first run. At startup, the Express application reads variables from the process environment (populated either by a .env file via dotenv or by the container runtime), applies them to the database connection, the JWT signing layer, and the Gemini AI client, and then begins serving requests. This approach makes OpsMind straightforward to deploy in any environment: local Docker Compose, a managed container platform like Render, or a bare VM.

Environment File Reference

Copy .env.example to .env at the project root and fill in your values:
.env
# Servidor Express
PORT=3000

# Conexión a la Base de Datos (Prisma)
DATABASE_URL="postgresql://postgres:TU_CONTRASEÑA_AQUÍ@localhost:5432/opsmind_db?schema=public"

# Gemini AI (Análisis inteligente de incidentes)
GEMINI_API_KEY=tu_api_key_aqui
Never commit .env to source control. Your .gitignore should include .env to prevent accidentally exposing your database credentials and API keys. The repository ships with .env.example as a safe, secret-free template — commit changes to that file instead.

Variable Reference

PORT
number
default:"3000"
The TCP port that Express listens on. Defaults to 3000 when the variable is absent. If you change this locally, update the port mapping in docker-compose.yml to match (e.g. "4000:4000").
DATABASE_URL
string
required
The full PostgreSQL connection string consumed by Prisma. The expected format is:
postgresql://USER:PASSWORD@HOST:PORT/DB?schema=public
SegmentDocker Compose valueLocal (non-Docker) value
USERlenin_devYour PostgreSQL user
PASSWORDpassword123Your PostgreSQL password
HOSTdb (Compose service name)localhost
PORT5432 (internal container port)5432 (or your custom port)
DBopsmind_dbYour database name
When running inside Docker Compose, the database host must be db — the service name defined in docker-compose.yml — not localhost. Docker Compose injects the correct value automatically (see below), so the DATABASE_URL in your .env is only used when running the application outside of Docker.
JWT_SECRET
string
required
The secret key used by jsonwebtoken to sign and verify all JWT tokens. Any string works, but you should use a long, randomly generated value in production (at least 32 characters). If this value changes, all previously issued tokens are immediately invalidated.Generate a strong secret with:
Terminal
node -e "console.log(require('crypto').randomBytes(48).toString('hex'))"
GEMINI_API_KEY
string
required
Your Google Gemini API key, used by the @google/genai SDK to generate AI-powered incident analyses and remediation suggestions. Obtain a free key from Google AI Studio.When this variable is missing or invalid, health checks still run normally, but the AIInsight records will not be generated for detected incidents.

Docker Compose Environment

The docker-compose.yml file defines two services — db (PostgreSQL) and api (the OpsMind Express application) — and injects environment variables directly into the api container, overriding anything in .env:
docker-compose.yml
services:
  db:
    image: postgres:15-alpine
    container_name: opsmind-postgres
    restart: always
    environment:
      POSTGRES_USER: lenin_dev
      POSTGRES_PASSWORD: password123
      POSTGRES_DB: opsmind_db
    ports:
      - "5433:5432"
    volumes:
      - db_data:/var/lib/postgresql/data

  api:
    build: .
    container_name: opsmind-api
    restart: always
    ports:
      - "3000:3000"
    depends_on:
      - db
    environment:
      JWT_SECRET: "mi_secreto_super_bloqueado_2026"
      DATABASE_URL: "postgresql://lenin_dev:password123@db:5432/opsmind_db?schema=public"
      GEMINI_API_KEY: "${GEMINI_API_KEY}"

volumes:
  db_data:
Key points to note:
  • DATABASE_URL is hardcoded in the Compose file to use db:5432 as the host, which is the correct internal Docker network address for the db service. Do not change this unless you rename the service.
  • JWT_SECRET is hardcoded in the Compose file for local development convenience. Replace this value with a secret loaded from a secrets manager or CI/CD environment variable before deploying to production.
  • GEMINI_API_KEY uses ${GEMINI_API_KEY} interpolation — Docker Compose reads the value from your local shell environment or your .env file at the project root and injects it into the container. This means your API key is never hardcoded in the repository; you only need to set it once in .env.
To override GEMINI_API_KEY without editing .env, export it in your shell before running Compose:
Terminal
export GEMINI_API_KEY=your_actual_key_here
docker compose up --build

Cron Check Interval

OpsMind’s health check worker is defined in src/services/scheduler.js and is started automatically when the server boots (in non-test environments). The worker uses the following node-cron expression:
src/services/scheduler.js
cron.schedule("*/5 * * * *", async () => {
  // Fetches all monitors from the database and runs executeMonitorCheck for each
});
The expression */5 * * * * fires every 5 minutes. On each tick the scheduler queries all Monitor records from PostgreSQL and calls executeMonitorCheck for every entry, recording a new Log and — when warranted — triggering a Gemini AI analysis.
The 5-minute interval is currently hardcoded in src/services/scheduler.js. To change the frequency, edit the cron expression string directly in that file. The Monitor model also stores a checkInterval field (default 300 seconds) which is intended for per-monitor interval configuration in a future release.

Test Environment Behaviour

When NODE_ENV is set to test, the Express server does not bind to a port and the cron scheduler does not start. This is enforced by a guard in src/app.js:
src/app.js
if (process.env.NODE_ENV !== "test") {
  const PORT = process.env.PORT || 3000;
  app.listen(PORT, () => {
    console.log(`Servidor corriendo en el puerto ${PORT}`);
    startCronJobs();
  });
}
The npm test script uses cross-env NODE_ENV=test to set this flag automatically, allowing Jest and Supertest to import the app object directly and run requests in-process — no port conflicts, no background timers interfering with test assertions.

Build docs developers (and LLMs) love