Creating a chat for a site with a client-server-client architecture

You need to create a standard chat with the ability to send text messages, emojis( in principle, I think this is not a problem ), files. The chat interface is already written. I scrolled through the Internet in search of information, and eventually realized that there are too many options: they offer to integrate existing chat systems( not suitable, I want to understand it myself), chat on sockets via js( priority), chat on sockets via php( not quite suitable, since js is easier for me ). Maybe there's more some options, I hope you can tell me.


At the moment, I have the following understanding of the necessary steps for my project:

  1. Each client has a unique ID ID.
  2. The client selects a specific interlocutor from the list of suggested
  3. The chat is opened; messages are loaded between the interlocutors, if there are any (perhaps the last 50 messages could be saved in the session or localstorage, for more optimal performance work); Connecting the client to the socket.
  4. After sending a message to one of the clients, the message is recorded in the database, and if the recording is successful, it is output to the interlocutor( similar to files).

On theory, it seems simple enough, but I feel that it is not so. If you are wrong about something, correct it. We need your advice and the necessary Internet resources that could help a beginner-average person create a chat that meets this requirement.

Author: Kirzzz, 2020-06-25