Saturday, 12 April 2025

System Design: Architecture Design Diagram : "Chat Application like WhatsApp".

 WhatsApp System Design with 1-to-1 Messaging Flow




📦 Component Breakdown

  • Client (Mobile/Web App): UI for composing and receiving messages.
  • API Gateway: Validates JWTs, rate-limits, logs, and forwards requests.
  • Authentication Service: Authenticates users and issues JWTs.
  • Message DB: Stores messages and metadata.
  • Message Queue: Kafka or RabbitMQ for asynchronous message handling.
  • Push Service: Delivers notifications using FCM or APNs.
  • Redis Cache: Fast storage for recent messages, states, and presence.
  • Notification Service: Consumes from the queue and triggers push.
  • Firewall & Encryption: TLS encryption, network rules, and key management.
  • User DB: Stores user profiles, keys, and metadata.

📩 1-to-1 Message Flow (User A → User B)

Step 1: User A types and encrypts the message using User B’s public key. The message is sent via HTTPS to the backend.
Step 2: API Gateway verifies JWT and forwards to the messaging service.
Step 3: Messaging Service queues the message in Kafka/RabbitMQ.
Step 4: Notification Service stores the message and updates the cache.
Step 5: Push Notification is sent via Push Service to User B’s device.
Step 6: User B’s app fetches and decrypts the message using their private key.
Step 7: Read receipts and delivery confirmations are updated.

🔐 Security Layers

Layer Security Feature
Firewall Blocks unauthorized traffic to internal services.
TLS Everywhere Encrypted communication across all APIs and services.
JWT Tokens Authenticated and stateless user sessions.
End-to-End Encryption Only sender and receiver can read messages.
Encrypted Storage All media and sensitive data stored in encrypted form.

No comments:

Post a Comment