Skip to content

A scalable, secure, and real-time chat application built with Java, Spring Boot, Spring Cloud Gateway, JWT, WebSocket, and microservices architecture. Inspired by the infrastructure of billion-user chat platforms like WhatsApp and Messenger.

Notifications You must be signed in to change notification settings

Github-Saurabh0/Design-a-chat-app-used-by-a-billion-users-by-using-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Billion-User Chat Application

A scalable chat application designed to support a billion users, built with Java.

System Architecture

This application follows a microservices architecture to ensure scalability, reliability, and maintainability:

  • API Gateway: Entry point for all client requests, handles authentication, rate limiting, and request routing
  • User Service: Manages user accounts, profiles, and authentication
  • Chat Service: Handles message processing and delivery
  • Presence Service: Tracks online/offline status of users
  • Notification Service: Manages push notifications
  • Media Service: Handles file sharing and media processing

Technology Stack

  • Backend: Java, Spring Boot, Spring Cloud
  • Messaging: Apache Kafka, WebSockets
  • Databases: PostgreSQL (user data), Cassandra (messages), Redis (caching)
  • Deployment: Docker, Kubernetes
  • Monitoring: Prometheus, Grafana

Scalability Strategies

  • Horizontal scaling of stateless services
  • Database sharding and partitioning
  • Multi-level caching
  • Asynchronous processing
  • Load balancing

Getting Started

Prerequisites

  • Java 17+
  • Maven 3.8+
  • Docker and Docker Compose

Setup and Installation

  1. Clone the repository
  2. Run mvn clean install to build all services
  3. Use Docker Compose to start the development environment: docker-compose up

Project Structure

├── api-gateway/           # API Gateway service
├── user-service/          # User management service
├── chat-service/          # Message handling service
├── presence-service/      # Online status tracking service
├── notification-service/  # Push notification service
├── media-service/         # File and media handling service
├── common/                # Shared libraries and utilities
└── docker/                # Docker configuration files

Key Features

  • Real-time messaging with WebSockets
  • End-to-end encryption
  • Group chats and channels
  • Media sharing
  • Message persistence
  • Offline message delivery
  • Read receipts
  • Typing indicators

Performance Considerations

  • Connection pooling
  • Message batching
  • Lazy loading of chat history
  • Efficient data serialization
  • Optimized database queries

Security Measures

  • End-to-end encryption
  • TLS for all communications
  • Rate limiting to prevent abuse
  • Input validation and sanitization
  • Regular security audits

Author

Saurabh Kushwaha
🔗 Portfolio
📧 Saurabh@wearl.co.in
🔗 LinkedIn
🔗 Instagram Dev Page


License

This project is licensed under the MIT License.


Star this repo if you found it helpful!

About

A scalable, secure, and real-time chat application built with Java, Spring Boot, Spring Cloud Gateway, JWT, WebSocket, and microservices architecture. Inspired by the infrastructure of billion-user chat platforms like WhatsApp and Messenger.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages