---
title: Run it locally
description: Start Postgres, the server, the daemon and the desktop app on your own computer.
sidebar:
  order: 2
---

You need Rust (the repo's `rust-toolchain.toml` asks for the stable channel with rustfmt and clippy, and the workspace needs 1.85 or newer), Docker for Postgres, and Node 22 for the desktop app. On Linux you also need the system libraries Tauri builds against.

**Linux packages**

This is the list CI installs on Ubuntu:

```bash
sudo apt-get install -y --no-install-recommends   libwebkit2gtk-4.1-dev libgtk-3-dev libsoup-3.0-dev libjavascriptcoregtk-4.1-dev   libayatana-appindicator3-dev librsvg2-dev libgtk-layer-shell-dev patchelf   libclang-dev libxcb1-dev libxrandr-dev libdbus-1-dev libpipewire-0.3-dev   libwayland-dev libegl-dev libgbm-dev
```

## Start the server

1. **Copy the example settings**

    ```bash
    cp .env.example .env
    ```
    The server reads `.env` on startup. The file is git-ignored.

2. **Start Postgres**

    ```bash
    docker compose up -d
    ```
    That's `postgres:17-alpine` on `127.0.0.1:5432` with user, password and database all set to `hindsight`, which is what `DATABASE_URL` in `.env.example` points at.

3. **Run the server**

    ```bash
    cargo run -p hindsight-server
    ```
    It runs its own migrations, then listens on `BIND_ADDR` (`127.0.0.1:8080` in `.env.example`). Check it with `curl http://localhost:8080/health`.

Without `HCA_CLIENT_ID` and `HCA_CLIENT_SECRET` the server still starts, but `/auth/login` answers 503 and you can't sign in. To sign in locally, make a Hack Club Auth app with the redirect URI `http://localhost:8080/auth/callback` and put its id and secret in `.env`. [Self-hosting](/docs/developers/self-hosting#hack-club-sign-in) has the details.

A debug build of the server reads the files in `website/` from disk on every request, so edits to the landing page show up on reload. A release build has them baked in.

## Start the daemon

In a second terminal:

```bash
cargo run -p hindsight-daemon -- run
```

A plain `cargo build` of the daemon signs in at `http://localhost:8080`. Set `HINDSIGHT_SERVER_URL` to point it somewhere else. Then link the computer to your account:

```bash
cargo run -p hindsight-daemon -- login
```

It prints a link and a code like `ABCD-EFGH`, and opens the link in your browser. Approve it there. The code is good for 15 minutes. Use `--no-browser` over SSH.

Other commands worth knowing:

```bash
cargo run -p hindsight-daemon -- status --verify   # what's collected, plus a full hash-chain check
cargo run -p hindsight-daemon -- sync              # upload right now instead of waiting for the minute loop
cargo run -p hindsight-daemon -- presence          # print the focused app and idle time, record nothing
```

### Keep it apart from your installed copy

If you also run the installed app, give your development daemon its own port and data directory so the two don't fight over either:

```powershell
$env:HINDSIGHT_PORT = "5293"
$env:HINDSIGHT_DATA_DIR = "$env:TEMP\hindsight-dev"
cargo run -p hindsight-daemon -- run
```

These are the settings the daemon reads:

| Variable | What it does |
|---|---|
| `HINDSIGHT_SERVER_URL` | Where `login` sends you and where uploads go. Defaults to `http://localhost:8080` for a plain build. |
| `HINDSIGHT_PORT` | The local API port. Default 5292. It always binds to `127.0.0.1`. |
| `HINDSIGHT_DATA_DIR` | Where `hindsight.db`, `local-token` and `device.json` live. The default is the per-user data folder for `org.hackclub.hindsight`. |
| `HINDSIGHT_AGENT_APPS` | Comma-separated app names that count as "the agent's window". Replaces the built-in list. |
| `HINDSIGHT_GIT_HOOK` | Set to `off` and the daemon stops adding a `post-commit` hook to repos on its own. |
| `RUST_LOG` | Log filter. The daemon defaults to `hindsight_daemon=info`. |

:::warning[Don't run `connect` from a debug build by accident]
`hindsight-daemon connect` writes the path of the binary it's running into your Claude Code, Codex, Cursor and other tools' configs. From `target/debug` that leaves your real tools pointing at a development build. `hindsight-daemon disconnect` takes it back out. The desktop app's dev build avoids the problem: it connects your tools with the installed app's daemon when there is one.
:::

## Start the desktop app

```bash
cd apps/desktop
npm ci
npm run tauri dev
```

This serves the Svelte frontend on `http://localhost:1420` and opens the app around it. A dev build doesn't start a daemon for you, so keep the one from the last step running. The app finds it through `HINDSIGHT_PORT` and `HINDSIGHT_DATA_DIR`, the same variables the daemon reads.

Frontend checks:

```bash
npm run check   # svelte-check
npm run build   # also needed before cargo build/clippy: Tauri embeds the built frontend
```

## Run the tests

```bash
cargo test --workspace
```

The server's integration tests need Postgres. Point `DATABASE_URL` at the container from above and each test run creates a throwaway database, so your dev data stays untouched. Without `DATABASE_URL` those tests print a notice and pass.

```bash
DATABASE_URL=postgres://hindsight:hindsight@localhost:5432/hindsight cargo test --workspace
```

The two TypeScript adapters have their own tests:

```bash
cd adapters/vscode && npm ci && npm test
cd adapters/opencode && npm ci && npm test
```

## Build an installer

`node scripts/build-installer.mjs` builds the daemon, packages the VS Code extension and bundles the desktop app for your operating system. To make an installer that signs in at your own server, add `--server https://hindsight.example.com`. [Releasing](/docs/developers/releasing#build-one-by-hand) covers what it does.
