Our New Contus Dart - Last Mile Delivery App is Just Out!Check it out

How WhatsApp works and how to build a WhatsApp clone?

WhatsApp is the most sought after messaging application that has revolutionized the messaging app market and has inspired a bunch of clones and competitors as well. On the flipside, many among those cloning attempts are unable to match the standards of WhatsApp.

WhatsApp clones which promise to have similar functionalities as that of the market giant are either a mere email messaging systems showcased as a messaging system or doesn’t use/follow even half of the technical aspects of WhatsApp.

In order to build a WhatsApp like chat application, one should have a detailed understanding of its functioning mechanism and technicalities.

How Whatsapp Messaging App is Working Technically?

create a clone app similar to whatsappWhatsApp is a real-time messaging application, which makes use of Ejabberd (XMPP) server. This server facilitates instant message transfer between two or many users at any given second.

ERLANG is the programming language used by WhatsApp. Ejabberd is an open source Jabber server written in Erlang language. It was preferred by the techies of WhatsApp as it was suitable for accommodating huge communication system with high sustainability.

However, while building a WhatsApp like app, a lot more efforts were put in like modifications in Ejabberd, opting for an in-house protocol from XMPP, code restructuring and incorporating important changes in Erlang. These tweaks contributed towards achieving optimal server performance.

Erlang also helps by quickly adapting to instant updates and hot fixes. Whatever may be the improvisations or coding improvements, Erlang helps in quickly pushing the changes to live implementation without needing restarts. Thus any changes can be rolled out in quick time and succession.

1. Insights on data transfer in WhatsApp

how whatsapp works technicallyWhatsApp manages over 50 billion message transfers a day. So how these ever-lasting queues of messages are processed without hiccups? The key to the smooth data processing lies with the message queue length. The length of the message queue of all the processes associated with a node is monitored.

In case of multimedia messages, contents (audio, video, or image) are uploaded into a HTTP server and are linked with the content and then sent to the receiving node (receiver) in the form of a thumbnail. Based on the user’s preference the content can either be viewed or discarded.

2. Protocol used by WhatsApp

XMPP (Extensible Messaging and Presence Protocol) is being used by WhatsApp. To ensure network security, DSL is being used. This ensures private data transfer.

As and when message is sent, it is queued on the server. The message waits in the queue until the recipient reconnects to receive the message. As and when a message is delivered the sender gets notified by a double check mark near the message. After the delivery the messages are instantly deleted from the server memory.

3. Registration process of WhatsApp

Whatsapp Registration ProcessWhatsApp followed the regular practice of generating a user name and password, which we commonly do while signing up for a mailing system, based on the mobile phone’s IMEI number.

Now the practice has been changed. Instead of being dependent on the IMEI number, WhatsApp now asks for the app to send a 5 digit PIN. A message will then be sent to the phone number from WhatsApp. The app on the mobile device requests for a unique key from WhatsApp. This ditches out the dependency of WhatsApp being used on the device.

4. Database management

For the database management Mnesia DB comes into play. Mnesia is a multiuser distributed DBMS which happens to be the default DB of ERLANG. Thus by using Mnesia, the app is able to achieve quicker request responses, thereby improving the overall efficiency.

FreeBSD is the operating system upon which WhatsApp is laid upon. Improvising on the ERLANG based applications and optimizing FreeBSD, WhatsApp is able to achieve better throughput. For storing multimedia files, the app uses an exclusive web server YAWS.

5. End-to-end encryption

Whatsapp’s end-to-end encryption is something which assures the safety of your data be it text or multimedia content. End-to-end encryption completely revolves around a token. The token exchange prepares your phone to encrypt and decrypt messages. When Whatsapp sends you a 4 digit number to your phone, your smartphone becomes ready for this encryption and decryption task.

When you send messages, you phone does the encryption and send it to Whatsapp server. The server gets the replies from the receiver’s end, encrypts it and sends to your smartphone. Now, your phone decrypts the messages and displays it.

How does Whatsapp web work technically?

 

The Whatsapp web is as interesting as its mobile counterpart. It is the question of how the web version syncs with the app which leaves everyone intrigued. So here it is.

It’s a known story that Whatsapp doesn’t use the regular username & password route to authenticate the user. Likewise the authentication for the Whatsapp web and mobile account sync happens through QR Code.

How does Whatsapp web QR code work?

watsapp web QR code

So, now the question is why QR code? Well, the smartness of the app lies here. Besides smartphones users are used to QR codes there lies a small communication which makes the sync happen.

Whatsapp mobile app, Whatsapp web app and the server are those in the communication loop here. First, you go for the Whatsapp web version in chrome and it asks you to scan the QR code.

Your Whatsapp web version requests for permission to Whatsapp’s server. Whatsapp server will approve it only when your mobile app version authenticates it. Here is where the QR scanning action comes into play.

The scan reads the QR code and the authenticating token which allows the phone to authenticate. Upon authentication from the mobile app end, Whatsapp’s server allows the web version to access the account (mobile app).

So, now the sync authentication is done. What does Whatsapp web version do to sync the stored chat history to the web version. Yup here it is. Whatsapp uses HTML5 WebSockets which communication technology which was developed for two-way communication.

Build a Whatsapp like Messaging App with Contus Fly

Having discussed the technicalities of WhatsApp it is time to shift gears over analyzing the possibilities of creating a whatsApp alternative. There are plenty of messaging applications in the market that appear to be perfect WhatsApp clones. The reality is many of the attempts of building WhatsApp like apps are failing because they do not follow the technical aspects.

Well, if we take such apps as an example, it might be quite difficult to understand as they are completely built products. Instead a ready made solution that can help in creating a WhatsApp clone app would be a better learning material.

Contus Fly is a framework that catalyses the build of an instant messaging application. Contus Fly can be used to develop WhatsApp clone app for Android, iOS and Windows platforms as it has the SDK ready for these widely preferred mobile operating systems. Since native coding has been used by Contus Fly to achieve better speed, it can be handy in developing a WhatsApp like native app.

Framework & Architecture of Contus Fly

contus fly real time chat app work flow

Ejabberd

Ejabberd, the open source Jabber server has been customized by Contus Fly to improve operational efficiency. The XMPP protocol has also been customized to speedup signing in and re-signing in sessions. To protect the app from DDOS attacks and to prevent account spoofing, this mobile chat application has been encrypted with HMAC.

Mnesia and MySQL

For data storing, Contus Fly makes use of both Mnesia and MySQL. While Mnesia is used to maintain user login sessions, MySQL contributes in maintaining the user details, right from account credentials to other personal data.

Cassandra database

Chat logs are a key for instant messaging applications. In order to save chat history between several nodes, Contus Fly has deployed . This database offers a good read write speed thus helping users to retrieve chat logs as and when they need.

Amazon S3 bucket

Multimedia messages including audio, image, video are saved in Amazon S3 bucket. Registration for the app usage can be done in multiple ways including mobile number, email, user name password and social login.

As and when a user triggers a message, the app’s SDK sends a request to the Ejabbered server. In return the server checks for the availability of the recipient and if available, the delivery request is sent to the recipients SDK and then delivered. If the recipient is offline, the data is stored in the Ejabbered as message will be queued in the server.

Contus Fly Features

  • Group Chat
  • Offline Messages
  • Push Notifications
  • Presence
  • Social Integrations
  • Locations
  • Sync and Store
  • Voice Calling
  • Video Calling
  • Multimedia Sharing
  • Easy Screen Sharing
  • Fully Searchable
  • Secure
  • Support

Create Real Time Chat & IM Apps with Contus Fly

  • 100% Customizable Solutions
  • Multi Platforms Supports
  • Authenticates using Social Networks
Whatsapp_footerbtn

Leave a Reply

97 Comments on "How WhatsApp works and how to build a WhatsApp clone?"


Guest
Jenifer
2 months 28 days ago

I understand that this is not a framework to develop apps. You already have the app developerd and ready to launch. Do you have the option to create stories just like Snapchat and instagram

Guest
gery
3 months 1 day ago

Hello, is it possible for you to create an app for me that an improvement of whatsapp? i would like to be able to make conference calls or group calls with that app and i would also like to have video calls with that app. wetchat has a video call but not a group call.

Guest
Fijoy Roy
3 months 15 days ago

Hello Ramanathan, This blog gives enough of technical info for creating a chat application similar to whatsapp. Thanks for sharing!

Guest
Karthik
3 months 21 days ago

Hi Ramanthan, i have one doubt.. if whatspp is not storing text messages in their server after it is sent..then how the cyber cell monitors the unwanted messages in whatsapp??
Can u pls explain it technically.?

Guest
Dan McKinley
3 months 28 days ago

What will be the market cost for developing a whatsapp clone?