🔴 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:
React/Vue SPA served by FastAPI
Real-time updates via WebSocket
Role-based access control
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
Phase 2: Dashboard Overview
Phase 3: Database Management
Phase 4: Query Explorer
Phase 5: Feedback Management
Phase 6: Monitoring Integration
Phase 7: Settings & Configuration
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 │ │
│ │ ... │ ... │ │
│ └─────────┴───────────┘ │
└─────────────────────────────────────────────────────────────┘
🔴 Priority: HIGH | Type: Feature
1. SUMMARY
2. SYSTEM CONTEXT
3. CURRENT STATE (with code)
📄 File:
app/main.pyOnly auto-generated API docs exist.
📄 File:
app/routes_databases.pyDatabase management is API-only.
📄 File:
monitoring/grafana/dashboard.json// Grafana dashboard exists but requires separate Grafana instanceMonitoring requires external tools.
4. PROPOSED SOLUTION
Create an embedded admin dashboard using a modern frontend framework:
📄 File:
admin/directory structure (NEW)📄 File:
app/main.py(ENHANCED)5. IMPLEMENTATION CHECKLIST
Phase 1: Core Infrastructure
admin/frontend/Phase 2: Dashboard Overview
Phase 3: Database Management
Phase 4: Query Explorer
Phase 5: Feedback Management
Phase 6: Monitoring Integration
Phase 7: Settings & Configuration
6. FILES TO MODIFY TABLE
admin/frontend/admin/api/admin_routes.pyapp/main.pyapp/security/auth.pyrequirements.txtDockerfile.github/workflows/ci.ymldocs/ADMIN_GUIDE.md7. RISK ASSESSMENT
8. RELATED CONTEXT
monitoring/grafana/dashboard.jsonapp/monitoring/endpoints.py/docs9. DESIGN MOCKUPS
Dashboard Overview:
Query Playground: