Skip to main content

Environment Variables

Energy CMMS uses environment variables for configuration. Copy .env.example to .env and adjust the values:
cp .env.example .env

Core Django Settings

DEBUG Mode

DJANGO_DEBUG=False
Never enable DEBUG in production! Set DJANGO_DEBUG=False for production environments. Debug mode exposes sensitive information and impacts performance.

Secret Key

SECRET_KEY=your-secret-key-here-change-in-production
Generate a secure secret key:
python -c "from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())"

Allowed Hosts

ALLOWED_HOSTS=your-domain.com,subdomain.example.com,*.coolify.io
Comma-separated list of domains allowed to access your application. Use * for local development only.

CSRF Trusted Origins

CSRF_TRUSTED_ORIGINS=https://your-domain.com,https://subdomain.example.com
Required for form submissions from specific domains. Must include the protocol (https:// or http://).

Database Configuration

PostgreSQL Connection

DATABASE_URL=postgresql://username:password@host:5432/database_name
Format: postgresql://[user]:[password]@[host]:[port]/[database] Configuration Details:
  • Connection pooling: Max age 600 seconds (10 minutes)
  • Health checks: Enabled
  • SSL mode: Disabled by default (use ?sslmode=require for SSL)
  • Connection timeout: 20 seconds (production), 10 seconds (development)
  • Keepalive settings: Enabled with 30s idle, 10s interval, 5 retries
For Coolify deployments, the DATABASE_URL is automatically provided by the platform. Use the service name (e.g., postgres-service) as the host for internal communication.

Local Development Database

For local development, you can use port tunneling:
DATABASE_URL=postgresql://postgres:[email protected]:5434/postgres

Celery Configuration

Redis Broker

CELERY_BROKER_URL=redis://redis:6379/0
For Docker Compose, use redis://redis:6379/0. For local development with external Redis:
CELERY_BROKER_URL=redis://localhost:6379/0
Or with authentication:
CELERY_BROKER_URL=redis://default:password@host:6379/0

Result Backend

CELERY_RESULT_BACKEND=django-db
Task results are stored in Django’s database using django-celery-results. Celery Settings:
  • Task time limit: 30 minutes
  • Broker connection timeout: 3 seconds
  • Socket timeout: 3 seconds
  • Connection retry: Enabled on startup

Storage Configuration (MinIO/S3)

AWS/MinIO Credentials

AWS_ACCESS_KEY_ID=your-access-key
AWS_SECRET_ACCESS_KEY=your-secret-key
AWS_STORAGE_BUCKET_NAME=energia-media
AWS_S3_ENDPOINT_URL=http://minio:9000

Development vs Production

Local Development:
AWS_S3_ENDPOINT_URL=http://181.115.47.107:9000
# Direct IP access without custom domain
Production (Coolify):
AWS_S3_ENDPOINT_URL=http://minio-service:9000
# Internal service name for container communication
Energy CMMS uses MinIO (S3-compatible) for media storage with proxy support to avoid SSL/CORS issues. In production, media files are served through /media-proxy/.
Storage Configuration:
  • Region: us-east-1 (default)
  • Signature version: s3v4
  • File overwrite: Disabled (preserves original files)
  • Addressing style: path (critical for MinIO compatibility)
  • SSL verification: Disabled for internal MinIO

Site URLs

Public Site URL

SITE_URL=https://your-domain.com
Public URL for accessing the application.

Internal Site URL

INTERNAL_SITE_URL=http://django-service:8000
Internal URL for container-to-container communication (e.g., n8n calling Django webhooks).
For Coolify deployments, use the internal service name provided by Coolify (format: http://[uuid]:8000) for INTERNAL_SITE_URL to ensure proper inter-container communication.

n8n Integration (Optional)

Webhook URLs

# n8n base URL
N8N_BASE_URL=http://n8n:5678

# Document processing webhooks
N8N_WEBHOOK_URL=http://n8n:5678/webhook/nuevo-documento
N8N_CHAT_WEBHOOK_URL=http://n8n:5678/webhook/chat-documento
N8N_EXTRACT_TEXTO_WEBHOOK_URL=http://n8n:5678/webhook/extract-text
N8N_PROCESS_DOCUMENT_WEBHOOK_URL=http://n8n:5678/webhook/process-document
N8N_SOLICITUD_WEBHOOK_URL=http://n8n:5678/webhook/solicitud-material
Local Development:
N8N_BASE_URL=http://181.115.47.107:5678
N8N_WEBHOOK_URL=http://181.115.47.107:5678/webhook-test/nuevo-documento

AI Configuration (Optional)

Google Gemini API

GEMINI_API_KEY=your-gemini-api-key-here
Required for:
  • Semantic document search using embeddings
  • AI-powered chat functionality
  • Automated document analysis
Get your API key from Google AI Studio.
Without a GEMINI_API_KEY, the system will start but AI features (semantic search, document chat) will not be available.

Microsoft Dynamics 365 Integration (Optional)

DYNAMICS_TENANT_ID=your-tenant-id
DYNAMICS_CLIENT_ID=your-client-id
DYNAMICS_CLIENT_SECRET=your-client-secret
DYNAMICS_RESOURCE_URL=https://your-org.crm.dynamics.com
Required for integrating with Microsoft Dynamics 365 CRM.

Application Settings (settings.py)

Localization

Energy CMMS is configured for Honduras:
LANGUAGE_CODE = 'es-hn'  # Spanish (Honduras)
TIME_ZONE = 'America/Tegucigalpa'
USE_I18N = True
USE_TZ = True
Number Formatting:
  • Decimal separator: . (point)
  • Thousand separator: , (comma)
  • Currency: Lempiras (HNL)

File Upload Limits

DATA_UPLOAD_MAX_MEMORY_SIZE = 10 * 1024 * 1024   # 10 MB
FILE_UPLOAD_MAX_MEMORY_SIZE = 50 * 1024 * 1024   # 50 MB
DATA_UPLOAD_MAX_NUMBER_FIELDS = 100000
These limits prevent memory exhaustion from large file uploads and support bulk import operations.

Installed Applications

Core modules included:
  • core: Base functionality and UI overrides
  • activos: Asset management
  • mantenimiento: Maintenance management (work orders, procedures, schedules)
  • inventarios: Inventory and material management
  • presupuestos: Budget and requisition management
  • documentos: Document management with AI-powered search
  • proyectos: Project and activity management
  • callcenter: Ticket and service request management
  • comunicaciones: Mail and transmittal system
  • plantillas: Word template system
  • seguridad: Safety management (incidents, inspections, permits)
  • almacen: Warehouse management
  • auditorias: Audit trails
  • servicios: Service management

Security Settings

Proxy Configuration

SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
USE_X_FORWARDED_HOST = True
USE_X_FORWARDED_PORT = True
Configured for reverse proxies (Nginx, Traefik, Coolify).

CORS

CORS_ALLOW_ALL_ORIGINS = True  # Development only
For production, restrict CORS to specific origins by setting CORS_ALLOWED_ORIGINS instead of CORS_ALLOW_ALL_ORIGINS.

X-Frame Options

X_FRAME_OPTIONS = 'SAMEORIGIN'
Allows embedding admin interface in iframes from the same origin (for modals and popups).

Logging Configuration

Default logging setup:
LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        'verbose': {
            'format': '{levelname} {asctime} {module} {process:d} {thread:d} {message}',
            'style': '{',
        },
        'simple': {
            'format': '{levelname} {message}',
            'style': '{',
        },
    },
    'handlers': {
        'console': {
            'level': 'INFO',
            'class': 'logging.StreamHandler',
            'formatter': 'simple',
        },
    },
    'loggers': {
        'django': {
            'handlers': ['console'],
            'level': 'INFO',
            'propagate': True,
        },
    },
}
Logs are written to stdout/stderr and captured by Docker/Coolify.

Periodic Tasks (Celery Beat)

Automated scheduled tasks:
CELERY_BEAT_SCHEDULE = {
    'sync-document-embeddings-every-minute': {
        'task': 'documentos.tasks.sync_document_embeddings',
        'schedule': 60.0,  # Every 60 seconds
    },
}
Processes new documents and generates AI embeddings for semantic search.

Environment Detection

The application automatically detects the environment:
IS_LOCAL = DEBUG and not os.environ.get('COOLIFY_FQDN')
  • Local: DJANGO_DEBUG=True and no COOLIFY_FQDN
  • Production: COOLIFY_FQDN is present or DEBUG=False
This affects:
  • Database connection settings
  • MinIO/S3 endpoints
  • n8n webhook URLs
  • Cache backend selection

Configuration Examples

DJANGO_DEBUG=True
SECRET_KEY=dev-secret-key-not-for-production
ALLOWED_HOSTS=*
DATABASE_URL=postgresql://postgres:admin123@localhost:5432/energia_db
CELERY_BROKER_URL=redis://localhost:6379/0
CELERY_RESULT_BACKEND=django-db
AWS_S3_ENDPOINT_URL=http://localhost:9000
GEMINI_API_KEY=your-api-key

Verification

After configuration, verify settings:
# Check configuration is loaded
python manage.py check

# Test database connection
python manage.py migrate --check

# Verify static files configuration
python manage.py collectstatic --dry-run

# Test Celery connection
celery -A energia inspect ping

Next Steps

First Steps

Start using Energy CMMS

Deployment

Deploy to production

Build docs developers (and LLMs) love