System and Design Thinking
System Design:
WhatsApp's architecture is built around five core engineering principles: real-time delivery, reliability at massive scale, extreme efficiency, end-to-end encryption by default, and minimal server-side storage. Understanding these principles is important because they directly constrain and shape what AI features are possible to build on top of WhatsApp without breaking its fundamental privacy model.
The system has six layers that work in sequence every time a message is sent.
The client layer is the app running on your phone. Every device runs the Signal Protocol, which handles end-to-end encryption. When you type a message and hit send, your phone encrypts it before it leaves your device. WhatsApp's servers never see the plaintext content of your messages. Ever. The app also maintains a local SQLite database which stores your entire chat history on your device. This is why switching phones requires a chat backup and restore process.
The edge and load balancing layer sits between your device and WhatsApp's core infrastructure. WhatsApp maintains Points of Presence geographically distributed around the world, including in India. When you open the app, a persistent WebSocket connection is established between your device and the nearest edge server. This connection stays alive in the background, which is how messages arrive instantly without the app having to constantly poll a server asking if anything new has arrived. TLS termination, traffic routing, and load balancing all happen at this layer.
The chat server layer is the heart of the system and WhatsApp's most famous engineering decision. The chat servers are built in Erlang, a programming language originally designed for telecoms infrastructure. Erlang's actor model allows a single server node to maintain approximately 2 million concurrent connections simultaneously. Each user connection is a lightweight process in Erlang's runtime. This is why WhatsApp famously served 450 million users with a team of only 32 engineers before the Facebook acquisition. The efficiency of Erlang made massive scale possible with minimal infrastructure.
The message delivery flow works as follows. When Arjun sends a message to Sneha, his phone encrypts it, sends it to the nearest WhatsApp chat server, which forwards it to Sneha's chat server, which delivers it to Sneha's device where it is decrypted. If Sneha is offline, the message is held in a Kafka-based message queue until she comes online, at which point it is delivered and then deleted from the server. Messages are not stored persistently on WhatsApp's servers after delivery. This is both a privacy feature and a significant cost saving.
The group messaging layer handles the fan-out problem. When Sunita sends a message to her 120-member mahila mandal group, the server must deliver copies of that message to every online member and queue it for every offline member. This fan-out operation is expensive at scale and is the primary engineering reason why WhatsApp group size is capped at 1024 members. The group service maintains membership lists and coordinates delivery across all members.
The media service handles photos, videos, documents, and voice notes differently from text messages. Media files are encrypted on your device, uploaded to WhatsApp's blob storage and CDN, and the actual chat message only contains a URL and a decryption key. The media sits on the CDN for approximately 13 days if undelivered. This separation of media from messages keeps the chat server lightweight and allows media to be served from geographically close CDN nodes for faster delivery.
The storage layer at the bottom uses a combination of Mnesia and Cassandra for message metadata and transient storage, WhatsApp's own CDN for media, and MySQL for user account data and contact information.
The critical architectural fact for the AI proposal is this: because messages are encrypted end-to-end and not stored on servers, any AI feature that needs to read message content must run on-device rather than in the cloud. This is a hard constraint that shapes every AI feature decision WhatsApp can make. It is also, paradoxically, a competitive advantage, because if WhatsApp can build powerful on-device AI that respects encryption, no competitor can replicate it without rebuilding their entire architecture.
Competitive Landscape:
The most important insight from the competitive landscape is not where WhatsApp is behind today. It is that the gap nobody has closed is AI within end-to-end encryption at scale. Telegram offers AI summaries but sacrifices encryption to do it, storing messages on its servers in plaintext. WeChat has the deepest AI integration of any messaging platform but operates under Chinese state surveillance with zero privacy. Signal has the strongest privacy model but has made a philosophical decision to avoid AI entirely. iMessage is building AI through Apple Intelligence but is irrelevant to 95% of India's Android-first market.
WhatsApp sits at a unique intersection: 500 million Indian users, end-to-end encryption that users trust, a device footprint that skews Android but is increasingly capable, and Meta's AI research resources including LLaMA models that can be compressed and run on-device. The strategic opportunity is to build AI that works within the encryption model rather than around it. That is what the AI proposal section will address in full.


