# Run your own hub

> Run the whole hub on one machine: database, storage, API and web. Also what a local hub lacks.

Prompt for your AI: Read https://mousemouse.ai/docs/self-host.md first. Help me run my own copy of the hub on this machine from a checkout of the source. Ask me before anything that costs money or moves a robot.

The hub is one FastAPI service, one Next.js app, a Postgres and an S3 API.
This page boots all four on one machine from a checkout of the source
repository. It is the same code a hosted hub runs. Use it for development, or
for a lab that wants its own hub. Every command here was tested on such a
local hub.

You need Docker, [uv](https://docs.astral.sh/uv/), Node ≥ 24 and the checkout.

## Boot a local hub

One command builds the whole thing: database, object storage, migrations, seed
data, the API on `:8000` and the web app on `:3000`.

```bash
make dev-local
```

Leave it running and open a second terminal for everything below. A Postgres
runs in Docker and the S3 API is [moto](https://docs.getmoto.org/), in memory.

It seeds repos under the org `lucen`: a robot card built from the real Lucen Biped
MJCF, a dataset, a policy, and one private repo so you can check that it stays
hidden. The dataset is **synthetic**, generated at seed time. The seeder says
so on every run and writes the warning into the repo's own README.

> The local S3 is in-memory. If you restart it without also resetting Postgres,
> the database will still hold blob rows whose bytes are gone and downloads
> will fail. `docker rm -f lucen-hub-pg && make dev-local` resets both.

## A key without a browser session

On a hub with sign-in, keys are created in **API keys**, which needs a
signed-in person. A key cannot create another key. A local stack has no
sign-in, so there is no session and no button. `tools/dev_api_key.py` makes a
key locally instead, and refuses any database that is not on localhost:

```bash
NEON_DATABASE_URL=postgresql://postgres:lucen@127.0.0.1:5433/lucen uv run --no-sync python tools/dev_api_key.py --user you --scopes train | lucen auth login --stdin --url http://127.0.0.1:8000
```

```
Signed in as you (scopes: read, write, train) at http://127.0.0.1:8000
Saved to /Users/you/.config/lucen/credentials (mode 0600)
```

From here every step of [Work from a terminal](/docs/from-a-terminal) works against
the local stack, with `http://127.0.0.1:8000` as the API and
`http://localhost:3000` as the web app.

## Install the clients from your own tree, or your own hub

The docs install `lucen`, `lucen-mcp` and `lucen-device` from PyPI, and those
releases work against a local stack. A checkout can be ahead of the release.
To run the CLI from the same tree as your hub, with the sim engine:

```bash
uv tool install --from "./packages/cli[rollout]" --with ./packages/sdk/py lucen-cli
```

A hub built from the API image also serves its own copy of the four client
packages, built from the hub's own commit. Its installer is for machines that
cannot reach PyPI: `curl -fsSL https://<your api>/install.sh | sh -s -- cli`
(also `device`, `mcp`, or an extra such as `"cli[rl]"`). It installs them from
the hub and points the CLI at it. A hub run from a checkout carries no wheels
and answers 404 there.

## What a local stack does not have

- **Sign-in.** Clerk is not set up, so the browser is always signed out.
  Public pages work. The [tutorial](/docs/first-policy)'s browser steps belong
  to an account, so they cannot be done from the page. These are adding a
  robot, training from its page, confirming a pairing and deploying.
- **The paid backends.** Lucen cloud training, sim tests and endpoints
  (`executor: modal`) answer 503 naming `MODAL_APP_NAME`. The Coach's diagnosis
  answers 503 without `ANTHROPIC_API_KEY`. Everything that runs on your own
  machine works: `lucen worker run`, `lucen rollout --local` and `lucen serve`.

Deploying a hub of your own to the cloud (Fly, Vercel, Neon, R2, Upstash,
Clerk) is described step by step in the repository's `docs/RUNBOOK.md`.
