Skip to content

pouradba/dba-coworker

Repository files navigation

DBA Coworker

DBA Coworker

AI-Powered PostgreSQL Database Administration Tool
Built for DBAs who want pgAdmin + SSMS + dbForge + DBtune — all in one tool, with AI superpowers.
AMVANA Software India Pvt. Ltd. | PouraDBA

Quick StartFeaturesArchitectureScreenshotsAPIContributing

v17 PostgreSQL 14-17 Node.js 18+ React 18 Claude API MIT License Minimal Deps


What is DBA Coworker?

DBA Coworker is a self-hosted, open-source PostgreSQL administration tool that combines the best features of pgAdmin, SSMS Activity Monitor, dbForge Studio, and DBtune into a single, AI-powered application.

Unlike traditional monitoring tools that just show you data, DBA Coworker understands your workload and actively helps you optimize, troubleshoot, and manage your PostgreSQL fleet.

Why DBA Coworker?

Traditional Tools DBA Coworker
Show metrics, you interpret AI analyzes your data and recommends actions
One server at a time Fleet-wide overview of all servers
Separate tools for monitoring, tuning, backups Everything in one place
Manual config tuning (PGTune) Workload-aware tuning score + AI recommendations
No schema version control Built-in schema compare with Git projects
Copy-paste SQL from docs SQL IDE with autocomplete, formatter, visual query builder

🚀 Quick Start

Prerequisites

Installation

Option 1: Download Release (Recommended)

  1. Download the latest release zip from GitHub Releases
  2. Extract the zip to your preferred location (e.g., D:\dba-coworker)

Option 2: Clone from GitHub

git clone https://github.com/PouraDBA/dba-coworker.git
cd dba-coworker

Starting the Application

Windows (PowerShell)

cd D:\dba-coworker

# If you get an execution policy error, run this first (current session only):
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process

.\start.ps1

Windows (Command Prompt)

cd D:\dba-coworker
start.bat

Windows (Manual)

cd D:\dba-coworker\backend
npm install
node server.js

Linux / macOS

cd dba-coworker

# Install backend dependencies
cd backend
npm install

# Install and build frontend
cd ../frontend
npm install
npm run build

# Start the application
cd ../backend
node server.js

Open http://localhost:4000 in your browser.

Docker

docker-compose up -d
# Open http://localhost:4000

First-Time Setup

  1. Open http://localhost:4000 — you'll see the welcome screen
  2. Click "+ Register Server" — enter your PostgreSQL host, port, credentials
  3. Click Test Connection to verify
  4. All monitoring tabs populate with live data immediately
  5. (Optional) Go to AI Auto-Fix tab → enter your Anthropic API key for AI features

✨ Features

DBA Coworker covers 7 pillars of database management, inspired by dbForge Studio's comprehensive approach:

                    ┌─────────────────┐
                    │  DBA Coworker   │
                    └────────┬────────┘
        ┌───────┬───────┬────┴────┬───────┬───────┬───────┐
        ▼       ▼       ▼        ▼       ▼       ▼       ▼
   ┌─────────┐┌──────┐┌───────┐┌──────┐┌──────┐┌───────┐┌──────┐
   │  SQL    ││ DB   ││ Data  ││ DB   ││  DB  ││Report ││Auto- │
   │  Dev    ││Design││ Mgmt  ││ Ops  ││Admin ││& Data ││mation│
   └─────────┘└──────┘└───────┘└──────┘└──────┘└───────┘└──────┘

🌐 Fleet Management

Feature Description
Server Registration pgAdmin-style — register servers with host, port, credentials, groups, colors
Fleet Overview Scan all servers at once — online/offline status, PG version, connections, latency
Server Groups Organize by environment (Production, Staging, Dev) with color coding
Multi-Database Switcher Dropdown in header — switch databases without re-registering

📊 Monitoring Dashboard (22 Tabs)

Tab Inspired By Description
Overview SSMS Activity Monitor Connections, active queries, cache hit %, locks, DB size, replication — with real-time sparkline graphs
Connections SSMS Processes Live pg_stat_activity with state badges, Cancel/Kill buttons per PID
Databases pgAdmin Dashboard Per-database size, cache hit, commits, rollbacks, deadlocks, temp files
Tables pgAdmin/SSMS Size, live/dead rows, bloat %, seq/idx scans, last vacuum/analyze, one-click VACUUM/ANALYZE/REINDEX
Indexes SSMS Usage stats, scan counts — find unused indexes consuming disk
Objects SSMS Object Explorer Tables, views, materialized views, sequences, foreign tables
Functions pgAdmin Functions & procedures with argument signatures and return types
Replication SSMS Always On Slots, lag, WAL status, streaming replication monitoring
Locks Blocking lock chains with blocker → blocked PID mapping
Wait Events SSMS Resource Waits Wait events grouped by type (Lock, IO, Client, IPC)
File I/O SSMS Data File I/O Block reads, hits, cache ratio, temp files, read/write times
Bloat myDBA.dev Dead tuple analysis with bloat % per table
Maintenance pgAdmin One-click VACUUM, ANALYZE, REINDEX buttons per table
Slow Queries SSMS Expensive Queries Top queries from pg_stat_statements by avg/total time
Extensions pgAdmin Installed extensions with versions
Roles SSMS Security Roles with superuser, replication, create DB, member_of
Backup/Server SSMS Properties Archive mode, WAL level, data directory, uptime, all DB sizes
Settings pgAdmin Key postgresql.conf parameters with restart/reload indicators

Extra on every tab: 📥 Export CSV button for all data.

📈 Real-Time Graphs (SSMS Activity Monitor-style)

Six live sparkline charts on the Overview tab, auto-refreshing every 10 seconds:

  • Connections — total client connections over time
  • Transactions/sec — TPS derived from pg_stat_database
  • Cache Hit % — buffer cache efficiency
  • Active Queries — concurrent active query count
  • Idle in Transaction — stale transaction detection
  • Lock Waits — lock contention trending

🤖 AI-Powered DBA (Claude API)

"Like having a senior DBA sitting next to you 24/7"

Feature Tab Description
AI Chat 💬 AI Chat Chat about your live server — AI has full context of connections, bloat, replication, settings, extensions
Auto-Fix Engine 🤖 AI Auto-Fix Scans 7 issue types with one-click fix buttons
Query Optimizer 🤖 AI Auto-Fix Paste SQL → gets EXPLAIN + schemas → AI rewrites with index suggestions
SQL Generator 🤖 AI Auto-Fix Natural language → production SQL using your actual table schemas
Incident Playbooks 🤖 AI Auto-Fix Describe incident → step-by-step resolution with SQL
Migration Helper 🤖 AI Auto-Fix Describe changes → ALTER TABLE with pre-checks, rollback, verification
Doc Generator 🤖 AI Auto-Fix One-click: Runbook, Architecture Doc, or DR Plan — from live data

How AI context works:

Your PG Server → Backend collects live data → Sent as context to Claude
                  (connections, bloat, replication,     ↓
                   settings, extensions, databases)   Specific advice with
                                                      real table names,
                                                      exact SQL, actual IPs

🎯 Tuning Advisor (DBtune-style)

View Description
📊 Tuning Score 12 automated checks scored A-F. Instant — no AI needed. Checks: cache hit ratio, connection usage, shared_buffers, effective_cache_size, work_mem, random_page_cost, io_concurrency, idle txn timeout, slow query logging, table bloat, unused indexes, checkpoint tuning.
🔬 Workload Profile Deep analysis: OLTP/OLAP/Mixed classification, read/write %, all tunable params, index health, top queries from pg_stat_statements
🧠 AI Recommendations Claude analyzes full workload → 🔴 CRITICAL / 🟡 IMPORTANT / 🟢 NICE-TO-HAVE with ready-to-run ALTER SYSTEM commands

🔀 Schema Compare (dbForge-style)

Feature Description
Upload & Compare Drag-drop Git project SQL files → instant diff against live database
Side-by-Side Diff Split-panel: PROJECT (Git) vs SERVER (Live) with line-by-line highlighting
8 Object Types Tables (with constraints, indexes), functions, views, materialized views, triggers, sequences, extensions, custom types
Status Detection ✅ Identical, 🔶 Modified, ➕ Project Only, ⚠️ Server Only
Export Schema Extract all objects as individual SQL files for Git initialization

💾 Backup Manager (11 Backup Types)

Type Tool
Single Database pg_dump with format/compression/parallel options
Schema Only DDL only (no data)
Data Only COPY/INSERT only (no DDL)
Per-Object Export Separate files for tables, functions, views, sequences, triggers
All Databases Full script with per-DB timing and logging
Roles & Users pg_dumpall --roles-only
Globals Roles + tablespaces
Physical pg_basebackup with WAL streaming
Incremental pgBackRest setup (full/diff/incr schedule)
PITR Setup WAL archiving + recovery guide + restore points
Restore Commands for any format

Plus: Backup Analysis (archive mode alerts), Log Analyzer (paste log → parsed), PITR Restore Points (create before migrations).

🔗 FDW Manager

  • View foreign servers, user mappings, foreign tables with column-level detail
  • Create: Foreign servers (tds_fdw template), tables (with OPTIONS), user mappings
  • Import Foreign Schema: Bulk import with LIMIT TO
  • Script All DDL: Complete export with column OPTIONS, COLLATE, NOT NULL
  • Drop with CASCADE confirmation

▷ SQL IDE

Feature Description
Autocomplete Tables, columns (table.), functions, keywords. Ctrl+Space trigger.
SQL Formatter One-click keyword uppercasing, indentation, clause separation
Visual Query Builder Click tables → columns → auto-FK joins → WHERE/ORDER/LIMIT → generate
12 SQL Snippets SELECT, JOIN, CTE, INSERT, UPDATE, CREATE TABLE/FUNCTION/INDEX, GRANT, EXPLAIN
EXPLAIN Visualizer Visual plan tree with color-coded timings and buffer stats
Query History Persistent sidebar, click to reload, saved across restarts
Export CSV One-click on any result

❤️ Health Report

8-point automated health check: cache hit ratio, connection usage, idle-in-transaction, replication slots, deadlocks, bloated tables, long queries, uptime — scored out of 100.


🏗 Architecture

┌──────────────────────────────┐
│    React Frontend (:3000)    │
│  ┌──────────────────────┐    │
│  │ Server Tree (sidebar)│    │
│  │ 22 Monitoring Tabs   │    │
│  │ SQL IDE              │    │
│  │ Schema Compare       │    │
│  │ Backup Manager       │    │
│  │ Tuning Advisor       │    │
│  │ AI Chat / Auto-Fix   │    │
│  │ FDW Manager          │    │
│  └──────────────────────┘    │
└─────────────┬────────────────┘
              │ /api (REST)
┌─────────────▼────────────────┐
│   Express.js Backend (:4000) │
│  ┌──────────────────────┐    │     ┌────────────────┐
│  │ Connection Pool Mgr  │─────────▶│ PostgreSQL     │
│  │ Monitoring Queries   │    │     │ Servers (fleet) │
│  │ Backup Engine        │    │     └────────────────┘
│  │ Schema Extractor     │    │
│  │ Tuning Analyzer      │    │     ┌────────────────┐
│  │ FDW Manager          │─────────▶│ Claude API     │
│  │ SQL Formatter        │    │     │ (Anthropic)    │
│  │ AI Proxy             │    │     └────────────────┘
│  └──────────────────────┘    │
│  servers.json                │
│  query_history.json          │
│  api_key.json                │
└──────────────────────────────┘

Tech Stack

Component Technology
Frontend React 18, Vite 6, SVG charts (zero CSS/chart dependencies)
Backend Express.js, node-postgres (pg)
AI Engine Anthropic Claude API (Sonnet)
Deployment Node.js / Docker

Zero Dependencies Philosophy

  • Backend: express, cors, pg — 3 packages
  • Frontend: react, react-dom, vite — 3 packages
  • No Redis, MongoDB, Elasticsearch — config in JSON files
  • SVG sparklines — hand-coded, no chart library
  • Inline styles — no Tailwind, no CSS framework

🔒 Security

Best Practices

  • Run inside your network — do NOT expose to the internet
  • Use a read-only monitoring user:
CREATE ROLE dba_coworker LOGIN PASSWORD 'secure_password';
GRANT pg_monitor TO dba_coworker;
GRANT pg_read_all_stats TO dba_coworker;
  • servers.json contains credentials — restrict with chmod 600
  • Blocked via SQL Editor: DROP DATABASE, DROP TABLESPACE, ALTER SYSTEM, COPY TO PROGRAM
  • All queries have 30-second timeout
  • Max 3 connections per server pool

📡 API Reference

Server Management

Method Endpoint Description
GET /api/servers List servers
POST /api/servers Register server
PUT /api/servers/:id Update server
DELETE /api/servers/:id Remove server
POST /api/servers/:id/test Test connection
GET /api/fleet/status Fleet scan

Monitoring

Method Endpoint Description
GET /api/servers/:id/monitor/:type Monitoring data (20+ types)
GET /api/servers/:id/metrics Time-series for graphs
GET /api/servers/:id/health-report Health check with score

SQL Development

Method Endpoint Description
POST /api/servers/:id/query Execute SQL
POST /api/servers/:id/explain EXPLAIN ANALYZE
POST /api/servers/:id/sql/format Format SQL
GET /api/servers/:id/sql/autocomplete Tables, columns, functions
GET /api/servers/:id/sql/relationships FK map for query builder

Tuning

Method Endpoint Description
GET /api/servers/:id/tuning/score 12-point score
GET /api/servers/:id/tuning/workload Workload profile
POST /api/servers/:id/tuning/recommend AI recommendations

Schema Compare

Method Endpoint Description
GET /api/servers/:id/schema/extract Extract schema DDL
POST /api/servers/:id/schema/compare Compare project vs live DB
GET /api/servers/:id/schema/export-project Export as project files

Backup

Method Endpoint Description
GET /api/servers/:id/backup/analysis Backup analysis
POST /api/servers/:id/backup/generate-command Generate commands (11 types)
POST /api/servers/:id/backup/restore-point Create PITR point

AI

Method Endpoint Description
POST /api/servers/:id/ai/chat AI chat with server context
POST /api/servers/:id/ai/optimize Query optimizer
POST /api/servers/:id/ai/generate-sql NL → SQL
GET /api/servers/:id/ai/auto-detect Issue detection
POST /api/servers/:id/ai/playbook Incident playbook
POST /api/servers/:id/ai/migration Migration helper
POST /api/servers/:id/ai/documentation Doc generator

FDW

Method Endpoint Description
GET /api/servers/:id/fdw FDW inventory
POST /api/servers/:id/fdw/create-server Create foreign server
POST /api/servers/:id/fdw/create-table Create foreign table
POST /api/servers/:id/fdw/import-schema Import remote schema
GET /api/servers/:id/fdw/generate-ddl Export all FDW DDL

🗺️ Roadmap

✅ Completed

  • Server registration & fleet management
  • 22 monitoring tabs with live data
  • Real-time sparkline graphs (6 metrics)
  • AI Chat with live server context
  • AI Auto-Fix with one-click remediation
  • Query Optimizer, SQL Generator, Incident Playbooks
  • Tuning Advisor (score + workload profile + AI recommendations)
  • Schema Compare (Git project vs live DB)
  • Backup Manager (11 types + log analyzer)
  • FDW Manager with DDL generation
  • SQL IDE (autocomplete, formatter, visual query builder, snippets)
  • EXPLAIN ANALYZE visualizer
  • Health Report (8-point scoring)
  • Export CSV on all tabs
  • Docker support

🗓️ Planned

  • ER Diagram generator
  • Visual schema designer
  • Inline data editor (cell editing in tables)
  • Data import (CSV, JSON, Excel)
  • Data compare between databases
  • pgAgent job manager
  • Scheduled health checks with email/Slack alerts
  • PDF report generation
  • Iterative auto-tuning (DBtune-style apply → measure → adjust)
  • Multi-user with role-based access
  • Plugin system for custom tabs

🤝 Contributing

Contributions welcome! See CONTRIBUTING.md for guidelines.

# Development setup
cd backend && npm install && node --watch server.js    # API on :4000
cd frontend && npm install && npm run dev              # UI on :3000 (proxied)

Project Structure

dba-coworker/
├── backend/
│   ├── server.js              # Express API (~2,600 lines)
│   └── package.json
├── frontend/
│   ├── src/
│   │   ├── App.jsx            # React app (~2,100 lines)
│   │   └── main.jsx
│   ├── index.html
│   └── vite.config.js
├── docker-compose.yml
├── Dockerfile
├── LICENSE
└── README.md

📄 License

MIT License — see LICENSE for details.


🙏 Acknowledgments


Built with ❤️ by PouraDBA

About

AI-Powered PostgreSQL Database Administration Tool - combines pgAdmin + SSMS + monitoring + AI auto-fix in one app

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages