> ## Documentation Index
> Fetch the complete documentation index at: https://docs.moneyline.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Self-Hosting

> Run Moneyline on your own infrastructure.

## Docker Compose (Recommended)

The fastest way to get a full Moneyline stack running.

### Prerequisites

* Docker Engine 24+
* Docker Compose v2
* 4GB+ RAM

### Quick Start

```bash theme={null}
git clone https://github.com/paragonhq/moneylined.git
cd moneylined

cp .env.example .env
# Edit .env with your configuration

# Infrastructure only — Postgres + Redis, for running the apps locally
docker compose up -d

# Or the full stack, including the API, worker, and ML service
docker compose --profile full up -d
```

The compose file lives at the repository root. `docker compose up -d` starts
only the infrastructure; the application services sit behind the `full` profile
so you can run the apps from source against containerized dependencies.

| Service | Profile | Port | Purpose |
| - | - | - | - |
| `postgres` | default | 5433 → 5432 | PostgreSQL 16 |
| `redis` | default | 6379 | Cache, rate limiting, and the BullMQ queue |
| `api` | `full` | 3000 | Fastify API server |
| `worker` | `full` | — | BullMQ consumer for background jobs |
| `ml` | `full` | 3001 | Python ML service |

BullMQ needs no container of its own — the `worker` process is the consumer and
connects to the `redis` service.

Useful shortcuts are wired up as root scripts:

```bash theme={null}
bun run docker:up          # infra only
bun run docker:full        # infra + api + worker, rebuilding images
bun run docker:logs        # tail logs
bun run docker:psql        # psql into the postgres container
bun run docker:reset       # tear down, including volumes
```

## Kubernetes

### Prerequisites

* Kubernetes 1.28+
* `kubectl` configured
* Ingress controller (nginx-ingress recommended)

### Deploy

```bash theme={null}
cd deploy/k8s

# Create namespace
kubectl apply -f namespace.yaml

# Deploy services
kubectl apply -f deployment-api.yaml
kubectl apply -f deployment-ml.yaml
kubectl apply -f service.yaml
kubectl apply -f ingress.yaml
```

### Configuration

Set environment variables via ConfigMap or Secrets:

```yaml theme={null}
apiVersion: v1
kind: Secret
metadata:
  name: moneyline-secrets
  namespace: moneyline
data:
  DATABASE_URL: <base64-encoded>
  API_KEY_ENCRYPTION_KEY: <base64-encoded>
  BETTER_AUTH_SECRET: <base64-encoded>
  R2_ACCESS_KEY_ID: <base64-encoded>
  R2_SECRET_ACCESS_KEY: <base64-encoded>
```

## Single Binary

For simple deployments, the API can run as a standalone Bun process:

```bash theme={null}
# Install deps (workspace-aware)
bun install

# Run migrations
bun run db:migrate

# Build + start
bun run turbo build --filter @moneyline/api
bun apps/api/dist/server.js
```

Requires an external PostgreSQL database, Redis instance, and an
S3-compatible object store (Cloudflare R2, AWS S3, Backblaze B2, or
MinIO).

## Environment Variables

| Variable | Required | Default | Description |
| - | - | - | - |
| `DATABASE_URL` | Yes | — | PostgreSQL connection string |
| `REDIS_URL` | No | `redis://localhost:6379` | Redis connection string |
| `BETTER_AUTH_SECRET` | Yes | — | 32+ char secret (`openssl rand -base64 32`) |
| `BETTER_AUTH_URL` | No | `http://localhost:3000` | Base URL of the API |
| `BETTER_AUTH_TRUSTED_ORIGINS` | No | localhost | Comma-separated origin allowlist |
| `API_KEY_ENCRYPTION_KEY` | Yes | — | 32-char encryption key |
| `R2_ENDPOINT` | Yes | — | S3-compatible endpoint (e.g. R2 account URL) |
| `R2_ACCESS_KEY_ID` | Yes | — | Object storage access key |
| `R2_SECRET_ACCESS_KEY` | Yes | — | Object storage secret |
| `R2_DOCUMENTS_BUCKET` | No | `moneyline-documents` | Docs bucket |
| `R2_EXPORTS_BUCKET` | No | `moneyline-exports` | Exports bucket |
| `PORT` | No | `3000` | API server port |
| `HOST` | No | `0.0.0.0` | API server host |
| `LOG_LEVEL` | No | `info` | Log level (debug, info, warn, error) |
| `CORS_ORIGIN` | No | `*` | CORS allowed origins |

## Health Check

```bash theme={null}
curl http://localhost:3000/v1/health
```

Returns:

```json theme={null}
{
  "status": "ok",
  "version": "0.1.0",
  "services": {
    "database": "connected",
    "redis": "connected",
    "ml": "connected"
  }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.