Hi Friends - I’d appreciate your advice. We’re building an app for university classes that is roughly a real-time Q&A board akin to the erstwhile Google Moderator. Teachers create topics, within a topic students ask questions, they can vote and comment on others’ questions.
The main view is a real-time list view of questions sorted by votes: those with the most bubble to the top. We have a “regular” version of this app written in Phoenix and are now moving to LiveView in order to make it real-time. We’d appreciate your critique of the following architecture for propagating database changes in real-time changes to the attached clients.
- PostgreSQL tables have trigger that call pg_notify
- A GenServer catches those using Postgrex.Notifications
- The GenServer sends notifications to LiveComponent processes that are subscribed to topics like “questions:384”, where “384” is the primary key of a particular question.
- In the view, each question shown is a LiveComponent.
Is that a good way to approach the problem?
I am worried about the memory requirements so I intend to use temporary_assigns
in the livecomponents. I should mention, I’m a phoenix noob but experienced full stack dev.
Thanks! Kyle