# Self-hosting

Kipivo uses a Web service, an API service, and PostgreSQL.

Set the same private `REDIS_URL` on each API replica to deliver live updates to open personal and team boards. A member can save a task on one replica and collaborators on another receive the change. PostgreSQL stores the tasks and determines who can read them. Without Redis, open boards check for changes every 15 seconds.

## Docker

Build the images from the repository root so Docker can access the workspace lockfile and shared assets. Follow the [authentication guide](https://github.com/kipivo/kipivo/blob/next/docs/auth.md#docker-and-railway) to run Web and API containers with PostgreSQL. Find build commands and image smoke tests for [Web and Docs](https://github.com/kipivo/kipivo/blob/next/docs/testing.md#web-and-docs-production-image-smoke-tests), the [API](https://github.com/kipivo/kipivo/blob/next/docs/testing.md#api-production-image-smoke-test), and the [gateway](https://github.com/kipivo/kipivo/blob/next/docs/testing.md#gateway-production-image-smoke-test).

## Background work and file limits

Authentication email and file cleanup resume from PostgreSQL after a restart. With Redis enabled, grant the API publish and subscribe access to `kipivo:jobs:v1:*` and `kipivo:board:v1:*`. Workers also poll the database if a wake-up is missed.

Each account has 1 GiB of file space by default. Set `FILE_QUOTA_BYTES` to the same positive byte count on all API replicas to change the limit. Files shows storage usage and space reserved by uploads. The limit for a single file is 25 MiB.

Set a random `METRICS_TOKEN` on the API to enable Prometheus scraping. Send it as a Bearer token to `GET /metrics` on each replica's private address. The endpoint reports board notification health, background job outcomes and queue age. The public gateway keeps this endpoint private.

## Railway

Create an empty Railway project named `kipivo` and grant the Railway GitHub App access to `kipivo/kipivo`. Install [Railway CLI](https://docs.railway.com/cli) 5.42.1 or newer. Run the following commands from the repository root and select the project's `next` environment when linking.

```sh
bun install --frozen-lockfile
railway login
railway link
railway config plan
```

Review the plan, then run `railway config apply`. The [Railway configuration](https://github.com/kipivo/kipivo/blob/next/.railway/railway.ts) declares gateway, Web, API, Docs, PostgreSQL, and Redis services. It connects services over the private network and enables **Wait for CI** for services deployed from `next`. Follow the [resource guide](https://github.com/kipivo/kipivo/blob/next/docs/resources.md#railway) to configure optional S3-compatible storage.

Keep the existing Web and API public domains while deploying the gateway as a separate service. The [routing guide](https://github.com/kipivo/kipivo/blob/next/docs/architecture.md#web-and-public-api) explains domain routing and upstream settings. Railway checks `/docs` before switching Docs traffic. Check the gateway itself at `/gateway-healthz`.

## Optional homepage analytics

Both services are disabled by default. To measure signed-out visits to the public homepage (`/`), set `VITE_CLOUDFLARE_ANALYTICS_TOKEN` for Cloudflare performance metrics or `VITE_UMAMI_WEBSITE_ID` for Umami visits and referrals. Pass the values as Docker build arguments or configure them on Railway's `web` service before rebuilding. If you use Cloudflare, select **Enable with JS Snippet installation** in its Web Analytics settings.

## Configure and verify the instance

1. Connect the API to PostgreSQL and apply the database migrations.
2. Configure `AUTH_URL` with the public Web origin and set `AUTH_SECRET` on the API. Follow the [authentication deployment guide](https://github.com/kipivo/kipivo/blob/next/docs/auth.md#docker-and-railway) for the exact settings.
3. Check Web at `/healthz` and API readiness at `/readyz`. Open the Web origin to create the first administrator.

Use the [service smoke tests](https://github.com/kipivo/kipivo/blob/next/docs/testing.md#verify-running-services) to verify a production deployment.

Use the Web origin when configuring [Mobile](/docs/mobile) or calling the [public API](/docs/api-reference).
