I want to create a simple real time chat which stores even stores old messages and can access them when I'll be online. Any tips ?

For detailed information, you can walk through this video:

Here is the source code of Chat Application by another YouTube Creator.

Here is an explanation of the source code— https://youtu.be/XkV9XdHueL8