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.
Requirements
Section titled “Requirements”- 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.
Run with Docker Compose
Section titled “Run with Docker Compose”-
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.gitcd querypilotcp .env.example .env -
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 32Paste the output into
.env:.env QUERYPILOT_ENCRYPTION_KEY=<paste the generated key> -
Start the stack.
Terminal window docker compose up -d --buildThis starts
postgres,api,workerandweb. The API applies database migrations on startup, so there is no separate migration step. -
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.
Connect a database
Section titled “Connect a database”-
Prepare the database: enable
pg_stat_statementsand create a least-privilege role. See PostgreSQL prerequisites. The bundledpostgresservice already preloads and createspg_stat_statements. -
In the web app, go to Databases → Add database and enter host, port, database name, username, password and SSL mode.
-
Click Test connection. The API connects with the credentials, without saving them, and returns a capability checklist with a remediation for anything missing.
-
Save. The password is encrypted at rest and never returned by the API.
Start an agent
Section titled “Start an agent”The agent is what collects telemetry. It runs next to the database it observes and only makes outbound connections.
-
Open the database’s page and, under Agents, click Create agent.
-
Copy the token. It is shown once. The panel also shows a ready-to-run
docker runcommand and the environment variables the agent needs. -
Run the agent. Pick whichever matches your setup:
The Compose file has an opt-in
agentservice 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 agentThe command generated by the UI looks like this (the password is always a placeholder):
Terminal window docker run -d --name querypilot-agent --restart unless-stopped \-e QUERYPILOT_API_URL='http://your-querypilot-host:8080' \-e QUERYPILOT_AGENT_TOKEN='<token>' \-e QUERYPILOT_TARGET_DATABASE_URL='postgres://querypilot:<password>@db.internal:5432/app' \querypilot/agent:latestThe image name is what the API prints; build it yourself from
infrastructure/docker/agent.Dockerfileif you are not pulling a published image. -
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.
Development setup
Section titled “Development setup”To work on QueryPilot itself, run the apps from source.
Requirements: Node.js 20.11+, pnpm 9.15, Docker (for the development PostgreSQL).
pnpm installcp .env.example .env # set QUERYPILOT_ENCRYPTION_KEYpnpm dev:setup # start PostgreSQL, build, migrate, seedpnpm dev # API, worker and web with hot reloadpnpm 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:
# QUERYPILOT_API_URL, QUERYPILOT_AGENT_TOKEN and QUERYPILOT_TARGET_DATABASE_URL in .envpnpm --filter @querypilot/agent devOther 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 |