General Notes
- AI-powered dashboard for energy audit data visualization (Maharashtra MSEDCL/Mahavitran)
- Users converse with AI to generate widgets (charts and tables) from DuckDB data
- Canvas-based UI with multiple canvases, each containing AI-generated widgets
- Similar to rows.com chat-to-canvas experience
- Backend built on slim-bp-v2 (Fastify 5 + MongoDB + Mongoose)
Mongo Schema
Canvas
{
"_id": "ObjectId",
"userId": "string (ref: user)",
"name": "string",
"displayOrder": "number (for reordering, no API yet)",
"isDefault": "boolean (true for Energy Audit canvas)",
"widgetLimit": "number (default: 10)",
"schemaVersion": 0.1,
"timestamps": { "createdAt": "Date", "updatedAt": "Date" }
}
Widget
{
"_id": "ObjectId",
"canvasId": "ObjectId (ref: Canvas)",
"conversationId": "ObjectId (ref: Conversation)",
"userId": "string (ref: user)",
"title": "string (AI-generated, user-editable)",
"type": "string (enum: chart, table)",
"chartType": "string (enum: line, bar, pie, donut, stackedBar, scatterPlot — null for tables)",
"sql": "string (the SQL query that generates this widget)",
"chartConfig": "object (frontend rendering config — axes, colors, etc.)",
"position": "number (order within canvas, reorganize on delete)",
"aiModel": "string (which model generated the SQL)",
"schemaVersion": 0.1,
"timestamps": { "createdAt": "Date", "updatedAt": "Date" }
}
Conversation
{
"_id": "ObjectId",
"canvasId": "ObjectId (ref: Canvas)",
"widgetId": "ObjectId (ref: Widget, set once widget is created)",
"userId": "string (ref: user)",
"name": "string (AI-generated, NOT user-editable)",
"status": "string (enum: active, completed)",
"messages": [
{
"role": "string (enum: user, assistant)",
"content": "string",
"chartConfig": "object (present when AI produces a chart)",
"sql": "string (present when AI produces a query)",
"timestamp": "Date"
}
],
"schemaVersion": 0.1,
"timestamps": { "createdAt": "Date", "updatedAt": "Date" }
}
Visit Later
- Which specific widgets will be pre-generated in the default Energy Audit canvas?
- Pre-generated widgets: stored SQL executed on-the-fly vs hardcoded config?
- Full list of default widget suggestions per user type
- Simultaneous conversation enforcement: backend vs frontend?
- Delete widget vs delete conversation: frontend decision
- Conversation visibility in UI: always visible or only on widget edit?
- What to do when a user tries to create the same widget in the same canvas? (Currently: allow duplicates)