Getting Started with DBKnox

This guide walks you from zero to a running DBKnox instance with a connected database and your first AI SQL query in under 10 minutes.

Using DBKnox Cloud?

If you're using the hosted platform at app.dbknox.com, skip to Connect your first database. Installation only applies to self-hosted deployments.

1. Prerequisites

Before you begin, make sure the following are installed and running on your system:

Requirement Minimum version Notes
Node.js≥ 24.14.0Use nvm to manage versions
npm≥ 10.0.0Bundled with Node.js
PostgreSQL≥ 14DBKnox's own metadata database
Redis≥ 7.0Sessions, queues, rate limiting
GitanyTo clone the repository

You'll also need an AI provider API key for SQL Chat (at least one of AWS Bedrock, OpenAI, Anthropic, or HuggingFace). AI SQL Chat does not function without a configured provider.

2. Installation

Clone the DBKnox repository and install dependencies for both the backend and frontend workspaces.

Clone the repository

# Clone
git clone https://github.com/dbknox/dbknox.git
cd dbknox

Install backend dependencies

cd backend
npm install

Install frontend dependencies

cd ../frontend
npm install

Tip — Workspaces

If the repository uses npm workspaces, you can run npm install from the repository root to install all packages in a single step.

3. Environment Variables

DBKnox is configured entirely through environment variables. Copy the example files and fill in your values:

cp backend/.env.example backend/.env
cp frontend/.env.example frontend/.env

Required backend variables

DATABASE_URL

PostgreSQL connection string for DBKnox's own metadata database (not your application databases). Format: postgresql://user:password@host:5432/dbknox

DATABASE_URL=postgresql://dbknox_user:secret@localhost:5432/dbknox
REDIS_URL

Redis connection URL for sessions, BullMQ queues, and rate limiting counters.

REDIS_URL=redis://localhost:6379
JWT_SECRET

Secret key for signing JWT access and refresh tokens. Use a cryptographically random string of at least 64 characters.

# Generate with: node -e "console.log(require('crypto').randomBytes(64).toString('hex'))"
JWT_SECRET=your_64_char_random_secret_here
ENCRYPTION_KEY

AES-256-GCM key for encrypting database credentials at rest. Must be exactly 32 bytes (64 hex characters). Never commit this value to version control.

# Generate with: node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
ENCRYPTION_KEY=your_32_byte_hex_key_here
PORT

Port the backend API server listens on. Defaults to 3000.

PORT=3000

AI provider keys (at least one required)

# OpenAI (bring your own API key)
OPENAI_API_KEY=sk-...

# Anthropic (bring your own API key)
ANTHROPIC_API_KEY=sk-ant-...

# AWS Bedrock (uses IAM role or access keys)
AWS_REGION=us-east-1
AWS_ACCESS_KEY_ID=AKIA...
AWS_SECRET_ACCESS_KEY=...

# HuggingFace (Inference API token)
HUGGINGFACE_API_TOKEN=hf_...

⚠ Security note

Never commit .env files to Git. Add **/.env to your .gitignore. In production, inject secrets via AWS Secrets Manager or your CI/CD platform's secret store.

Frontend variables

# URL of the backend API
VITE_API_URL=http://localhost:3000/api/v1

# WebSocket URL for AI SQL Chat streaming
VITE_WS_URL=ws://localhost:3000

4. Run Migrations

DBKnox uses a migration system to set up its PostgreSQL schema. Run the migrations before starting the app for the first time — and after every update that includes schema changes.

cd backend
npm run migrate:up

This creates all required tables, indexes, and seed data including the system health check definitions.

Rolling back

To roll back the last migration batch: npm run migrate:down. To reset entirely: npm run migrate:reset (destructive — only use in development).

5. Start the App

Start the backend API server and frontend dev server in separate terminals:

Terminal 1 — Backend

cd backend
npm run dev

The backend starts on http://localhost:3000. You should see output confirming the database connection, Redis connection, and BullMQ workers initialising.

Terminal 2 — Frontend

cd frontend
npm run dev

The frontend starts on http://localhost:5173 (Vite default). Open this URL in your browser.

Verify the API is healthy

curl http://localhost:3000/health/live
# → {"status":"ok"}

curl http://localhost:3000/health/ready
# → {"status":"ok","db":"connected","redis":"connected"}

6. Connect Your First Database

With the app running, navigate to http://localhost:5173 and complete registration. Then follow these steps to connect your first database:

  1. 1

    Open the Databases panel

    In the left sidebar, click Databases, then click Add database in the top right.

  2. 2

    Select your engine

    Choose from PostgreSQL, MySQL, MSSQL, or Oracle. The connection form adapts to the selected engine.

  3. 3

    Enter connection details

    Fill in the host, port, database name, username, and password. For SSL, select the appropriate mode (require recommended for production databases).

    # Example PostgreSQL connection details
    Host:     db.yourapp.com
    Port:     5432
    Database: production_db
    Username: dbknox_readonly
    Password: ••••••••
    SSL mode: require
  4. 4

    Test the connection

    Click Test connection. DBKnox attempts a connection, validates the engine type, and returns a health summary. Fix any errors before saving.

  5. 5

    Save the database

    Click Add database. DBKnox encrypts the connection string using AES-256-GCM and stores it. The credential is now retrievable only by DBKnox's backend — never exposed in the UI or API responses.

Tip — Least privilege

Create a dedicated read-only database user for DBKnox queries. Grant SELECT on the schemas you want to query. For health checks, some system views require additional grants — see the engine-specific permission guides.

7. Send Your First AI SQL Query

With a database connected, open the AI SQL Chat panel from the left sidebar and select your database.

Configure your AI provider first

Go to Settings → AI Provider and enter your API key for the provider you want to use. Click Save. The provider is now active for your tenant.

Send a query

Type a question in the chat input and press Enter:

AI Chat — production_db
How many users registered in the last 7 days?

Here's the query:

SELECT COUNT(*) AS new_users
FROM users
WHERE created_at >= NOW() - INTERVAL '7 days';
Low risk ·0.1s·1 row

What happens next

High-risk query example

If you ask "Delete all test users", DBKnox generates the DELETE statement but flags it as High risk. A confirmation modal appears and you must type the confirmation phrase before execution. This cannot be bypassed.

8. Next Steps

Now that your first database is connected and you've sent your first query, explore these areas next: