Simple, Fast Node.JS chat server — Simple-Chat

Davids Murafa
3 min readFeb 25, 2021

Now we cannot imagine our life without chat applications. People are able to reach anyone by simply sending a text message. Currently, you can find a lot of different chat apps, so it became standard that we can communicate with each other and businesses using text messages. Those who build apps for businesses or even those who build their dream app, or just for hobby, want to implement chat into their apps.

I also faced such a need to implement Chat into my mobile app. In the begging, I made a simple custom module in my app’s backend which was working as a chat gateway. Later I understood that there are much more aspects that should be considered when building a chat backend.

The main features which people need when they are implementing chat is:

  • Possibility to create multi-user chat rooms.
  • Possibility to create single-user chat rooms (just person-to-person communication).
  • Store chat archive, with the possibility to fetch it.
  • Handle offline user chat messages — deliver a push notification to an offline user.
  • Deliver undelivered messages on reconnect.
  • Be sure that messages were delivered.

Maybe I missed some features, but for me, those were some of the most important things in the chat app.

Then after understanding the needs I found an Ejabberd chat server, which is a very good chat server, which is used by big chat applications.

After implementation and tests, I came to the conclusion that this chat server is overkill for me, and it is also a problem for me to maintain and develop new features, as it is written in Erlang, which is not the most popular language.

Then I decided to build my own chat server which will support basic functions and will be written on Node.JS.

I inspired by the Ejabberd chat server, but left features which I specifically need and which I believe need most of the people.

As a result, I am glad to present — Simple-Chat chat server which is built in Node.JS using TypeScript, Inversify.JS, RethinkDB, and Socket.IO.

Here is the link to the chat server repository:

Here is the link to the chat server client repository:

Need to mention that Simple-Chat was built to work with the main API backend server.

Recommended setup would be like this:

Simple-Chat recommended setup

Simple-Chat has an API method that helps you to integrate the Simple-Chat server with your API. We can call the Simple-Chat server a message delivery system, which ensures that message will be delivered.

To send offline message Push Notifications you can provide API URL to which to push offline message — for example, you can handle such cases in the main API.

Features that are supported in this package is:

  • Multi-user chats.
  • Single-user chats.
  • Guaranteed delivery.
  • Offline message handling.
  • Message archive storage and retrieval.
  • API to manage chats in the system.
  • Connection using WebSockets.
  • Message typing state broadcast — so you can show that chat user is typing message.

I think those are basic chat server features which you could use.

As this is a new package, there could be bugs and design gaps, but as I mentioned now it is written in TypeScript so it will be much easier to maintain and fix those issues.

I encourage you to try Simple-Chat to see how it works.

I will continue to improve Simple-Chat, but as of now first, beta is released, so we can start using it. If you are interested in this chat server, go to GitHub to see documentation and installation instructions.

Thank you for reading!

--

--