Skip to content

aritradevelops/hush

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Logo

Hush

A modern, full-stack end-to-end encrypted chat application for secure communications

Live Demo TypeScript Node.js PostgreSQL

Hush delivers privacy-first messaging with end-to-end encryption, ensuring your conversations remain completely private. Built with modern technologies for seamless performance across all devices.


Backstory / Inspiration

  • When I started this project there were many questions in my head like how to manage socket, authentication, authorization, encryption, database layer, read receipts, file encryption, private chat, group chat, web workers, multipart upload, secure key exchange and many more. Of course there are many tutorials which covers chat application, mostly they does not cover any of the above mentioned, just the basic concepts. So with this repository I tend to share my findings and a decent implementation putting all the pieces together. I hope it guides the future me's :)

โœจ Features

๐Ÿ” Security & Privacy

  • End-to-end encryption - Messages encrypted with AES-GCM, media with AES-CTR
  • RSA key exchange - Secure 2048-bit RSA key pairs for initial key establishment
  • Zero-knowledge architecture - Server cannot read your messages or access encryption keys
  • Secure file sharing - Documents, images, and media encrypted before upload

๐Ÿ’ฌ Messaging

  • Direct messaging - One-on-one conversations
  • Group messaging - Secure group chats with multiple participants
  • Read status tracking - Know when messages are delivered and read
  • Rich media support - Share images, documents, and files securely

๐Ÿ‘ฅ User Management

  • Block users - Control who can contact you
  • User profiles - Customizable user information
  • Online status - See when contacts are active

๐ŸŽฏ Coming Soon

  • Video conferencing with scalable SFU architecture
  • Message reactions and emoji responses
  • Message replies and threading
  • Message deletion and editing
  • Enhanced media preview - In-app image and video preview

๐Ÿš€ What Makes Hush Different

  • Client-Side Encryption: All encryption happens in your browser using Web Crypto API

    • AES-GCM for message encryption with authenticated encryption
    • AES-CTR for media files with stream-based encryption
    • RSA-2048 key pairs for secure key exchange protocols
  • Performance Optimizations

    • Web Workers: Multipart uploads and chunk processing in background threads
    • Smart File Handling: Large files chunked, uploaded, and reassembled efficiently
    • Progressive Downloads: Media files downloaded in chunks and merged seamlessly

Scalable Architecture

  • Horizontally Scalable: Socket.io servers with Redis pub/sub for multi-instance support
  • JWT + RBAC: Role-based access control with secure token management
  • Database Optimization: Custom query generation and TypeORM for complex relationships

Developer Experience

  • Auto-Generated CRUD: CLI tools for rapid API development
  • Type Safety: End-to-end TypeScript with custom type definitions
  • Background Processing: Web Workers handle heavy crypto operations without blocking UI
  • Real-time Everything: Socket.io for instant message delivery and presence updates

๐Ÿš€ Quick Start

For setup and development instructions, see the contribution guide:

  • Read: CONTRIBUTING.md โ€” includes end-to-end server and client setup steps
  • Issues and PR workflow are also documented there

๐Ÿ› ๏ธ Development

Project Structure

hush/
โ”œโ”€โ”€ server/             # Backend API server
โ”‚   โ”œโ”€โ”€ src/            # Source code
โ”‚   โ”œโ”€โ”€ @types/         # Global Types
โ”‚   โ”œโ”€โ”€ cli/            # CLI for generating CRUD & query
โ”‚   โ”œโ”€โ”€ db/             # Docker compose file for spinning postgres individually
โ”‚   โ”œโ”€โ”€ docs/           # Documentation
โ”‚   โ”œโ”€โ”€ local/          # Internationalization
โ”‚   โ”œโ”€โ”€ queries/        # Complex sql queries (code is auto-generated)
โ”‚   โ”œโ”€โ”€ migrations/     # Database migrations
โ”‚   โ””โ”€โ”€ docker-compose.yml
โ”œโ”€โ”€ clients/
โ”‚   โ””โ”€โ”€ web/            # Frontend web application
โ””

Available Scripts

Server

npm run dev          # Start development server
npm run prod         # Start production server
npm run prod:watch   # Start production server in watch mode
npm run build        # Build for production
npm run cli g:crud <ModuleName(In Pascal Case)> # Generate a new CRUD Module
npm run cli r:crud <ModuleName(In Pascal Case)> # Remove a CRUD Module
npm run cli g:query  # Generate code for SQL queries written in queries directory

Client

npm run dev           # Start development server
npm run build         # Build for production
npm run build:workers # Build the web workers
npm run watch:workers # Build the web workers in watch mode
npm run start         # Start production server

๐Ÿ” Security Architecture

Client-Side Encryption

  • Message Encryption: AES-GCM (Galois/Counter Mode) with authenticated encryption

    • 256-bit keys with built-in authentication
    • Prevents tampering and ensures message integrity
    • Unique nonce for each message
  • Media Encryption: AES-CTR (Counter Mode) for streaming encryption

    • Efficient for large files with parallel processing
    • Stream cipher perfect for chunked uploads/downloads
    • No padding required, works with any file size

Secure Key Exchange

  • RSA Key Pairs: 2048-bit RSA encryption for initial key establishment
  • Secure Storage: Keys stored in browser's IndexedDB with additional encryption layer

Authentication & Authorization

  • JWT Authentication: Stateless tokens with configurable expiration
  • Role-Based Access Control (RBAC): Granular permissions system
  • Refresh Token Rotation: Automatic token refresh with security best practices
  • Session Management: Secure logout and session invalidation

Data Protection

  • Zero-Knowledge: Server never has access to decryption keys or plaintext

๐Ÿ—๏ธ Tech Stack

Backend

  • Runtime: Node.js with TypeScript
  • Framework: Express.js with custom middleware
  • Database: PostgreSQL with TypeORM
  • Real-time: Socket.io with Redis pub/sub for horizontal scaling
  • Authentication: JWT with RBAC implementation
  • File Storage: Local filesystem / AWS S3 with multipart uploads
  • Video Infrastructure: SFU (Selective Forwarding Unit) architecture

Frontend

  • Framework: Next.js with TypeScript
  • UI Library: React with Tailwind CSS
  • State Management: React Context + Custom hooks
  • Real-time: Socket.io client with auto-reconnection
  • Encryption: Web Crypto API with custom implementations
  • File Handling: Web Workers for background processing
  • Performance: Chunk-based uploads/downloads with progress tracking

DevOps

  • Containerization: Docker & Docker Compose
  • Development: Hot reload, TypeScript, ESLint
  • Deployment: Production-ready Docker images

๐Ÿ“‹ Roadmap

Phase 1: Core Messaging โœ…

  • End-to-end encrypted messaging
  • User authentication and profiles
  • Direct and group messaging
  • File sharing with encryption
  • Read status and user blocking
  • Database migrations

Phase 2: Enhanced Features ๐Ÿ”„

  • Message replies and threading
  • Message reactions with emojis
  • Message deletion and editing
  • Enhanced media preview
  • Push notifications

Phase 3: Advanced Communication ๐Ÿ”ฎ

  • Video conferencing with SFU
  • Voice messages
  • Screen sharing
  • File collaboration tools

Phase 4: Platform Expansion ๐Ÿš€

  • Mobile applications (iOS/Android)
  • Desktop applications (Electron)
  • Browser extensions
  • API for third-party integrations

๐Ÿค Contributing

We welcome contributions! Please see our Contributing Guide for details.

๐ŸŽฏ Hacktoberfest 2025

This project is participating in Hacktoberfest 2025! We welcome contributions from developers of all skill levels.

Good First Issues: Look for issues labeled with good first issue, hacktoberfest, or help wanted.

Contribution Types:

  • ๐Ÿ› Bug fixes
  • โœจ New features
  • ๐Ÿ“š Documentation improvements
  • ๐Ÿงช Test coverage
  • ๐ŸŽจ UI/UX enhancements
  • ๐Ÿ”’ Security improvements

Development Workflow

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Commit your changes (git commit -m 'feat: Add amazing feature')
  5. Push to the branch (git push origin feature/amazing-feature)
  6. Open a Pull Request

Code of Conduct

Please read our Code of Conduct before contributing.


๐Ÿ“„ License

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


๐ŸŒŸ Support

Community

Maintainers

Contributors

@vansh2408 @princyballabh @bharateshwq @AtulPandey25

๐ŸŽฏ Hacktoberfest 2025

This project is participating in Hacktoberfest 2025! We welcome contributions from developers of all skill levels. Check out our Contributing Guide to get started.

Good To Know

  • As only one instance of the server is running I have not implemented any code for synchronizing the server's socket state. by default socket server's are not horizontally scalable. To achieve horizontal scalability please follow this official guide here

๐Ÿ”’ Try Hush Live | ๐Ÿ› Report Bug

Made with โค๏ธ for privacy-conscious users worldwide

Your conversations, truly private.

Releases

No releases published

Packages

No packages published

Contributors 5