FactoryFactory

Configuration

This document provides comprehensive information about configuring the ManufactAI Factory application through environment variables. Proper configuration is critical for system functionality.

Configuration Overview

ManufactAI Factory is configured primarily through environment variables that are passed to the Docker containers. These environment variables control all aspects of the application's behavior, from database connections to authentication methods.

Environment Variables Reference

Core Application Parameters

ParameterDescriptionDefaultRequiredEffect
PORTPort the API server listens on8080YesChanges the port where the API service runs
APP_URLPublic URL of the frontend applicationNoneYesUsed for generating links in emails and redirects

Database Configuration

ParameterDescriptionDefaultRequiredEffect
DB_URIMongoDB connection stringNoneYesRequired for connecting to the MongoDB database

S3 Storage Configuration

ParameterDescriptionDefaultRequiredEffect
S3_ENDPOINT_URLURL of the S3-compatible storage serviceNoneYesSpecifies the connection endpoint for S3 operations
S3_ACCESS_KEYAccess key for S3 authenticationNoneYesRequired for authenticating with the S3 service
S3_SECRET_KEYSecret key for S3 authenticationNoneYesRequired for authenticating with the S3 service
S3_BUCKETName of the S3 bucket to use"factory"YesDetermines where files are stored in S3
S3_REGIONAWS region for S3 operations"eu-central-1"NoRequired for AWS S3 services, optional for other S3-compatible services
S3_PATH_PREFIXPrefix for all paths in the S3 bucket""NoAdds a prefix to all object keys in S3, useful for organizing data
S3_UPLOAD_EXPIRES_INExpiration time for upload URLs in seconds3600 (1 hour)NoControls how long presigned upload URLs remain valid
S3_DOWNLOAD_EXPIRES_INExpiration time for download URLs in seconds3600 (1 hour)NoControls how long presigned download URLs remain valid

Security and Licensing

ParameterDescriptionDefaultRequiredEffect
SECRET_KEYSecret key for token generationGeneratedYesUsed to sign JWTs and secure cookies, should be changed in production
LICENSE_KEYLicense key for the installationNoneYesRequired for activating the software

CORS Configuration

ParameterDescriptionDefaultRequiredEffect
ALLOW_ORIGINSList of allowed origins for CORS["*"]NoControls which domains can access the API
ALLOW_METHODSList of allowed HTTP methods for CORS["*"]NoControls which HTTP methods can be used with the API
ALLOW_HEADERSList of allowed HTTP headers for CORS["*"]NoControls which HTTP headers can be sent to the API
EXPOSE_HEADERSList of headers exposed to the client["X-Total-Count", etc.]NoControls which headers the client can read from API responses

SMTP Email Configuration

ParameterDescriptionDefaultRequiredEffect
SMTP_HOSTHostname of the SMTP serverNoneYes*Required for sending emails
SMTP_PORTPort of the SMTP server587Yes*Required for connecting to the SMTP server
SMTP_USERUsername for SMTP authenticationNoneYes*Required for authenticating with the SMTP server
SMTP_PASSWORDPassword for SMTP authenticationNoneYes*Required for authenticating with the SMTP server
SMTP_MAILEmail address used as the senderNoneYes*Sets the "From" address in sent emails

*Required if email functionality is needed (user registration, password reset, notifications)

Single Sign-On Configuration

ParameterDescriptionDefaultRequiredEffect
SSO_ENABLEDMaster switch to enable/disable SSOfalseNoWhen false, all SSO providers are disabled
SSO_DISABLE_EMAIL_LOGINFlag to disable email/password loginfalseNoWhen true, only SSO authentication is allowed

For detailed SSO configuration, see the Authentication Guide.

Performance Tuning

ParameterDescriptionDefaultRequiredEffect
GUNICORN_WORKERSNumber of worker processes4NoDetermines how many parallel requests can be processed
GUNICORN_WORKER_CONNECTIONSMaximum number of connections per worker1000NoLimits the number of concurrent connections per worker
GUNICORN_TIMEOUTWorker timeout in seconds120NoWorkers exceeding this time are terminated and restarted
GUNICORN_KEEPALIVEKeep-alive timeout in seconds5NoHow long to keep idle connections open
GUNICORN_LOG_LEVELLog level for Gunicorn logs"info"NoControls verbosity of server logs
GUNICORN_MAX_REQUESTSMaximum number of requests per worker1000NoWorkers are restarted after handling this many requests
GUNICORN_MAX_REQUESTS_JITTERRandom jitter added to max requests50NoPrevents all workers from restarting simultaneously

Configuration Best Practices

Security Recommendations

  1. Use Strong Secrets

    • Generate a strong random value for SECRET_KEY
    • Use complex passwords for database and S3 access
    • Never use default or example credentials in production
  2. Restrict Access

    • Configure ALLOW_ORIGINS to only include trusted domains
    • Use firewalls to restrict access to your MongoDB and S3 services
    • Enable HTTPS for all external communication
  3. Regular Updates

    • Keep your Factory installation up to date with the latest security patches
    • Regularly rotate credentials, especially for S3 and database access

Performance Optimization

  1. Worker Configuration

    • Set GUNICORN_WORKERS to (2 × CPU cores) + 1 for optimal performance
    • Adjust GUNICORN_WORKER_CONNECTIONS based on expected concurrent users
  2. Database Indexing

    • Monitor database performance and adjust resources as needed
  3. Resource Allocation

    • Provide sufficient CPU and memory resources to the Factory containers
    • Consider using dedicated hosts for MongoDB and S3 storage in high-load scenarios