Skip to content

Configuration Guide

This guide covers the configuration options and best practices for AIDDDMAP deployment.

Environment Variables

Core Settings

# Server Configuration
PORT=3000
NODE_ENV=production
API_URL=https://api.yourdomain.com
FRONTEND_URL=https://yourdomain.com

# Database
DATABASE_URL=postgresql://user:password@host:5432/dbname
DATABASE_POOL_SIZE=20
DATABASE_SSL=true

# Redis
REDIS_URL=redis://user:password@host:6379
REDIS_TLS=true

# Authentication
JWT_SECRET=your-secure-secret
JWT_EXPIRY=24h
REFRESH_TOKEN_EXPIRY=7d

# Encryption
ENCRYPTION_KEY=your-encryption-key
FHE_PARAMS_PATH=/path/to/fhe/params
ZK_PROVING_KEY=/path/to/zk/key

Feature Flags

# Enable/Disable Features
ENABLE_FHE=true
ENABLE_ZK_PROOFS=true
ENABLE_MARKETPLACE=true
ENABLE_AGENT_DEPLOYMENT=true

# Feature Limits
MAX_DATASET_SIZE=1000000
MAX_AGENTS_PER_USER=10
MAX_CONCURRENT_JOBS=5

Integration Settings

# External Services
S3_BUCKET=your-bucket-name
S3_REGION=us-west-2
AWS_ACCESS_KEY_ID=your-access-key
AWS_SECRET_ACCESS_KEY=your-secret-key

# Monitoring
SENTRY_DSN=your-sentry-dsn
DATADOG_API_KEY=your-datadog-key
PROMETHEUS_ENDPOINT=/metrics

Configuration Files

1. Application Config (config/app.json)

{
  "name": "AIDDDMAP",
  "version": "1.0.0",
  "logLevel": "info",
  "cors": {
    "origins": ["https://yourdomain.com"],
    "methods": ["GET", "POST", "PUT", "DELETE"],
    "allowedHeaders": ["Content-Type", "Authorization"]
  },
  "rateLimit": {
    "windowMs": 900000,
    "max": 1000
  }
}

2. Database Config (config/database.json)

{
  "production": {
    "ssl": true,
    "poolSize": 20,
    "idleTimeoutMillis": 30000,
    "connectionTimeoutMillis": 2000
  },
  "development": {
    "ssl": false,
    "poolSize": 10,
    "idleTimeoutMillis": 30000,
    "connectionTimeoutMillis": 2000
  }
}

3. Cache Config (config/cache.json)

{
  "ttl": 3600,
  "checkPeriod": 600,
  "maxItems": 1000,
  "updateAgeOnGet": true
}

Security Configuration

1. SSL/TLS Settings

# Example Nginx configuration
server {
    listen 443 ssl http2;
    server_name api.yourdomain.com;

    ssl_certificate /path/to/cert.pem;
    ssl_certificate_key /path/to/key.pem;
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers HIGH:!aNULL:!MD5;
}

2. CORS Configuration

// src/config/cors.ts
export default {
  origin: process.env.FRONTEND_URL,
  methods: ["GET", "POST", "PUT", "DELETE"],
  allowedHeaders: ["Content-Type", "Authorization"],
  credentials: true,
  maxAge: 86400,
};

3. Rate Limiting

// src/config/rateLimit.ts
export default {
  windowMs: 15 * 60 * 1000, // 15 minutes
  max: 1000, // limit each IP to 1000 requests per windowMs
  message: "Too many requests, please try again later.",
};

Logging Configuration

1. Winston Logger

// src/config/logger.ts
export default {
  level: process.env.LOG_LEVEL || "info",
  format: "json",
  transports: [
    {
      type: "file",
      filename: "logs/error.log",
      level: "error",
    },
    {
      type: "file",
      filename: "logs/combined.log",
    },
  ],
};

2. Audit Logging

{
  "auditLog": {
    "enabled": true,
    "storage": "database",
    "retention": "90d",
    "events": ["user.login", "data.access", "agent.deploy"]
  }
}

Performance Tuning

1. Node.js Settings

# Set in ecosystem.config.js for PM2
module.exports = {
  apps: [{
    name: 'aidddmap',
    script: 'dist/server.js',
    instances: 'max',
    exec_mode: 'cluster',
    max_memory_restart: '1G',
    node_args: [
      '--max-old-space-size=4096',
      '--optimize-for-size'
    ]
  }]
}

2. Database Optimization

{
  "pool": {
    "min": 2,
    "max": 20,
    "acquireTimeoutMillis": 30000,
    "createTimeoutMillis": 30000,
    "destroyTimeoutMillis": 5000,
    "idleTimeoutMillis": 30000,
    "reapIntervalMillis": 1000,
    "createRetryIntervalMillis": 200
  }
}

Monitoring Configuration

1. Health Checks

{
  "healthCheck": {
    "path": "/health",
    "interval": "30s",
    "timeout": "5s",
    "checks": [
      {
        "name": "database",
        "timeout": "3s"
      },
      {
        "name": "redis",
        "timeout": "2s"
      }
    ]
  }
}

2. Metrics Collection

{
  "metrics": {
    "enabled": true,
    "interval": "10s",
    "prefix": "aidddmap",
    "defaultLabels": {
      "service": "api",
      "environment": "production"
    }
  }
}

Deployment-Specific Configurations

1. Development

NODE_ENV=development
LOG_LEVEL=debug
ENABLE_SWAGGER=true

2. Staging

NODE_ENV=staging
LOG_LEVEL=info
ENABLE_MONITORING=true

3. Production

NODE_ENV=production
LOG_LEVEL=warn
ENABLE_MONITORING=true

Configuration Management

1. Version Control

  • Store configuration templates in version control
  • Use environment-specific overrides
  • Document all configuration changes

2. Security

  • Never commit sensitive values
  • Use secret management services
  • Rotate secrets regularly

3. Validation

  • Validate configuration at startup
  • Provide clear error messages
  • Include configuration in health checks

Next Steps

  1. Review environment setup
  2. Configure monitoring
  3. Implement security measures
  4. Set up maintenance procedures
  5. Plan for scaling

Support

Need help with configuration?