WebAIChat

Vidura AI

Vidura is an AI-powered analytics chat interface embedded in the Quper dashboard. It allows users to ask natural language questions about their Redshift clusters, AWS costs, and optimization opportunities, receiving structured markdown responses powered by the Vidura service's LangChain agent.

Route: /vidura

Architecture

Vidura Data Flow
User (browser)
  → POST /api/vidura (Next.js route handler)
  → Vidura Service POST /ask
  → LangChain Agent (GPT-4o-mini)
    → Tool selection & execution
    → Redshift queries / Athena queries / RAG lookup
  → Markdown response
  → react-markdown rendering in browser

Chat Interface Features

  • Multi-session support — Users can create, name, switch between, and delete multiple chat sessions, all persisted to localStorage
  • Markdown rendering — Responses are rendered via react-markdown with remark-gfm for tables, code blocks, and GitHub-flavored markdown
  • Message history — Full conversation history with timestamps is preserved per session
  • Streaming indicator — Loading state shown while the Vidura agent processes the query
  • Ask Vidura Sheet — A slide-in drawer component (AskViduraSheet.tsx) accessible from any dashboard page via a floating button, allowing contextual questions without leaving the current view

Session Management

Session Storage Schema
type ViduraSession = {
  id: string;           // UUID
  name: string;         // User-defined session name
  createdAt: string;    // ISO timestamp
  messages: ViduraMessage[];
};

type ViduraMessage = {
  id: string;
  role: 'user' | 'assistant';
  content: string;      // Markdown string
  timestamp: string;    // ISO timestamp
};

// Stored in localStorage as:
// key: 'vidura_sessions'
// value: JSON.stringify(ViduraSession[])

API Route

The Next.js API route at /api/vidura acts as a proxy to the Vidura service. It:

  1. Validates the authenticated session token from cookies
  2. Extracts the tenant context (environment ID, schema)
  3. Forwards the prompt to the Vidura /ask endpoint
  4. Returns the response to the client

Authentication

All Vidura requests require an authenticated session. The JWT token is read from the cookie set during login and validated by Auth0 before proxying to the Vidura service.

Example Queries

Users can ask Vidura questions such as:

  • "What are my top 5 most expensive EC2 instances this month?"
  • "Which queries are causing the most disk spill in our Redshift cluster?"
  • "How can I optimize the sort keys on our largest tables?"
  • "Show me our AWS spend trends over the last 3 months."
  • "What tables need vacuuming most urgently?"