Skip to content

Configuration

Both parts are configured through environment variables. Nothing secret belongs in files that are committed or baked into images.

  • Backend: environment variables, read by Settings in src/middleware_forge/config.py (pydantic-settings; names are case-insensitive). For local runs, .env in the repository root (and then in the working directory) is read too; start from .env.example. The container reads deploy/backend.env; start from deploy/backend.env.example.
  • Web UI: ASP.NET Core configuration: appsettings.json for defaults, overridden by environment variables such as ForgeApi__BaseUrl (double underscore for nesting).

Blank values (NAME=) count as "not set". At startup the backend validates the configuration and refuses to start with a list of every problem (see Startup validation).

Backend

LLM

Variable Default Meaning
OPENAI_API_BASE – Base URL of the OpenAI-compatible endpoint, e.g. http://llm.internal:1234/v1. Leave empty to use OpenAI itself.
OPENAI_API_KEY not-needed Key for the endpoint, if it needs one
LLM_MODEL gpt-4o Model name. With a custom base URL, a name without a LiteLLM provider prefix is sent through openai/.
LLM_JSON_MODE off How structured replies are requested: json_schema (vLLM, LM Studio, OpenAI), json_object, or off (prompt instructions only). The examples set json_schema.
LLM_TEMPERATURE 0.1 Sampling temperature
LLM_REQUEST_TIMEOUT 120 Seconds per LLM call
LLM_MAX_RETRIES 2 Critique-and-revise attempts when the LLM fallback produces an XML artifact (attempts = this + 1)
LLM_TRANSPORT_RETRIES 0 HTTP retries inside LiteLLM. Keep 0; retries are handled by the generator.
FORGE_READY_CHECK_LLM false Make /health/ready also call the endpoint's /models

Security and network

Variable Default Meaning
FORGE_ENV development (production in the image) production requires FORGE_API_KEY and an LLM endpoint
FORGE_API_KEY – Shared secret required as X-Forge-Api-Key on every route except /health*. At least 16 characters.
FORGE_CORS_ORIGINS – Comma-separated browser origins. Keep empty: browsers never call the backend. * is rejected.
FORGE_FORWARDED_ALLOW_IPS 127.0.0.1 Proxies whose X-Forwarded-* headers are trusted
FORGE_CA_BUNDLE – PEM bundle of internal certificate authorities, used for the LLM, git and pull-request calls
SSL_VERIFY true false disables certificate checks for every HTTPS call. Development only; a warning is logged.

Storage and retention

Variable Default Meaning
FORGE_DATA_DIR DEFAULT_OUTPUT_DIR (/data in the image) Root of all data: state/ (SQLite), uploads/, runs/, workspaces/, tmp/
DEFAULT_OUTPUT_DIR ./output Data root when FORGE_DATA_DIR is not set (local development)
FORGE_RETENTION_DAYS 30 Finished runs, their artifacts and idle sessions are deleted after this many days; 0 keeps everything
FORGE_RETENTION_INTERVAL_SECONDS 3600 How often retention runs (minimum 60)
RUN_TTL_SECONDS 3600 Finished runs leave the in-memory cache after this long; they reload from the database on access
UPLOAD_MAX_FILES 10 Files per upload request
UPLOAD_MAX_BYTES 10485760 Bytes per file (10 MB)

Generation

Variable Default Meaning
TEMPLATE_DIR template/{project_name} in the repository OSB templates: proxy, pipeline and route fragments, business service, base pipeline, Resources/Schemas/CommonSchema.xsd
EXAMPLE_DIR example/OSB/TravelService Reference project shown to the LLM fallback as examples
COMMON_SCHEMA_PATH TEMPLATE_DIR/Resources/Schemas/CommonSchema.xsd Shared schema copied into every OSB project
COMMON_NAMESPACE http://www.moi.gov.ae/common Namespace of the shared schema, used in the base pipeline, the copied CommonSchema.xsd and generated schemas
FORGE_DOCX_TEMPLATE – Corporate Word template; its styles (Title, Heading 1–3, Table Grid) are used for the technical design document
FORGE_ICD_TEMPLATE TEMPLATE_DIR/../docs/ICD-template.docx Interface Control Document template, also used for the consumer guides (structure)
FORGE_DOCS_ENVIRONMENTS – Environments listed in ICD endpoint tables and OpenAPI servers: Name=URL pairs separated by commas, e.g. Staging=https://esb-stg.example.com,Production=https://esb.example.com. Empty means one Default environment at FORGE_DOCS_OSB_URL.
FORGE_DOCS_OSB_URL http://localhost:7001 OSB server URL written into the generated Postman environment and SoapUI project, and the default documentation environment

Repository write-back

Variable Default Meaning
FORGE_REPOS – JSON list of allow-listed repositories (below)
FORGE_GIT_AUTHOR_NAME Middleware Forge Commit author
FORGE_GIT_AUTHOR_EMAIL middleware-forge@localhost Commit author e-mail
FORGE_GIT_TIMEOUT_SECONDS 120 Timeout of each git command

FORGE_REPOS lists the only repositories users can write to. Users pick one by id; they never send URLs or paths.

Field Required Meaning
id yes 1–64 letters, digits, _ or -
provider yes azure_devops_server, github, git (push a branch, no pull request) or local (a mounted folder, no git)
url git providers Clone URL, e.g. https://ado.internal/tfs/DefaultCollection/Integration/_git/osb-services. A local bare repository path works for tests.
path local Absolute folder inside the container
name no Display name; defaults to the repository name
base_branch no Default main
subpath no Folder for the OSB projects inside the repository, e.g. OSB
username no User name sent with the token (default forge)
token_env / token_file git providers Environment variable or mounted file holding the token; read at use time
api_version Azure DevOps REST API version: Azure DevOps Server 2019 → 5.0, 2020 and later → 6.0 (default)
api_url GitHub Enterprise API root, e.g. https://github.internal/api/v3
reviewers no Reviewer ids added to the pull request
FORGE_REPOS=[{"id":"osb","provider":"azure_devops_server","url":"https://ado.internal/tfs/DefaultCollection/Integration/_git/osb-services","base_branch":"main","subpath":"OSB","token_file":"/run/secrets/ado-pat","api_version":"6.0"}]

The service account needs Code: Read & Write and Contribute to pull requests on the repository.

Logging and tracing

Variable Default Meaning
FORGE_LOG_LEVEL INFO Log level
FORGE_LOG_FORMAT text (json in the image) json writes one object per line with request_id, session_id and run_id
LANGSMITH_TRACING false Send LangGraph and LLM traces to LangSmith (only when SSL_VERIFY is on)
LANGSMITH_API_KEY, LANGSMITH_PROJECT –, middleware-forge LangSmith credentials and project

Server

Variable Default Meaning
TIMEOUT_KEEP_ALIVE 180 uvicorn keep-alive; event streams need more than the 5-second default
TIMEOUT_GRACEFUL_SHUTDOWN 30 Seconds to finish requests on shutdown

Docker Compose variables

These are read by docker-compose.yml from your shell or a .env next to it, not by the application.

Variable Default Meaning
FORGE_BIND_ADDRESS 127.0.0.1 Host address the API port is published on; use the internal address the IIS server can reach
FORGE_PORT 8000 Published host port
FORGE_IMAGE_TAG local Image tag to build or run
FORGE_VOLUME_NAME middleware-forge-data Named volume for /data

Startup validation

startup.check_configuration runs when the API starts. It stops the server with every error at once and logs warnings:

Check Error Warning
Storage A data folder is not writable –
Templates An OSB template file is missing CommonSchema.xsd not found
Security No API key in production; key shorter than 16; missing CA bundle or Word template file; * in CORS No API key in development; SSL_VERIFY=false in production
LLM No endpoint or key in production No endpoint or key in development
Repositories Invalid FORGE_REPOS; a local folder does not exist An HTTPS repository without a token

Web UI

Setting (environment variable) Default Meaning
ForgeApi__BaseUrl http://127.0.0.1:8000 Backend URL as seen from the web server
ForgeApi__ApiKey – Must equal the backend's FORGE_API_KEY. Set it on the IIS application pool, never in a file.
ForgeApi__MaxUploadBytes 10485760 Per-file upload limit in the browser; keep it at or below UPLOAD_MAX_BYTES
DataProtection__KeysPath – Folder for Data Protection keys, so circuits survive app-pool recycles. Shared by all servers of a web farm.
ASPNETCORE_ENVIRONMENT Production on IIS Production enables HSTS and the generic error page

HTTP calls to the backend use a resilience pipeline: retries only for safe methods, 120 seconds per attempt and 300 seconds in total. The session event stream has no timeout and reconnects with exponential backoff (up to 15 seconds).