# Production readiness (https://docs.ctxpipe.ai/docs/self-hosting/production-readiness)

Use this checklist before you make a self-hosted deployment available to a team.
The reference Compose stack is a first draft. A production deployment must
define the network boundary, persistence, secrets, and rollback process.

## Public origin

ctxpipe expects a single public backend origin for browser, REST, auth, and MCP
traffic.

| Check                                                       | Why it matters                                                                                                       |
| ----------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
| `AUTH_BASE_URL` is the public HTTPS origin                  | Better Auth callbacks, generated links, OAuth issuer values, MCP auth, and connector callbacks depend on this value. |
| `CTXPIPE_PUBLIC_APP_URL` matches the public backend origin  | The UI uses this value at build time.                                                                                |
| Browser users enter through the backend                     | The backend proxies the UI, keeping auth and API requests on the same origin.                                        |
| `AUTH_ALLOWED_ORIGINS` includes only required extra origins | Avoid broad CORS allowances.                                                                                         |

## TLS and proxying

Put a TLS-terminating proxy or platform load balancer in front of the backend.
Expose only the backend origin publicly unless you have an operational
reason to expose other services.

| Service                                         | Public exposure                                                                                              |
| ----------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| `backend`                                       | Public HTTPS                                                                                                 |
| `ui`                                            | Private; backend proxy should serve it                                                                       |
| `worker`                                        | Private                                                                                                      |
| `codesearch`                                    | Private                                                                                                      |
| `postgres`                                      | Private                                                                                                      |
| `falkordb` or graph database                    | Private                                                                                                      |
| `clickhouse`                                    | Private                                                                                                      |
| `dind` (Docker Compose) or the AWS sandbox host | Private. Do not publish the Docker API or other unauthenticated services on a host that runs chat sandboxes. |

The Compose deploy profile binds `ui` (`3002`) and `codesearch` (`3001`) to
`127.0.0.1` only. Do not change them to all interfaces.

The backend refuses a webhook body above its limit with `413`. The limits are
25 MiB for GitHub, 5 MiB for Linear, Buildkite, and Plain, and 1 MiB for Slack,
Notion, PagerDuty, and Atlassian. If your proxy has a lower body limit, set it
to at least 25 MiB for `/api/v1/webhook/github`. Set it to 5 MiB for
`/api/v1/webhook/linear`, `/api/v1/webhook/buildkite/*`, and
`/api/v1/webhook/plain/*`.

Telemetry export is outbound only. There is no collector to expose. Set
`OTEL_EXPORTER_OTLP_*` to your own endpoint when you want traces, logs, or
metrics to leave the app containers.

## Callback URLs

Register callback and webhook URLs against your public origin.

| Integration                                | URL shape                                                     |
| ------------------------------------------ | ------------------------------------------------------------- |
| Atlassian OAuth                            | `{AUTH_BASE_URL}/api/v1/integrations/atlassian/callback`      |
| Linear OAuth                               | `{AUTH_BASE_URL}/api/v1/integrations/linear/callback`         |
| Linear webhook                             | `{AUTH_BASE_URL}/api/v1/webhook/linear`                       |
| GitHub App webhook                         | `{AUTH_BASE_URL}/api/v1/webhook/github/<connectionId>`        |
| Slack OAuth                                | `{AUTH_BASE_URL}/api/v1/connectors/slack/oauth/callback`      |
| Slack Events API                           | `{AUTH_BASE_URL}/api/v1/webhook/slack`                        |
| Notion OAuth                               | `{AUTH_BASE_URL}/api/v1/connectors/notion/oauth/callback`     |
| Notion webhook                             | `{AUTH_BASE_URL}/api/v1/webhook/notion?provisioningToken=...` |
| PagerDuty OAuth                            | `{AUTH_BASE_URL}/api/v1/integrations/pagerduty/callback`      |
| PagerDuty webhook                          | `{AUTH_BASE_URL}/api/v1/webhook/pagerduty`                    |
| Buildkite webhook                          | `{AUTH_BASE_URL}/api/v1/webhook/buildkite/<connectionId>`     |
| Plain webhook (ctxpipe creates the target) | `{AUTH_BASE_URL}/api/v1/webhook/plain/<connectionId>`         |
| MCP                                        | `{AUTH_BASE_URL}/mcp`                                         |
| App auth                                   | `/.auth/*` routes under `AUTH_BASE_URL`                       |

## Persistence

Do not treat the reference Compose volumes as disposable in production. On
Compose, mount named volumes for Postgres and FalkorDB before the first start.
See [Docker: Persistent state](/docs/self-hosting/deployment/docker#persistent-state).

| State                                     | Production expectation                                                                                                                                                                      |
| ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Postgres                                  | Managed backups, restore test, monitoring, and storage alerts                                                                                                                               |
| Graph database                            | Backup or snapshot according to provider guidance                                                                                                                                           |
| ClickHouse (`clickhouse_data` on Compose) | Backup for fast recovery, or a full rebuild from the Workspace repositories (see [Recover the knowledge store](/docs/self-hosting/configuration#recover-the-knowledge-store)). Disk alerts. |
| `repo_cache`                              | Persistent volume if recloning large repositories is expensive                                                                                                                              |
| `zoekt_index_deploy`                      | Persistent volume if rebuilding indexes is expensive                                                                                                                                        |
| Secrets                                   | Stored in a secret manager or platform secret store, not committed files                                                                                                                    |

## Codesearch capacity

Keep `codesearch` at **one replica**. Zoekt shards, git clone cache, and SCIP
artifacts are process-local. Extra worker replicas do not raise ingest
throughput unless codesearch memory and the injected
`OPENWORKFLOW_CONCURRENCY` / `CODESEARCH_INDEXER_CONCURRENCY` /
`CODESEARCH_INDEX_PIPELINE_CONCURRENCY` values also grow. Compose `deploy`
uses the small pair (indexer 1, pipelines 1, worker concurrency 6). AWS CDK
injects the matching pair for `small` / `medium` / `large`.

## Worker memory

The worker starts with a Node heap limit of about 55% of the memory its
container may use, up to 12 GiB. Native memory, Git, and the sandbox SDKs
use the rest. The AWS CDK worker task (1, 2, or 4 GiB for `small`, `medium`,
`large`) and a Compose host therefore get a limit that fits their memory. No
setting is needed.

To use another limit, set `--max-old-space-size=<MiB>` in `NODE_OPTIONS` on
the worker. The worker keeps your value. Keep it below the container memory.

The worker also starts with `--heapsnapshot-near-heap-limit=1` and
`--diagnostic-dir=/tmp/heap`. If the heap nears its limit, Node writes one
`.heapsnapshot` file to `/tmp/heap` before the process exits. The file is lost
when the container restarts, unless `/tmp/heap` is on a volume.

Writing the snapshot pauses the worker. It needs extra memory and disk space,
and the file can be larger than the heap. On a small task the write can fail,
and the platform can then stop the process. The result is the same crash as
without the snapshot. To turn the snapshot off, set
`--heapsnapshot-near-heap-limit=0` in `NODE_OPTIONS` on the worker.

The worker logs its heap limit at start (`heapLimitMib` in the
`openworkflow.config-loaded` line).

## Secret handling

Protect and rotate:

* `AUTH_SECRET`
* `CONNECTION_SECRETS_ENCRYPTION_KEY`, if set
* GitHub App private keys and webhook secrets
* Atlassian OAuth client secrets and Forge tokens
* Slack client secret, signing secret, and stored bot-token encryption material
* Linear OAuth client and webhook secrets, or the shared encryption key used to decrypt connection-stored Linear app secrets
* Notion OAuth client and webhook secrets
* Model provider API keys
* SMTP credentials
* OTLP exporter credentials

<Callout type="warn" title="Changing encryption secrets">
  `AUTH_SECRET` and `CONNECTION_SECRETS_ENCRYPTION_KEY` can affect sessions and
  encrypted connector credentials. Plan each rotation carefully. Verify the connectors that
  you have after the change.
</Callout>

## Connector readiness

Before inviting users:

* Create or configure at least one GitHub App connection.
* Confirm GitHub webhook delivery reaches the public backend origin.
* If you use Confluence, set up Atlassian OAuth and Forge install or
  provisioning.
* If you use Slack, set all three Slack app secrets. Verify the OAuth callback
  and the Events Request URL. When you need multi-workspace distribution, test
  the installation in a non-development workspace.
* If you use Linear, register a Linear OAuth application. Use the product UI,
  or `LINEAR_*` on the backend and the worker.
* Register the exact OAuth callback and webhook URLs.
* Confirm that the backend and the worker can reach `api.linear.app`.
* If you use Notion, set `NOTION_CLIENT_ID` and `NOTION_CLIENT_SECRET`. Register
  the exact OAuth redirect URL. Set `NOTION_WEBHOOK_SECRET` after the first
  webhook delivery.
* If you use PagerDuty, register the exact OAuth callback.
* Save the client ID and secret in the connector wizard. Or set
  `PAGERDUTY_CLIENT_ID` and `PAGERDUTY_CLIENT_SECRET` on the backend and the
  worker. ctxpipe creates the webhook subscription after authorization.
* If you use Buildkite, confirm that the backend and worker can reach
  `api.buildkite.com`. Confirm that the backend can reach
  `graphql.buildkite.com`, which the connect check uses.
* Confirm that the backend and the worker can reach `identity.pagerduty.com` and
  `api.pagerduty.com` or `api.eu.pagerduty.com`.
* If you use Plain, confirm that the backend and the worker can reach
  `core-api.uk.plain.com`. Plain posts webhooks only to a public HTTPS URL.
  Without one, Plain sources use the daily sync and **Sync now**.
* Confirm the worker can run connector jobs.
* Confirm `codesearch` can clone the expected repositories.
* Confirm model provider credentials work for both chat and embedding calls.

## Preflight checklist

* `curl https://<public-origin>/.status` returns JSON with `status: "ok"`.
* Sign-in works using the enabled auth method.
* A user can create or select an organization.
* A repository can be added and reaches indexed state.
* Chat or MCP can answer a question grounded in the repository.
* A Workspace chat answers in a sandbox, and `SANDBOX_PROVIDER` is not
  `unsandboxed`. See [Operations](/docs/self-hosting/operations) for the
  sandbox checks.
* Backend, worker, and codesearch logs are collected.
* Postgres and graph database backups are configured.
* Upgrade and rollback steps are written down for the current deployment shape.

## Related pages

<Cards>
  <Card title="Configuration" href="/docs/self-hosting/configuration" description="Environment variables and connector setup." />

  <Card title="Operations" href="/docs/self-hosting/operations" description="Logs, health, backups, and recovery." />

  <Card title="GitHub" href="/docs/self-hosting/github" description="Deployment-owned App registration, permissions, and webhooks." />

  <Card title="Confluence & Atlassian" href="/docs/self-hosting/confluence-atlassian" description="Atlassian callbacks, Forge, and sync." />

  <Card title="Slack" href="/docs/self-hosting/slack" description="Slack app scopes, app_mention Events, deployment secrets, and troubleshooting." />

  <Card title="Linear" href="/docs/self-hosting/linear" description="Linear OAuth, signed webhooks, and end-to-end verification." />

  <Card title="Notion" href="/docs/self-hosting/notion" description="Notion OAuth, webhook signing, and end-to-end verification." />

  <Card title="PagerDuty" href="/docs/self-hosting/pagerduty" description="PagerDuty OAuth, automatic webhooks, and end-to-end verification." />

  <Card title="Buildkite" href="/docs/self-hosting/buildkite" description="API access token, the webhook of each connection, and end-to-end verification." />
</Cards>
