Installation

Installation Guide

Step-by-step guide for installing and setting up SelfHostedDB

This guide walks you through installing SelfHostedDB on your system, whether you're using Docker, a cloud platform, or a local server.


Quick Start

Fastest way to get started (5 minutes):

# 1. Clone or download the project
git clone <repository-url>
cd db-tool-pgvista
 
# 2. Start with Docker Compose (includes PostgreSQL)
docker-compose up -d
 
# 3. Access the application
# Open http://localhost:3001 in your browser
# Default credentials: admin / secret

That's it! You now have a running SelfHostedDB with a test database.


Prerequisites

Required Software

  1. Docker (version 20.10 or higher)

    Verify installation:

    docker --version
    docker-compose --version
  2. PostgreSQL Database (version 12 or higher)

    • Can be local, remote, or cloud-hosted
    • Or use the bundled PostgreSQL in Docker Compose (recommended for testing)

Optional Software

  • Git (for cloning the repository)
  • Text Editor (for editing configuration files)

Installation Methods

Method 1: Docker Compose (Recommended for Beginners)

Best for: Quick setup, testing, development, single-server deployments

Steps:

  1. Download or clone the project:

    git clone <repository-url>
    cd db-tool-pgvista
  2. Configure environment variables (optional):

    # Copy the example file
    cp backend/env.example .env
     
    # Edit .env with your settings (or use defaults for testing)
    # DATABASE_URL=postgres://postgres:testpass@db:5432/postgres
    # AUTH_USER=admin
    # AUTH_PASS=secret
  3. Start the application:

    docker-compose up -d
  4. Verify it's running:

    docker-compose ps
    # You should see 'selfhosteddb-db' and 'selfhosteddb-app' running
  5. Access the application:

    • Open your browser: http://localhost:3001
    • Login with credentials from .env (default: admin / secret)

What this does:

  • Starts a PostgreSQL database container
  • Starts the application container
  • Connects them together
  • Persists database data in ./data directory

Stop the application:

docker-compose down

Stop and remove all data:

docker-compose down -v

Method 2: Docker Run (Using Existing Database)

Best for: Production deployments, using existing PostgreSQL instance

Steps:

  1. Pull or build the Docker image:

    # Option A: Pull from registry (if available)
    docker pull your-registry/selfhosteddb:latest
     
    # Option B: Build from source
    git clone <repository-url>
    cd db-tool-pgvista
    docker build -t selfhosteddb:latest .
  2. Run the container:

    docker run -d \
      --name selfhosteddb \
      --restart unless-stopped \
      -p 3001:3001 \
      -e DATABASE_URL="postgres://username:password@host:5432/database" \
      -e AUTH_USER="admin" \
      -e AUTH_PASS="your-strong-password" \
      -e NODE_ENV="production" \
      selfhosteddb:latest
  3. Verify it's running:

    docker ps | grep selfhosteddb
    docker logs selfhosteddb
  4. Access the application:

    • Open: http://localhost:3001 (or your server IP)
    • Login with your AUTH_USER and AUTH_PASS

Notes:

  • Replace host with your PostgreSQL hostname/IP
  • For local PostgreSQL: use host.docker.internal (Windows/Mac) or 172.17.0.1 (Linux)
  • For remote PostgreSQL: use the server's IP address or hostname

Method 3: Manual Installation (Development)

Best for: Developers who want to modify the code

Prerequisites:

  • Node.js 18+ installed
  • PostgreSQL 12+ running locally or remotely

Steps:

  1. Clone the repository:

    git clone <repository-url>
    cd db-tool-pgvista
  2. Install backend dependencies:

    cd backend
    npm install
  3. Configure backend:

    cp env.example .env
    # Edit .env with your database connection
  4. Start backend:

    npm run dev
    # Backend runs on http://localhost:3001
  5. Install frontend dependencies (in a new terminal):

    cd frontend
    npm install
  6. Start frontend:

    npm start
    # Frontend runs on http://localhost:3000
  7. Access the application:

    • Open: http://localhost:3000
    • The frontend will connect to the backend automatically

Configuration

Environment Variables

Required Variables:

VariableDescriptionExample
DATABASE_URLPostgreSQL connection stringpostgres://user:pass@host:5432/db
AUTH_USERAdmin username for loginadmin
AUTH_PASSAdmin password for loginyour-strong-password
LICENSE_SERVER_URLLicense server URL (for license validation)https://license.yourdomain.com

Optional Variables:

VariableDescriptionDefault
PORTServer port3001
NODE_ENVEnvironment modedevelopment
LICENSE_ENCRYPTION_KEYKey for encrypting local license cache (recommended for production)Not set

Database Connection String Format

postgres://username:password@hostname:port/database_name

Examples:

  • Local PostgreSQL:

    postgres://postgres:mypassword@localhost:5432/mydb
  • Remote PostgreSQL:

    postgres://user:pass@192.168.1.100:5432/production_db
  • Cloud PostgreSQL (with SSL):

    postgres://user:pass@db.example.com:5432/mydb?sslmode=require
  • Docker Compose (internal network):

    postgres://postgres:testpass@db:5432/postgres

Security Configuration

Change default credentials immediately:

# Generate a strong password
# Linux/Mac:
openssl rand -base64 32
 
# Windows PowerShell:
[Convert]::ToBase64String((1..32 | ForEach-Object { Get-Random -Minimum 0 -Maximum 256 }))

Update .env or environment variables:

AUTH_USER=my_admin_username
AUTH_PASS=your-generated-strong-password

First Run

Initial Setup

  1. Start the application (using your chosen method)

  2. Access the login page:

    • Open http://localhost:3001 (or your server address)
    • You should see the login screen
  3. Activate License or Start Trial:

    • Option A: Activate a purchased license
      • Enter your license key (received via email after purchase)
      • Enter the email address associated with your purchase
      • Click "Activate License"
    • Option B: Start a 14-day free trial
      • Enter your email address
      • Click "Start Free Trial"
      • You'll have full access for 14 days
  4. Login:

    • Enter your AUTH_USER and AUTH_PASS
    • Click "Login"
  5. Create your first project (schema):

    • Click "New Project" or "Create Schema"
    • Enter a schema name (e.g., my_project)
    • Enter a password for the schema user
    • Click "Create"
  6. Start using the application:

    • Browse tables in the "Tables" tab
    • Run queries in the "SQL Editor" tab
    • View schema relationships in the "Schema" tab

License Information

License Model:

  • Email-based activation - License is tied to the purchaser's email address
  • Unlimited deployments - Same owner can deploy on unlimited machines/platforms
  • Unlimited team members - No limit on who can access the deployed instance
  • Lifetime license - Pay once, use forever with free updates

Trial Period:

  • 14-day free trial with full feature access
  • No credit card required
  • Automatically converts to license after purchase

Sample Data (Optional)

Load sample data for testing:

# If using Docker Compose
docker exec -i selfhosteddb-db psql -U postgres < seed.sql
 
# If using local PostgreSQL
psql -U postgres -d your_database < seed.sql

This creates sample tables (users, posts, comments) with test data.


Verification

Health Check

Test if the application is running:

# Using curl
curl http://localhost:3001/api/health
 
# Expected response:
# {"status":"ok","timestamp":"2025-01-27T10:00:00.000Z"}

Using browser:

  • Open: http://localhost:3001/api/health
  • Should see JSON response with "status": "ok"

Database Connection

Check if database connection works:

  1. Login to the application
  2. Navigate to "Tables" tab
  3. You should see a list of tables (or empty list if no tables exist)
  4. If you see an error, check:
    • DATABASE_URL is correct
    • PostgreSQL is running
    • Network connectivity (if remote database)
    • Firewall rules (if remote database)

Common Issues

Application won't start:

  • Check Docker is running: docker ps
  • Check logs: docker logs selfhosteddb-app
  • Verify environment variables are set

Can't connect to database:

  • Verify PostgreSQL is running
  • Check DATABASE_URL format
  • Test connection: psql "your-database-url"
  • For Docker: use host.docker.internal instead of localhost

Login doesn't work:

  • Verify AUTH_USER and AUTH_PASS are set correctly
  • Check for typos in credentials
  • Clear browser cache and cookies

For more troubleshooting: See the Troubleshooting Guide

Related Documentation:


Next Steps

After installation:

  1. Read the Production Deployment Guide - Deploy to production
  2. Review Security Best Practices - Secure your installation
  3. Check API Documentation - Integrate with your applications
  4. Explore Features:
    • Browse and edit tables
    • Run SQL queries
    • View schema relationships
    • Export data

Uninstallation

Docker Compose

# Stop and remove containers
docker-compose down
 
# Remove containers and volumes (deletes database data!)
docker-compose down -v
 
# Remove images
docker rmi selfhosteddb:latest postgres:15-alpine

Docker Run

# Stop container
docker stop selfhosteddb
 
# Remove container
docker rm selfhosteddb
 
# Remove image
docker rmi selfhosteddb:latest

Manual Installation

# Stop processes (Ctrl+C in terminals)
 
# Remove dependencies (optional)
cd backend && rm -rf node_modules
cd ../frontend && rm -rf node_modules

Support

Need help?


Last Updated: 2025-01-27


License Activation

Understanding the License System

SelfHostedDB uses an email-based license system that allows unlimited deployments per license owner:

  • License Owner: Identified by email address (the purchaser)
  • Deployments: Unlimited (same owner can deploy on AWS, GCP, Docker, DigitalOcean, etc.)
  • Team Members: Unlimited per deployment (via Basic Auth or API Keys)
  • Restrictions: License key must match the purchaser's email address (prevents sharing)

Activating Your License

After Purchase:

  1. You'll receive a license key via email
  2. Start the application
  3. Enter your license key and the email address used for purchase
  4. Click "Activate License"
  5. The license is activated and cached locally

Starting a Trial

14-Day Free Trial:

  1. Start the application
  2. Enter your email address
  3. Click "Start Free Trial"
  4. You'll have full access for 14 days
  5. After purchase, your trial automatically converts to a license

License Status

Check License Status:

  • View license status in the application UI
  • API endpoint: GET /api/license/status (no authentication required)
  • Shows: license validity, trial expiration, grace period status

Troubleshooting License Issues

"License key not found":

  • Verify you're using the correct license key from your purchase email
  • Ensure the email address matches the one used for purchase
  • Check that LICENSE_SERVER_URL is correctly configured

"License key does not match email":

  • Use the exact email address associated with your purchase
  • License keys are tied to the purchaser's email to prevent sharing

"Trial expired":

  • Purchase a license to continue using the application
  • Your trial data and configuration are preserved

For more help: See Troubleshooting Guide for license-related issues