How to create backend using ejabberd for my chat app?

I have a web chat app, and I finish front end of the web app . I want to start back end, so I do not know how can I create logical back end architect, because I want to use ejabberd with elixiri hooks, is there any open source project for it?

If you use ejabberd as the backend, there is no need for a middle tier. Ejabberd supports BOSH, which is an enhanced version of HTTP long polling, so your frontend can talk to the backend directly with it.

1 Like

tnx so much for ur comment apprciated, if I use ejabberd with elixir hook or just create my own back end with elixir will be best ?

ā€œWhat is best for meā€ is not a question other people can answer. We can give you ideas, but ultimately you have to pick your own way. Here are 3 ways to leverage Ejabberd that I can think of:

  • make a javascript frontend that talks BOSH to your instance of Ejabberd. There will be no Elixir part
  • make a Phoenix Liveview application that talks TCP XMPP to your instance of Ejabberd
  • combine your Phoenix application and your Ejabberd instance into the same OTP release and skip the network connection

The implementation will get progressively harder however you would gain tighter control from the first way to the last way.

2 Likes

Creating an ejabberd plugin using Elixir isnā€™t difficult, and communicating over XMPP using a JS library will work just fine. If this is just a ā€˜toyā€™ app then ejabberd is a completely fine choice, especially if it is used as a dep in a larger application. Running it ā€˜at scaleā€™ in a multi-node setup is much more complex and has itā€™s own challenges. Especially since it is a large code base that you donā€™t have a ton of experience with. XMPP is also a beast, and knowing the various XEPs is extremely useful, but takes time.

All of that being said, there are very simple examples of chat apps written in Elixir that youā€™ll have a good amount of control over yourself, know exactly how it works, etc. You donā€™t get the fancy guarantees, federation, and standards that XMPP gives you, but you should really ask yourself: do you need it? Are you going to support 10s of thousands of users?

3 Likes

tnx so much for ur comment, yes definitely I want to create this app for huge community, that is why I am not sure which one will be best for me, ejabberd or just own elixir chat server with xmpp?

1 Like

tnx for ur comment, for alots of users this one enough?

What do you mean by a lot? What resources do you have at your disposal? If you are a lone developer scaling is the last thing you should consider.

1 Like

alots users for chat

ā€œA lotā€ is not useful to the discussion. Do you know the general magnitude? 1000, 10k, 100k? Thereā€™s vastly different tradeoffs you can take as well as requirements to a team behind a project based on that.

1 Like

like more than one million users per day for chat app, I mean