Some Dashboard architectural questions in Phoenix

So first, this is my first post here at ElixirForum, though I’ve read lots of topics over the years. But now I’ve been hired to build out this companies internal admin/CMS pages… and I’m a bit stumped on how to approach this.

The client wants a bunch of widgets on the page, many of which can be clicked on to occupy their own page with maybe a few others on the details page. Things like employee tasks, products, contact lists, etc. These collections of widgets are different for sales, finance, etc. Some attention to roles is necessary: when a team manager sees the customers list, they can move the customer between various account managers, while the account manager only sees their list–that kind of thing.

Logically, it seems that each widget would be its own context in Phoenix that has whatever database and views necessary to generate the html for that widget. That seems to be no problem–build one widget at a time and so forth.

The problem is: how do I display all of these widgets, especially since the layout and which are displayed will change depending on the logged in employee? Is this usually done with like a loop that renders a bunch of partial templates? Or am I looking at building something like an Elm fronted (or Ember or React or whatever) and a truly massive channel that is responsible for talking to ultimately 30, 40 different widgets? That seems error prone!

I would imagine that Lots of people here have built these kinds of things. What’s usually the best design guidelines here? I keep thinking of a widget as a plugin, which should be self contained but easily moved around. Plugins seem to violate MVC though, don’t they? I really don’t think a 1500 odd line controller sounds like the answer, but right now it appears to be what I’ll have to build. Or am I going about it all wrong?

Thanks!

You can prepare different html.eex templates for the various roles and render them cobditionally based on logged in user role in the action controller.