Skip to content

Quickstart

This guide gets the full stack (web app, API, worker and PostgreSQL storage) running with Docker Compose, then connects a database and starts an agent for it.

  • Docker with the Compose plugin (docker compose)
  • openssl (or any other way to generate 32 random bytes)
  • A PostgreSQL 12+ database to observe. The bundled PostgreSQL works for evaluation.
  1. Get the code and create an environment file. The repository becomes available when the source is published; the URL below is a placeholder until then.

    Terminal window
    git clone https://github.com/your-org/querypilot.git
    cd querypilot
    cp .env.example .env
  2. Set the encryption key. QueryPilot encrypts stored database credentials with this key (AES-256-GCM). It is required; the API refuses to start without it.

    Terminal window
    openssl rand -base64 32

    Paste the output into .env:

    .env
    QUERYPILOT_ENCRYPTION_KEY=<paste the generated key>
  3. Start the stack.

    Terminal window
    docker compose up -d --build

    This starts postgres, api, worker and web. The API applies database migrations on startup, so there is no separate migration step.

  4. Open the app at http://localhost:3000. The API listens on http://localhost:8080 and serves its OpenAPI description at http://localhost:8080/api/docs.

  1. Prepare the database: enable pg_stat_statements and create a least-privilege role. See PostgreSQL prerequisites. The bundled postgres service already preloads and creates pg_stat_statements.

  2. In the web app, go to Databases → Add database and enter host, port, database name, username, password and SSL mode.

  3. Click Test connection. The API connects with the credentials, without saving them, and returns a capability checklist with a remediation for anything missing.

  4. Save. The password is encrypted at rest and never returned by the API.

The agent is what collects telemetry. It runs next to the database it observes and only makes outbound connections.

  1. Open the database’s page and, under Agents, click Create agent.

  2. Copy the token. It is shown once. The panel also shows a ready-to-run docker run command and the environment variables the agent needs.

  3. Run the agent. Pick whichever matches your setup:

    The Compose file has an opt-in agent service that talks to the API over the Compose network:

    Terminal window
    QUERYPILOT_AGENT_TOKEN='<token>' \
    QUERYPILOT_TARGET_DATABASE_URL='postgres://querypilot:querypilot@postgres:5432/querypilot' \
    docker compose --profile agent up -d agent
  4. Within a heartbeat (30 seconds by default) the agent shows as ONLINE. Query statistics are collected every 15 seconds; the overview and the query explorer fill in as samples arrive.

To work on QueryPilot itself, run the apps from source.

Requirements: Node.js 20.11+, pnpm 9.15, Docker (for the development PostgreSQL).

Terminal window
pnpm install
cp .env.example .env # set QUERYPILOT_ENCRYPTION_KEY
pnpm dev:setup # start PostgreSQL, build, migrate, seed
pnpm dev # API, worker and web with hot reload

pnpm dev:setup runs pnpm dev:db && pnpm build && pnpm db:migrate && pnpm db:seed. The agent is not part of pnpm dev; start it separately once you have a token:

Terminal window
# QUERYPILOT_API_URL, QUERYPILOT_AGENT_TOKEN and QUERYPILOT_TARGET_DATABASE_URL in .env
pnpm --filter @querypilot/agent dev

Other useful scripts:

Command What it does
pnpm dev:all Run every app, including the agent, in watch mode
pnpm lint / pnpm typecheck ESLint and TypeScript across the monorepo
pnpm test Unit tests (Vitest)
pnpm test:integration Integration tests
pnpm db:migrate / pnpm db:seed Apply migrations / create the default organization and project
pnpm docker:up / pnpm docker:down Start / stop the Compose stack