Configuration Guide

Configure AIM for your environment with flexible deployment options, from Docker Compose to Kubernetes, with support for both SDK and non-SDK integrations.

Configuration Methods

Docker Compose Configuration

Step 1: Environment Variables

Create a .env file in your project root:

# Database Configuration
POSTGRES_USER=aim_user
POSTGRES_PASSWORD=SecurePassword123!
POSTGRES_DB=aim_production
DATABASE_URL=postgresql://aim_user:SecurePassword123!@postgres:5432/aim_production

# Redis Configuration (Optional - for caching)
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_PASSWORD=RedisPassword123!

# JWT Configuration
JWT_SECRET=your-super-secret-jwt-key-min-32-chars
JWT_EXPIRY=15m
JWT_REFRESH_EXPIRY=7d

# Email Configuration (Optional)
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USER=noreply@example.com
SMTP_PASSWORD=app-specific-password
SMTP_FROM=AIM Platform <noreply@example.com>

# Security Configuration
BCRYPT_COST=12
API_RATE_LIMIT=1000
PUBLIC_RATE_LIMIT=100

# Environment
NODE_ENV=production
ENVIRONMENT=production
LOG_LEVEL=info

# CORS Configuration
ALLOWED_ORIGINS=http://localhost:3000,https://app.example.com

# Agent Configuration
AGENT_KEY_ROTATION_DAYS=90
AGENT_SESSION_TIMEOUT=30m
MAX_TRUST_SCORE=100
MIN_TRUST_SCORE=0

# MCP Server Defaults
MCP_AUTO_DETECT=true
MCP_VERIFY_SIGNATURES=true
MCP_TIMEOUT=30s

Step 2: Docker Compose File

version: '3.8'

services:
  postgres:
    image: postgres:16-alpine
    environment:
      - POSTGRES_USER=${POSTGRES_USER}
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
      - POSTGRES_DB=${POSTGRES_DB}
    volumes:
      - postgres_data:/var/lib/postgresql/data
    ports:
      - "5432:5432"
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER}"]
      interval: 10s
      timeout: 5s
      retries: 5

  redis:
    image: redis:7-alpine
    command: redis-server --requirepass ${REDIS_PASSWORD}
    ports:
      - "6379:6379"
    volumes:
      - redis_data:/data
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 10s
      timeout: 5s
      retries: 5

  backend:
    build:
      context: ./apps/backend
      dockerfile: Dockerfile
    environment:
      - DATABASE_URL=${DATABASE_URL}
      - REDIS_HOST=${REDIS_HOST}
      - REDIS_PORT=${REDIS_PORT}
      - REDIS_PASSWORD=${REDIS_PASSWORD}
      - JWT_SECRET=${JWT_SECRET}
      - NODE_ENV=${NODE_ENV}
    ports:
      - "8080:8080"
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_healthy
    volumes:
      - ./migrations:/app/migrations

  frontend:
    build:
      context: ./apps/web
      dockerfile: Dockerfile
    environment:
      - NEXT_PUBLIC_API_URL=http://localhost:8080
      - NODE_ENV=${NODE_ENV}
    ports:
      - "3000:3000"
    depends_on:
      - backend

volumes:
  postgres_data:
  redis_data:

Step 3: Start Services

# Start all services
docker compose up -d

# Check service status
docker compose ps

# View logs
docker compose logs -f backend

# Run database migrations (automatic on startup)
docker compose exec backend npm run migrate

Advanced Configuration Options

Database Tuning

# PostgreSQL optimization
max_connections = 200
shared_buffers = 256MB
effective_cache_size = 1GB
maintenance_work_mem = 128MB
work_mem = 4MB
wal_buffers = 16MB
checkpoint_completion_target = 0.9

Security Hardening

# Security settings
BCRYPT_ROUNDS=14
SESSION_TIMEOUT=15m
MAX_LOGIN_ATTEMPTS=5
LOCKOUT_DURATION=30m
FORCE_HTTPS=true
HSTS_MAX_AGE=31536000
CSP_ENABLED=true

Email Provider Setup

# SendGrid configuration
SMTP_HOST=smtp.sendgrid.net
SMTP_PORT=587
SMTP_USER=apikey
SMTP_PASSWORD=SG.xxxxxx
SMTP_FROM=noreply@aim.example.com

CDN & Proxy

# Nginx reverse proxy
upstream aim_backend {
  server backend:8080;
}

server {
  listen 443 ssl http2;
  server_name aim.example.com;

  ssl_certificate /etc/ssl/cert.pem;
  ssl_certificate_key /etc/ssl/key.pem;

  location /api {
    proxy_pass http://aim_backend;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
  }
}

Monitoring & Observability

Prometheus Metrics

# Enable metrics endpoint
METRICS_ENABLED=true
METRICS_PORT=9090
METRICS_PATH=/metrics

# Grafana dashboard available at:
# https://grafana.com/dashboards/aim-monitoring

Health Checks

# Health check endpoints
GET /health          # Basic health
GET /health/ready    # Readiness probe
GET /health/live     # Liveness probe
GET /api/v1/status   # Detailed status