However, more important than the implementation language is the protocol you are using. So far, this is probably something you didn't spend much time on since you had just one client and the server was more or less just Firebase. But as soon as you want to allow others to run their own servers (they might want to because they trust only themselves), you need at least some kind of server-to-server (s2s) protocol. If you want other developers to build clients for your network, you will also have to define a client-to-server protocol (c2s).
A well-known standard in this regard is XMPP and another competing is Matrix. XMPP is much older and part of the 'official' standards by the Internet Engineering Task Force, while Matrix is younger and setting a stronger focus on what the server should do.