{"id":47870394,"url":"https://github.com/lamngockhuong/dbsight","last_synced_at":"2026-04-04T00:48:38.185Z","repository":{"id":339873084,"uuid":"1163414530","full_name":"lamngockhuong/dbsight","owner":"lamngockhuong","description":"Database performance analyzer — slow queries, EXPLAIN plans, index efficiency. Go + React.","archived":false,"fork":false,"pushed_at":"2026-03-31T08:55:39.000Z","size":950,"stargazers_count":2,"open_issues_count":11,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-04T00:48:32.457Z","etag":null,"topics":["analyzer","database","database-performance-optimization","mariadb","mysql","performance","postgresql"],"latest_commit_sha":null,"homepage":"http://dbsight.khuong.dev/","language":"MDX","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lamngockhuong.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-21T15:45:41.000Z","updated_at":"2026-02-23T16:27:19.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/lamngockhuong/dbsight","commit_stats":null,"previous_names":["lamngockhuong/dbsight"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lamngockhuong/dbsight","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamngockhuong%2Fdbsight","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamngockhuong%2Fdbsight/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamngockhuong%2Fdbsight/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamngockhuong%2Fdbsight/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lamngockhuong","download_url":"https://codeload.github.com/lamngockhuong/dbsight/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamngockhuong%2Fdbsight/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31383635,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-03T23:20:52.058Z","status":"ssl_error","status_checked_at":"2026-04-03T23:20:51.675Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["analyzer","database","database-performance-optimization","mariadb","mysql","performance","postgresql"],"created_at":"2026-04-04T00:48:37.230Z","updated_at":"2026-04-04T00:48:38.174Z","avatar_url":"https://github.com/lamngockhuong.png","language":"MDX","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DBSight\n\nDatabase performance analyzer for PostgreSQL, MySQL, and MariaDB. Monitor slow queries, visualize EXPLAIN plans, and track index usage — all from a single binary.\n\n![Go](https://img.shields.io/badge/Go-1.26+-00ADD8?logo=go\u0026logoColor=white)\n![React](https://img.shields.io/badge/React-19-61DAFB?logo=react\u0026logoColor=white)\n![PostgreSQL](https://img.shields.io/badge/PostgreSQL-14+-4169E1?logo=postgresql\u0026logoColor=white)\n![MySQL](https://img.shields.io/badge/MySQL-5.7+-005A87?logo=mysql\u0026logoColor=white)\n![MariaDB](https://img.shields.io/badge/MariaDB-10.x+-C0765F?logo=mariadb\u0026logoColor=white)\n![License](https://img.shields.io/badge/License-MIT-green)\n\n**Documentation:** [dbsight.khuong.dev](https://dbsight.khuong.dev)\n\n## Features\n\n- **Slow Query Detection** — polls `pg_stat_statements` (PostgreSQL), `performance_schema` (MySQL/MariaDB) every 30s, ranks by total execution time with delta tracking\n- **Live Dashboard** — real-time updates via Server-Sent Events (SSE), no page refresh needed\n- **EXPLAIN Plans** — run EXPLAIN safely with per-database format support (PostgreSQL JSON, MySQL FORMAT=JSON, MariaDB ANALYZE FORMAT=JSON)\n- **Index Analysis** — identify unused indexes and missing index opportunities\n- **Paste Mode** — analyze slow query logs offline without a live database connection\n- **Multi-Database** — monitor multiple PostgreSQL, MySQL, and MariaDB instances from one dashboard\n- **Secure** — DSN credentials encrypted with AES-256-GCM, never exposed via API\n\n## Quick Start\n\n### Prerequisites\n\n- Go 1.26+\n- Node.js 20+\n- One or more supported databases:\n  - PostgreSQL 14+ (with `pg_stat_statements` extension enabled)\n  - MySQL 5.7+ or 8.0+ (with `performance_schema` enabled)\n  - MariaDB 10.x+ (with `performance_schema` enabled)\n- Docker \u0026 Docker Compose (optional)\n\n### Using Docker Compose\n\n```bash\ndocker-compose up -d postgres\n```\n\n### Setup\n\n```bash\n# Generate a 32-byte encryption key\nexport ENCRYPTION_KEY=$(openssl rand -hex 32)\n\n# Configure database\nexport DATABASE_URL=\"postgres://dbsight:secret@localhost:5499/dbsight?sslmode=disable\"\n\n# Run migrations\ngo run . migrate\n\n# Start the server (API + worker)\ngo run . serve\n```\n\n### Frontend Development\n\n```bash\npnpm install          # Install all workspace dependencies\npnpm --filter web dev # Vite dev server on :5173, proxies /api to :42198\n```\n\n### Documentation Site\n\n```bash\npnpm --filter docs dev   # Starlight dev server on :4321\npnpm --filter docs build # Build static docs site\n```\n\n### Production Build\n\n```bash\nmake build     # Builds frontend, then Go binary → bin/dbsight\n./bin/dbsight serve\n```\n\nOr with Docker:\n\n```bash\nmake docker-build\ndocker run -e DATABASE_URL=... -e ENCRYPTION_KEY=... -p 42198:42198 dbsight:latest\n```\n\n## Architecture\n\nThis is a **pnpm workspaces monorepo**:\n\n```\ndbsight/\n├── apps/web/        # React SPA (Vite + shadcn/ui)\n├── apps/docs/       # Starlight documentation site (EN + VI)\n├── internal/        # Go backend packages\n├── migrations/      # SQL migration files\n├── main.go          # Entry point — embeds apps/web/dist into binary\n└── docker-compose.yml\n```\n\n```\n┌─────────────────────────────────────────────┐\n│              Go Binary (dbsight)            │\n│                                             │\n│  ┌──────────┐  ┌────────┐  ┌────────────┐   │\n│  │ Chi API  │  │ Worker │  │ Embedded   │   │\n│  │ Server   │  │ (30s)  │  │ React SPA  │   │\n│  └────┬─────┘  └───┬────┘  └────────────┘   │\n│       │            │                        │\n│  ┌────┴────────────┴──────┐                 │\n│  │    Store (pgxpool)     │                 │\n│  └────────────┬───────────┘                 │\n└───────────────┼─────────────────────────────┘\n                │\n        ┌───────┴───────┐\n        │  PostgreSQL   │ (app metadata + metrics)\n        └───────────────┘\n                │\n        ┌───────┴───────┐\n        │  Target DBs   │ (via DBAnalyzer adapter)\n        └───────────────┘\n```\n\nThe single binary serves the API, background worker, and React SPA. The worker collects metrics from target databases via the adapter interface — extensible to MySQL and others.\n\n## Tech Stack\n\n| Layer     | Technology                                             |\n| --------- | ------------------------------------------------------ |\n| Backend   | Go 1.26+, Chi router, pgx/v5, Cobra CLI                |\n| Frontend  | React 19, Vite, TypeScript, shadcn/ui, Tailwind CSS v4 |\n| Data      | TanStack Table v8, Recharts                            |\n| Database  | PostgreSQL (metadata storage)                          |\n| Security  | AES-256-GCM encrypted DSN storage                      |\n| Real-time | Server-Sent Events (SSE)                               |\n| Deploy    | Docker multi-stage build                               |\n| Docs      | Astro Starlight, i18n (EN + VI), Pagefind search       |\n\n## Environment Variables\n\n| Variable               | Default | Description                             |\n| ---------------------- | ------- | --------------------------------------- |\n| `PORT`                 | `42198` | HTTP server port                        |\n| `DATABASE_URL`         | —       | PostgreSQL connection string for app DB |\n| `ENCRYPTION_KEY`       | —       | 64 hex chars (32 bytes) for AES-256-GCM |\n| `WORKER_INTERVAL_SECS` | `30`    | Metrics polling interval in seconds     |\n\n## Target Database Setup\n\n### PostgreSQL\n\nEnable `pg_stat_statements` on the databases you want to monitor:\n\n```sql\n-- postgresql.conf\nshared_preload_libraries = 'pg_stat_statements'\n\n-- Then run:\nCREATE EXTENSION IF NOT EXISTS pg_stat_statements;\n```\n\n### MySQL 5.7+ / 8.0+\n\nEnsure `performance_schema` is enabled (usually on by default):\n\n```sql\n-- Check if it is enabled\nSHOW GLOBAL VARIABLES LIKE 'performance_schema';\n-- Should return 'ON'\n\n-- If disabled, add to my.cnf and restart:\n[mysqld]\nperformance_schema = ON\n```\n\n### MariaDB 10.x+\n\nEnable `performance_schema` in the configuration:\n\n```sql\n-- Check if it is enabled\nSHOW GLOBAL VARIABLES LIKE 'performance_schema';\n-- Should return 'ON'\n\n-- If disabled, add to my.cnf and restart:\n[mysqld]\nperformance_schema = ON\n```\n\n## API\n\n| Method         | Endpoint                                | Description                       |\n| -------------- | --------------------------------------- | --------------------------------- |\n| GET/POST       | `/api/connections`                      | List / create connections         |\n| GET/PUT/DELETE | `/api/connections/{id}`                 | Get / update / delete connection  |\n| POST           | `/api/connections/{id}/test`            | Test connection (returns latency) |\n| GET            | `/api/connections/{id}/queries`         | Latest slow queries with deltas   |\n| GET            | `/api/connections/{id}/queries/stream`  | SSE live query updates            |\n| GET            | `/api/connections/{id}/queries/history` | Historical snapshots              |\n| POST           | `/api/paste/queries`                    | Parse slow query log text         |\n\n## Project Status\n\n- [x] Project scaffold + config\n- [x] Database schema + store layer\n- [x] DB adapter interface + PostgreSQL implementation\n- [x] API server + connection management\n- [x] Background worker + query endpoints\n- [x] React frontend foundation\n- [x] Slow query dashboard UI\n- [x] EXPLAIN plan visualization (custom tree renderer)\n- [x] Index analysis dashboard\n- [x] Docker production deployment\n- [x] Monorepo restructure (pnpm workspaces)\n- [x] Documentation site (Starlight, EN + VI)\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flamngockhuong%2Fdbsight","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flamngockhuong%2Fdbsight","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flamngockhuong%2Fdbsight/lists"}