Adam BlansettSenior Full-Stack & AI Engineer
Autonomous AI WorkforcePhase 3 Starter Scaffold (MIT)

AI Database Administrator Platform

Self-hosted AI DBA starter scaffold for slow-query and index tuning, schema migration risk checks, lock and connection diagnostics, replication/backup verification, and bloat forecasting.

Engineering RoleLead Systems & AI Architect

01. Problem & Context

Backend teams running production PostgreSQL without a dedicated DBA regularly hit unindexed sequential-scan regressions, lock-heavy DDL migrations causing outages, idle-in-transaction connection-pool exhaustion, untested backups, and unchecked table bloat.

02. Engineering Solution

Initialized the Phase 3 self-hosted starter scaffold pairing a FastAPI + Pydantic v2 backend (`/api/v1/health{,/live,/ready}`, pure ASGI security-header middleware, fail-fast production secret validation) with a React 18 Vite/Tailwind workspace, PostgreSQL (`pgvector`) + Redis Compose stack, and GitHub Actions CI. Establishes the verified runtime baseline for planned `query_tuning/`, `migrations/`, `diagnostics/`, and `reliability/` modules alongside `ai-data-governance`.

03. System Architecture

Verified starter runtime (`backend/app/main.py`, `core/config.py`, `core/middleware.py`, `api/v1/health.py`) paired with a React 18 TypeScript dashboard (`frontend/src/App.tsx`), Docker Compose (`postgres` pgvector, `redis`, `api`, `frontend`, `ollama` profile), and CI pipeline (`ruff`, `mypy`, `pytest`, `tsc`, `vitest`, `vite build`, `npm audit`, Trivy) ready for the four planned DBA modules in `docs/ARCHITECTURE.md`.

Core Architectural Components

Verified Starter API, Security Baseline & UI Shell (`/api/v1/health*`)

Shipped FastAPI application with versioned `/api/v1/health`, `/live`, and `/ready` probes, ASGI security-header injection (`X-Request-ID`, `nosniff`, `DENY`), fail-fast `validate_production_security()`, offline `mock`/Ollama/Gemini routing settings, and React 18 live health console.

Planned Domain Module: Slow-Query & Index Tuning (`query_tuning/`)

Blueprint for `EXPLAIN ANALYZE` and `pg_stat_statements` profiling, hot-query aggregation, and non-destructive index recommendations.

Planned Domain Module: Schema Migration Risk Checks (`migrations/`)

Blueprint for static DDL linting that flags lock-heavy `ALTER TABLE` statements, missing `CONCURRENTLY` index builds, and breaking column drops before rollout.

Planned Domain Modules: Lock Diagnostics & Reliability (`diagnostics/`, `reliability/`)

Blueprint for blocking-tree inspection, connection-pool saturation alerts, WAL replication lag monitoring, backup restore-drill verification, and storage bloat forecasting.

04. Notable Engineering Decisions

Non-Destructive Advisory Index & DDL Recommendations

Executing automated DDL or killing live queries blindly risks production downtime; the architecture separates static risk analysis and index proposals from human-approved execution.

Complementary Scope Alongside `ai-data-governance`

While `ai-data-governance` focuses on PII tokenization, record deduplication, and data hygiene, `ai-dba` targets operational PostgreSQL performance, lock trees, WAL replication, backup restore drills, and migration safety.

Local-First Telemetry Analysis Without Exposing Schema Metadata

Query plans and table schemas often reveal sensitive business structure; offline `mock` mode, local Ollama routing, and cloud PII redaction keep telemetry self-hosted.

05. Engineering Challenges & Solutions

Challenge: Keeping database administration tooling secure and non-privileged when inspecting sensitive catalog metadata.

Engineering Solution: Enforced non-root Docker containers, fail-fast `AUTH_SECRET_KEY` and CORS checks in production, and ASGI security-header middleware on every API response.

Challenge: Ensuring query tuning, migration linting, lock graphs, and backup verification evolve cleanly without monolithic coupling.

Engineering Solution: Partitioned the planned domain architecture into four focused packages (`query_tuning/`, `migrations/`, `diagnostics/`, `reliability/`) over a verified FastAPI + pgvector + Redis baseline.

06. Implementation Highlights

  • Verified FastAPI starter with `/api/v1/health`, `/live`, and `/ready` probes plus fail-fast `APP_ENV=production` secret and CORS validation
  • Pure ASGI `SecurityHeadersMiddleware` injecting `X-Request-ID`, `X-Content-Type-Options: nosniff`, `X-Frame-Options: DENY`, and production HSTS
  • React 18 + TypeScript + Vite + Tailwind starter dashboard with live `/api/v1/health` status check and Vitest + Testing Library unit tests
  • PostgreSQL (`pgvector`) + Redis + optional Ollama Docker Compose stack with non-root API and unprivileged Nginx containers
  • Documented Phase 3 `docs/ARCHITECTURE.md` blueprint for `query_tuning/`, `migrations/`, `diagnostics/`, and `reliability/` modules behind GitHub Actions CI