Multi-user chat application

I’m wondering whether it would be possible to create a multithread socket chat in streamlit that would allow users to send messages to each other. Basically a st.chat_messages group chat. Any ideas?

For every chat message, record the message and the userid that sent that message. You can use a database for this.

Whenever there are changes in the database, send the history of the chat to every user, so that all can see them. Or just update the chat board every 1 second or so.