Skip to content

[HIGH] Admin UI/Dashboard for Database and Query ManagementΒ #46

@Sakeeb91

Description

@Sakeeb91

πŸ”΄ Priority: HIGH | Type: Feature

1. SUMMARY

  • No web-based admin interface exists for managing databases, reviewing queries, monitoring system health, or managing feedback.
  • Impact: Administrators must use CLI/API for all operations. No visual dashboards for monitoring. Poor discoverability of system state and issues.

2. SYSTEM CONTEXT

Current state: CLI/API only
─────────────────────────────
Admin β†’ curl/httpie β†’ API endpoints β†’ Response JSON
Admin β†’ Grafana (separate) β†’ Metrics only

Desired state: Integrated Admin UI
─────────────────────────────────────
Admin β†’ Web Dashboard β†’
  β”œβ”€β”€ Database Management (register, health, schema viewer)
  β”œβ”€β”€ Query Explorer (history, search, replay)
  β”œβ”€β”€ Feedback Queue (review, verify, apply)
  β”œβ”€β”€ Monitoring (health, metrics, alerts)
  └── Configuration (settings, users, API keys)

Existing infrastructure:
β”œβ”€β”€ FastAPI (can serve static files)
β”œβ”€β”€ Prometheus metrics (available at /monitoring/metrics)
β”œβ”€β”€ Health endpoints (/api/v1/health, /monitoring/health)
└── OpenAPI spec (auto-generated)

3. CURRENT STATE (with code)

πŸ“„ File: app/main.py

app = FastAPI(
    title="Text2SQL Agent",
    docs_url="/docs",  # Swagger UI exists
    redoc_url="/redoc",  # ReDoc exists
)
# No admin UI mounted

Only auto-generated API docs exist.

πŸ“„ File: app/routes_databases.py

@router.get("/databases")
async def list_databases(...):
    # Returns JSON, no UI

Database management is API-only.

πŸ“„ File: monitoring/grafana/dashboard.json

// Grafana dashboard exists but requires separate Grafana instance

Monitoring requires external tools.

4. PROPOSED SOLUTION

Create an embedded admin dashboard using a modern frontend framework:

  1. React/Vue SPA served by FastAPI
  2. Real-time updates via WebSocket
  3. Role-based access control
  4. Mobile-responsive design

πŸ“„ File: admin/ directory structure (NEW)

admin/
β”œβ”€β”€ frontend/                 # React/Vue app
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”‚   β”œβ”€β”€ Dashboard.tsx       # Overview with key metrics
β”‚   β”‚   β”‚   β”œβ”€β”€ Databases.tsx       # Database management
β”‚   β”‚   β”‚   β”œβ”€β”€ QueryExplorer.tsx   # Query history and search
β”‚   β”‚   β”‚   β”œβ”€β”€ FeedbackQueue.tsx   # Feedback review
β”‚   β”‚   β”‚   β”œβ”€β”€ Monitoring.tsx      # Health and metrics
β”‚   β”‚   β”‚   └── Settings.tsx        # Configuration
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   β”œβ”€β”€ SchemaViewer.tsx    # Interactive schema browser
β”‚   β”‚   β”‚   β”œβ”€β”€ QueryPlayground.tsx # Test queries interactively
β”‚   β”‚   β”‚   β”œβ”€β”€ MetricsChart.tsx    # Embedded metrics charts
β”‚   β”‚   β”‚   └── AlertsPanel.tsx     # Active alerts display
β”‚   β”‚   └── hooks/
β”‚   β”‚       β”œβ”€β”€ useWebSocket.ts     # Real-time updates
β”‚   β”‚       └── useAuth.ts          # Admin authentication
β”‚   └── package.json
β”œβ”€β”€ api/
β”‚   └── admin_routes.py       # Admin-specific endpoints
└── static/                   # Built frontend (served by FastAPI)

πŸ“„ File: app/main.py (ENHANCED)

from fastapi.staticfiles import StaticFiles

# Mount admin UI
app.mount("/admin", StaticFiles(directory="admin/static", html=True), name="admin")

# Admin API routes
app.include_router(admin_router, prefix="/api/admin", tags=["admin"])

5. IMPLEMENTATION CHECKLIST

Phase 1: Core Infrastructure

  • Set up React/Vite frontend project in admin/frontend/
  • Configure FastAPI to serve static files
  • Implement admin authentication (separate from API auth)
  • Create base layout with navigation

Phase 2: Dashboard Overview

  • Key metrics cards (queries/day, success rate, avg latency)
  • Recent activity feed
  • System health status
  • Quick actions (test query, view logs)

Phase 3: Database Management

  • List registered databases with health status
  • Register new database form with connection test
  • Interactive schema browser (tables, columns, relationships)
  • Database health history graph

Phase 4: Query Explorer

  • Query history with search and filters
  • Query detail view (SQL, reasoning trace, results)
  • Replay query functionality
  • Export queries to CSV/JSON

Phase 5: Feedback Management

  • Pending feedback queue
  • Review interface with side-by-side comparison
  • Bulk verify/reject actions
  • Feedback analytics (common corrections)

Phase 6: Monitoring Integration

  • Embedded metrics charts (without Grafana)
  • Active alerts display
  • Log viewer (structured logs)
  • Performance trends

Phase 7: Settings & Configuration

  • API key management
  • User management (if multi-user)
  • Feature flags
  • Cache management (clear, stats)

6. FILES TO MODIFY TABLE

File Lines Action Description
admin/frontend/ NEW Create React frontend application
admin/api/admin_routes.py NEW Create Admin-specific API endpoints
app/main.py TBD Modify Mount admin static files and routes
app/security/auth.py TBD Modify Add admin role/scope
requirements.txt TBD Modify Add any backend dependencies
Dockerfile TBD Modify Include frontend build step
.github/workflows/ci.yml TBD Modify Add frontend build/test job
docs/ADMIN_GUIDE.md NEW Create Admin UI documentation

7. RISK ASSESSMENT

Risk Impact Mitigation
Frontend adds complexity 🟑 Use simple stack (React + Vite); minimal dependencies
Security exposure πŸ”΄ Separate admin auth; IP whitelisting; audit logs
Build time increase 🟑 Cache node_modules; parallel builds
Maintenance burden 🟑 Keep UI simple; use component library (shadcn/ui)

8. RELATED CONTEXT

  • Existing Grafana dashboard: monitoring/grafana/dashboard.json
  • Health endpoints: app/monitoring/endpoints.py
  • OpenAPI spec: Auto-generated at /docs
  • Related issue: [HIGH] Query Feedback Loop - Learn from User CorrectionsΒ #45 (Feedback Loop - needs admin UI for review queue)
  • Similar projects: Metabase, Apache Superset (for inspiration)

9. DESIGN MOCKUPS

Dashboard Overview:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Text2SQL Admin                    [Health: βœ…] [User β–Ό]   β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚          β”‚  Dashboard                                       β”‚
β”‚ Dashboardβ”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”‚
β”‚ Databasesβ”‚  β”‚ 1,234    β”‚ β”‚ 94.2%    β”‚ β”‚ 156ms    β”‚         β”‚
β”‚ Queries  β”‚  β”‚ Queries  β”‚ β”‚ Success  β”‚ β”‚ Avg Lat  β”‚         β”‚
β”‚ Feedback β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β”‚
β”‚ Monitor  β”‚                                                  β”‚
β”‚ Settings β”‚  Recent Activity                                 β”‚
β”‚          β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚          β”‚  β”‚ 2m ago  Query: "Show sales..." β†’ Success    β”‚ β”‚
β”‚          β”‚  β”‚ 5m ago  DB: analytics registered            β”‚ β”‚
β”‚          β”‚  β”‚ 8m ago  Feedback: #123 verified             β”‚ β”‚
β”‚          β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Query Playground:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Query Playground                                           β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Database: [analytics β–Ό]                                    β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚  β”‚ Show me top 10 customers by revenue                     β”‚β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β”‚  [Execute] [Show Reasoning]                                 β”‚
β”‚                                                             β”‚
β”‚  Generated SQL:                          Confidence: 92%    β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚  β”‚ SELECT c.name, SUM(o.total) as revenue                  β”‚β”‚
β”‚  β”‚ FROM customers c JOIN orders o ON c.id = o.customer_id  β”‚β”‚
β”‚  β”‚ GROUP BY c.id ORDER BY revenue DESC LIMIT 10            β”‚β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β”‚                                                             β”‚
β”‚  Results: 10 rows                                           β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                                    β”‚
β”‚  β”‚ name    β”‚ revenue   β”‚                                    β”‚
β”‚  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€                                    β”‚
β”‚  β”‚ Acme    β”‚ $125,000  β”‚                                    β”‚
β”‚  β”‚ ...     β”‚ ...       β”‚                                    β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions