Napoleon
Napoleon•2w ago

Convex schema/functions design advice for dashboard app

We're building a dashboard-focused web app and need Convex schema/function design advice for handling frequent layout updates efficiently. Our data model: - Users create multiple dashboards (~30 per user) - Each dashboard contains multiple widgets that can be: - Dragged and resized (x, y, width, height positions) - Configured with ~10 settings parameters each - Added/removed dynamically - Users frequently switch between dashboards (querying full dashboard state) - Users regularly move/resize widgets (mutating widget's position data) - Users regularly configure widgets' settings parameters (mutating widget's settings config data) Some constraints: - Grid libraries like React Grid Layout provide the entire layout state on each change (not diffs) - Moving one widget often repositions others automatically - Users expect snappy drag/resize without lag - Switching between dashboards should feel fast Schema options we're considering: Option A: Normalized
- users
- dashboards (id, name, userId)
- widgetInstances (id, dashboardId, x, y, width, height, widgetType, settings)
- users
- dashboards (id, name, userId)
- widgetInstances (id, dashboardId, x, y, width, height, widgetType, settings)
Option B: Hybrid
- users
- dashboards (id, name, userId, layout: [{widgetId, x, y, w, h}])
- widgetInstances (id, dashboardId, widgetType, settings)
- users
- dashboards (id, name, userId, layout: [{widgetId, x, y, w, h}])
- widgetInstances (id, dashboardId, widgetType, settings)
Option C: Document-centric
- users
- dashboards (id, name, userId, state: {layout: [...], configs: {...}})
- users
- dashboards (id, name, userId, state: {layout: [...], configs: {...}})
Option D: Something else? I'm looking for any advice or best practices on how to design our schema and queries/mutations to make sure we properly take advantage of Convex's strengths, performance, layout engine constraints while ensuring cost efficiency, performance. Thank you.
3 Replies
Convex Bot
Convex Bot•2w ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
Napoleon
NapoleonOP•2w ago
Can someone who is an expert in Convex please answer, because I'm really unsure how to proceed 😅 Or at least tell me if kapa's advice is accurate? https://discord.com/channels/1019350475847499849/1405446046892560384
erquhart
erquhart•2w ago
Kapa is correct, go normalized.

Did you find this page helpful?