Skip to content

๐Ÿš€ Modern real-time messaging platform built with React, Node.js, Socket.io & MongoDB. Features instant messaging, file sharing, group chats, typing indicators, PWA support & Docker deployment. Production-ready with JWT auth, Redis caching & comprehensive testing suite.

License

Notifications You must be signed in to change notification settings

SatvikPraveen/ChatVerse

Repository files navigation

ChatVerse ๐Ÿ’ฌ

ChatVerse Logo

A modern, scalable real-time messaging platform built for the next generation of communication

License: MIT Node.js React TypeScript

Live Demo โ€ข Documentation โ€ข API Reference โ€ข Report Bug


๐ŸŒŸ Overview

ChatVerse is a production-ready, real-time messaging platform designed for modern communication needs. Built with scalability, performance, and user experience in mind, it provides a WhatsApp-like experience with enterprise-grade features.

โœจ Key Highlights

  • ๐Ÿš€ Real-time Everything: Instant messaging, typing indicators, presence status
  • ๐Ÿ”’ Enterprise Security: JWT authentication, rate limiting, input validation
  • ๐Ÿ“ฑ Cross-Platform: PWA support for mobile and desktop installations
  • โ˜๏ธ Cloud-Ready: Docker containerization with Kubernetes deployment configs
  • ๐ŸŽจ Modern UI/UX: Responsive design with dark/light theme support
  • ๐Ÿ“ˆ Scalable Architecture: Microservices-ready with monitoring and observability

๐Ÿš€ Features

๐Ÿ” Authentication & Security

  • JWT-based authentication
  • Password hashing with bcrypt
  • Rate limiting protection
  • CORS security headers
  • Input validation & sanitization

๐Ÿ’ฌ Messaging Experience

  • Real-time message delivery
  • File sharing (images, videos, docs)
  • Message reactions with emojis
  • Typing indicators
  • Message history & search

๐Ÿ‘ฅ Social Features

  • Group conversations
  • User presence (online/offline)
  • Profile management
  • Push notifications
  • Contact management

๐Ÿ›  Developer Experience

  • TypeScript throughout
  • Comprehensive testing suite
  • Hot reload development
  • Docker development environment
  • Automated CI/CD pipeline

๐Ÿ— Architecture & Tech Stack

Frontend Stack

graph TD
    A[React 18 + TypeScript] --> B[Vite Build Tool]
    B --> C[Tailwind CSS]
    C --> D[Zustand State Management]
    D --> E[React Query Data Fetching]
    E --> F[Socket.io Client]
    F --> G[PWA Service Worker]
Loading

Backend Stack

graph TD
    A[Node.js + Express] --> B[TypeScript]
    B --> C[Socket.io Server]
    C --> D[MongoDB + Mongoose]
    D --> E[Redis Caching]
    E --> F[AWS S3 Storage]
    F --> G[JWT Authentication]
Loading

Infrastructure & DevOps

  • Containerization: Docker & Docker Compose
  • Orchestration: Kubernetes manifests
  • Monitoring: OpenTelemetry, Prometheus metrics
  • CI/CD: GitHub Actions workflows
  • Cloud: AWS (S3, CloudFront, ECS ready)

๐Ÿ“ Project Structure

ChatVerse/
โ”œโ”€โ”€ ๐Ÿ“ฑ apps/
โ”‚   โ”œโ”€โ”€ ๐ŸŒ web/                 # React frontend application
โ”‚   โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ components/     # Reusable UI components
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ hooks/         # Custom React hooks
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ services/      # API clients & utilities
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ store/         # Zustand state management
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ utils/         # Helper functions
โ”‚   โ”‚   โ””โ”€โ”€ public/            # Static assets
โ”‚   โ””โ”€โ”€ ๐Ÿ”ง api/                 # Node.js backend API
โ”‚       โ”œโ”€โ”€ src/
โ”‚       โ”‚   โ”œโ”€โ”€ controllers/   # Route handlers
โ”‚       โ”‚   โ”œโ”€โ”€ middlewares/   # Express middlewares
โ”‚       โ”‚   โ”œโ”€โ”€ models/        # MongoDB schemas
โ”‚       โ”‚   โ”œโ”€โ”€ services/      # Business logic
โ”‚       โ”‚   โ”œโ”€โ”€ realtime/      # Socket.io handlers
โ”‚       โ”‚   โ””โ”€โ”€ tests/         # Test suites
โ”‚       โ””โ”€โ”€ dist/              # Compiled JavaScript
โ”œโ”€โ”€ ๐Ÿ“ฆ packages/
โ”‚   โ”œโ”€โ”€ types/                 # Shared TypeScript definitions
โ”‚   โ”œโ”€โ”€ ui/                    # Reusable UI components
โ”‚   โ””โ”€โ”€ eslint-config/         # Shared linting rules
โ”œโ”€โ”€ ๐Ÿณ infra/
โ”‚   โ”œโ”€โ”€ docker/                # Docker configurations
โ”‚   โ”œโ”€โ”€ k8s/                   # Kubernetes manifests
โ”‚   โ””โ”€โ”€ terraform/             # Infrastructure as Code
โ”œโ”€โ”€ ๐Ÿ“š docs/                   # Comprehensive documentation
โ””โ”€โ”€ ๐Ÿ”จ scripts/                # Build & deployment scripts

๐Ÿš€ Quick Start

Prerequisites

Ensure you have the following installed:

๐Ÿ”ง Installation

  1. Clone the repository

    git clone https://github.com/SatvikPraveen/ChatVerse.git
    cd ChatVerse
  2. Install dependencies

    pnpm install
  3. Set up environment variables

    # Backend configuration
    cp apps/api/.env.example apps/api/.env
    
    # Frontend configuration
    cp apps/web/.env.example apps/web/.env
  4. Start development services

    # Start MongoDB & Redis containers
    pnpm docker:dev
    
    # Start development servers (separate terminal)
    pnpm dev
  5. Access the application


โš™๏ธ Configuration

Backend Environment Variables

Create apps/api/.env from the example file:

# Application
NODE_ENV=development
PORT=3001

# Database
MONGODB_URI=mongodb://admin:password@localhost:27017/ChatVerse?authSource=admin
REDIS_URL=redis://localhost:6379

# Authentication
JWT_SECRET=your-super-secret-jwt-key-minimum-32-characters-long
JWT_EXPIRES_IN=7d

# Security
CORS_ORIGINS=http://localhost:3000,https://yourdomain.com

# File Storage (AWS S3)
AWS_REGION=us-east-1
AWS_S3_BUCKET=ChatVerse-uploads
AWS_ACCESS_KEY_ID=your-access-key
AWS_SECRET_ACCESS_KEY=your-secret-key

# Push Notifications (Optional)
VAPID_PUBLIC_KEY=your-vapid-public-key
VAPID_PRIVATE_KEY=your-vapid-private-key
VAPID_EMAIL=your-email@domain.com

# Monitoring (Optional)
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318

Frontend Environment Variables

Create apps/web/.env:

# API Configuration
VITE_API_URL=http://localhost:3001/api
VITE_WS_URL=http://localhost:3001

# Features
VITE_ENABLE_PWA=true
VITE_ENABLE_NOTIFICATIONS=true

# Analytics (Optional)
VITE_GA_MEASUREMENT_ID=G-XXXXXXXXXX

๐Ÿ›  Development

Available Scripts

# ๐Ÿš€ Development
pnpm dev              # Start both frontend and backend in watch mode
pnpm dev:web          # Start only React development server
pnpm dev:api          # Start only Node.js API server

# ๐Ÿ— Building
pnpm build            # Build all packages for production
pnpm build:web        # Build React app only
pnpm build:api        # Build Node.js API only

# ๐Ÿงช Testing & Quality
pnpm test             # Run all test suites
pnpm test:unit        # Run unit tests only
pnpm test:integration # Run integration tests
pnpm test:e2e         # Run end-to-end tests
pnpm test:watch       # Run tests in watch mode

pnpm lint             # Lint all packages
pnpm lint:fix         # Fix linting issues
pnpm type-check       # TypeScript type checking

# ๐Ÿณ Docker Operations
pnpm docker:dev       # Start development database services
pnpm docker:down      # Stop all development services
pnpm docker:logs      # View service logs
pnpm docker:clean     # Clean up containers and volumes

# ๐Ÿ“Š Database Operations
pnpm db:migrate       # Run database migrations
pnpm db:seed          # Seed database with sample data
pnpm db:reset         # Reset database to clean state

๐Ÿงช Testing Strategy

# Unit Tests - Business logic & utilities
pnpm test:unit

# Integration Tests - API endpoints & database operations
pnpm test:integration

# End-to-End Tests - Complete user workflows
pnpm test:e2e

# Coverage Report
pnpm test:coverage

๐Ÿ”„ Development Workflow

  1. Feature Development

    git checkout -b feature/awesome-feature
    pnpm dev  # Start development environment
    # Make your changes...
    pnpm test  # Ensure tests pass
    pnpm lint  # Check code quality
  2. Code Quality Checks

    pnpm type-check    # TypeScript validation
    pnpm lint:fix      # Auto-fix linting issues
    pnpm test:coverage # Ensure adequate test coverage
  3. Commit & Push

    git add .
    git commit -m "feat: add awesome feature"
    git push origin feature/awesome-feature

๐Ÿ“ก API Reference

Authentication Endpoints

POST   /api/auth/register     # User registration
POST   /api/auth/login        # User authentication
POST   /api/auth/refresh      # Refresh JWT token
POST   /api/auth/logout       # User logout

Messaging Endpoints

GET    /api/conversations          # List user conversations
POST   /api/conversations          # Create new conversation
GET    /api/conversations/:id      # Get conversation details
POST   /api/conversations/:id/join # Join group conversation

GET    /api/messages/:conversationId    # Get conversation messages
POST   /api/messages                    # Send new message
PUT    /api/messages/:id               # Edit message
DELETE /api/messages/:id               # Delete message

File Upload Endpoints

POST   /api/uploads/presign      # Get S3 pre-signed URL
POST   /api/uploads/complete     # Complete file upload

Real-time Socket Events

// Client to Server
socket.emit('conversation:join', { conversationId })
socket.emit('message:send', { conversationId, content, type })
socket.emit('typing:start', { conversationId })
socket.emit('typing:stop', { conversationId })

// Server to Client
socket.on('message:received', (message) => {})
socket.on('typing:update', ({ userId, isTyping }) => {})
socket.on('presence:update', ({ userId, status }) => {})

For detailed API documentation, see API_REFERENCE.md.


๐Ÿš€ Deployment

๐Ÿณ Docker Production Deployment

  1. Build production images

    # Build all services
    docker-compose -f infra/docker/docker-compose.prod.yml build
  2. Deploy with Docker Compose

    # Start production stack
    docker-compose -f infra/docker/docker-compose.prod.yml up -d
    
    # View logs
    docker-compose -f infra/docker/docker-compose.prod.yml logs -f

โ˜ธ๏ธ Kubernetes Deployment

  1. Apply Kubernetes manifests

    # Create namespace and secrets
    kubectl apply -f infra/k8s/namespace.yaml
    kubectl apply -f infra/k8s/secrets.yaml
    
    # Deploy applications
    kubectl apply -f infra/k8s/
  2. Monitor deployment

    kubectl get pods -n ChatVerse
    kubectl logs -f deployment/ChatVerse-api -n ChatVerse

โ˜๏ธ AWS Deployment with Terraform

cd infra/terraform/aws
terraform init
terraform plan
terraform apply

๐Ÿ”ง Production Environment Variables

Ensure these are properly configured for production:

NODE_ENV=production
JWT_SECRET=<strong-production-secret>
MONGODB_URI=<production-mongodb-uri>
REDIS_URL=<production-redis-uri>
AWS_S3_BUCKET=<production-s3-bucket>
CORS_ORIGINS=https://yourdomain.com

๐Ÿ“Š Monitoring & Observability

๐Ÿ“ˆ Metrics & Monitoring

  • Application Metrics: Custom Prometheus metrics
  • Health Checks: Liveness and readiness probes
  • Error Tracking: Comprehensive error logging
  • Performance: Response time and throughput monitoring

๐Ÿ“‹ Health Endpoints

GET /health/liveness     # Application liveness check
GET /health/readiness    # Application readiness check
GET /metrics            # Prometheus metrics endpoint

๐Ÿ” Logging

Structured JSON logging with different levels:

  • Error: Application errors and exceptions
  • Warn: Performance issues and warnings
  • Info: General application flow
  • Debug: Detailed debugging information

๐Ÿค Contributing

We welcome contributions! Here's how to get started:

๐ŸŒŸ Ways to Contribute

  • ๐Ÿ› Bug Reports: Open an issue
  • โœจ Feature Requests: Request a feature
  • ๐Ÿ“– Documentation: Improve docs and guides
  • ๐Ÿ’ป Code: Submit pull requests

๐Ÿ“‹ Development Guidelines

  1. Fork the repository and create a feature branch
  2. Follow coding standards: ESLint + Prettier configuration
  3. Write tests: Maintain >80% code coverage
  4. Update documentation: Keep README and docs current
  5. Submit a pull request: Clear description of changes

๐Ÿ”„ Pull Request Process

# 1. Fork and clone
git clone https://github.com/yourusername/ChatVerse.git

# 2. Create feature branch
git checkout -b feature/your-feature-name

# 3. Make changes and test
pnpm test
pnpm lint

# 4. Commit with conventional commits
git commit -m "feat: add your feature description"

# 5. Push and create PR
git push origin feature/your-feature-name

๐Ÿ“ Code Style

  • TypeScript: Strict mode enabled
  • Formatting: Prettier with 2-space indentation
  • Linting: ESLint with custom rules
  • Commits: Conventional Commits

๐Ÿ“š Documentation

Comprehensive documentation is available in the /docs directory:

Document Description
๐Ÿ“– API Reference Complete API endpoint documentation
๐Ÿ— Architecture Guide System design and architecture decisions
๐Ÿš€ Deployment Guide Production deployment instructions
๐Ÿ”’ Security Guide Security best practices and policies
๐Ÿ“‹ Runbooks Operational guides and troubleshooting

๐Ÿ—บ Roadmap

๐Ÿ“… Current Sprint (v1.1)

  • Voice messages support
  • Message search functionality
  • Dark/light theme toggle
  • Improved mobile experience

๐Ÿ”ฎ Upcoming Features (v1.2)

  • Video calling integration
  • Message threading
  • Custom emoji reactions
  • Message scheduling

๐Ÿš€ Future Vision (v2.0)

  • AI-powered features
  • Advanced admin dashboard
  • Message encryption
  • Plugin architecture

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

MIT License

Copyright (c) 2024 Satvik Praveen

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction...

๐Ÿ™ Acknowledgments

Special thanks to the amazing open-source community and these fantastic projects:

  • Socket.io - Real-time bidirectional event-based communication
  • React - A JavaScript library for building user interfaces
  • Node.js - JavaScript runtime built on Chrome's V8 engine
  • MongoDB - The most popular NoSQL database
  • Tailwind CSS - A utility-first CSS framework
  • TypeScript - JavaScript with syntax for types

๐Ÿ’ฌ Support & Community


โญ Star this repo if you find it helpful!

Built with โค๏ธ by Satvik Praveen and the ChatVerse community

Empowering real-time communication for the modern world

About

๐Ÿš€ Modern real-time messaging platform built with React, Node.js, Socket.io & MongoDB. Features instant messaging, file sharing, group chats, typing indicators, PWA support & Docker deployment. Production-ready with JWT auth, Redis caching & comprehensive testing suite.

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published