-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
π΄ 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 mountedOnly auto-generated API docs exist.
π File: app/routes_databases.py
@router.get("/databases")
async def list_databases(...):
# Returns JSON, no UIDatabase 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:
- 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
- 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
Labels
No labels