Skip to content

cLLeB/ephemeral-chat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

70 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸŽ₯ Demo Video

Demo Video

Watch a quick demo of Ephemeral Chat in action!


πŸ“Έ Screenshots

Here’s a sneak peek at the app interface:

Home Screen Join Room UI

πŸ”’ CI/CD & Code Quality

  • GitHub Actions: Automated workflows for building, testing, and analyzing code.
  • CodeQL: Security analysis for JavaScript/Node.js and Java/Android code.
  • Gradle Build: Ensures Android app builds successfully on every push.

Ephemeral Chat

License: GPL v3 PRs Welcome Live Demo

A secure, anonymous, and ephemeral chat application with self-destructing messages. Installable as a Progressive Web App (PWA) for native-like experience.

A secure, anonymous, and ephemeral chat application with self-destructing messages. Installable as a Progressive Web App (PWA) for native-like experience. Can also be distributed as a Trusted Web Activity (TWA) for Android via the Play Store.

Report Bug Β· Request Feature

✨ Features

πŸ’¬ Rich Messaging

  • Real-Time Messaging: Lightning-fast message delivery using Socket.io
  • πŸ“ž Voice Calls: Crystal clear peer-to-peer audio calls using WebRTC
  • 🎀 Universal Voice Notes: Record audio on any device (iOS, Android, Desktop) and play it anywhere.
    • Technical Feat: Server-side conversion to AAC (.m4a) ensures seamless playback on Safari and all modern browsers.
  • πŸ“Έ Image Sharing: Share images securely with view-once capability
  • Self-Destructing Messages: Messages disappear after being read or after a set time

🏠 Room Management

  • Instant Room Creation: Generate unique chat rooms instantly with 6-digit codes
  • πŸšͺ Knock-to-Join System: Guests enter a lobby and must be approved by the host
  • πŸ‘‘ Host Controls: Room creators can approve or deny entry to pending guests
  • πŸ”„ Host Handover: Automatic ownership transfer if the host leaves
  • Anonymous Participation: No accounts or personal information required
  • Auto-Cleanup: Rooms automatically close after inactivity

πŸ›‘οΈ Security & Privacy

  • πŸ” Client-Side Encryption (E2EE): Messages are encrypted in the browser using AES-GCM. The key is in the URL hash and never reaches the server.
  • No Message Persistence: Messages are never stored permanently on the server
  • πŸ”’ Password Protection: Optional password protection for rooms
  • πŸ€– Bot Protection: Integrated Proof-of-Work CAPTCHA to prevent spam
  • πŸ›‘οΈ Brute Force Protection: Failed attempt tracking and automatic lockout
  • βœ… Input Validation: XSS prevention and credential sanitization

πŸ“± Progressive Web App (PWA)

  • Installable: Add to home screen on any device
  • Native Feel: App-like experience with splash screen and theme colors
  • Offline Capable: Core shell works offline

πŸ› οΈ Tech Stack

Frontend

  • React: UI library
  • Vite: Build tool and dev server
  • Tailwind CSS: Utility-first CSS framework
  • Socket.io Client: Real-time communication
  • WebRTC: Peer-to-peer audio calls
  • Lucide React: Beautiful icons

Android Distribution

  • Trusted Web Activity (TWA): The project includes an android/ directory with a Gradle project, allowing the PWA to be packaged and distributed as a native Android app on the Google Play Store.

Backend

  • Node.js & Express: Server runtime and framework
  • Socket.io: Real-time event-based communication
  • FFmpeg: Audio processing and conversion (with static binaries)
  • @cap.js: Proof-of-Work CAPTCHA system
  • Redis (Optional): For scaling across multiple instances

Audio Processing

  • Universal Compatibility: Automated conversion of WebM/Ogg (Android/Chrome) to AAC (iOS/Safari).
  • Smart Copy: Intelligent detection of AAC inputs to avoid unnecessary re-encoding.
  • Robust Normalization: Auto-correction of sample rates and timestamps for glitch-free playback.

PWA

  • Vite PWA Plugin: PWA generation and management
  • Workbox: Service worker libraries

πŸš€ Quick Start

Prerequisites

  • Node.js (v16 or higher)
  • npm (v8 or higher) or yarn
  • (Optional) Redis for production deployments

Installation

  1. Clone the repository

    git clone https://github.com/cLLeB/ephemeral-chat.git
    cd ephemeral-chat
  2. Install dependencies

    # Install root dependencies
    npm install
    
    # Install client dependencies
    cd client && npm install && cd ..
  3. Set up environment variables Copy the existing .env file or create one with these settings:

    # Server Configuration
    PORT=3001
    NODE_ENV=development
    
    # Security Settings (already configured)
    INACTIVITY_TIMEOUT_MINUTES=10
    MAX_FAILED_ATTEMPTS=5
    LOCKOUT_DURATION_MINUTES=10
    ROOM_CODE_SALT=your-secure-salt-here
    CAP_SECRET=your-captcha-secret-key
    
    # Room Settings
    ROOM_EXPIRY_MINUTES=60
    INVITE_TOKEN_EXPIRY_MINUTES=25
    MAX_MESSAGES_PER_MINUTE=30
  4. Start the development server

    # Start both client and server concurrently
    npm run dev
  5. Access the application

πŸ“± Progressive Web App (PWA)

Your chat application is a fully-featured PWA that can be installed on any device!

Installation

  1. Open in browser and visit the live demo
  2. Look for install prompt in your browser's address bar
  3. Click "Install" or "Add to Home Screen"
  4. Launch from home screen like a native app

PWA Features

  • Offline functionality - Chat works without internet
  • Native app feel - Custom splash screen and theme colors
  • Auto-updates - Always runs the latest version
  • Fast loading - Cached assets for instant access

Documentation

User Documentation

🀝 Contributing

Contributions are welcome! Here's how you can help:

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

See our Contributing Guidelines for more details.

πŸ“„ License

Distributed under the GNU General Public License v3. See LICENSE for more information.

πŸ“ž Contact

πŸ™ Acknowledgments


πŸ—οΈ Project Structure

ephemeral-chat/
β”œβ”€β”€ android/                  # Android TWA project (wraps the PWA for Play Store distribution)
β”‚   β”œβ”€β”€ app/                  # Android app module
β”‚   β”œβ”€β”€ build.gradle          # Gradle build files
β”‚   β”œβ”€β”€ gradlew, gradlew.bat  # Gradle wrapper scripts
β”‚   └── ...                   # Other Android/Gradle files
β”œβ”€β”€ client/                   # React frontend (Vite + PWA)
β”‚   β”œβ”€β”€ public/               # PWA assets & manifest
β”‚   β”‚   β”œβ”€β”€ manifest.json     # Web app manifest
β”‚   β”‚   β”œβ”€β”€ sw.js             # Service worker
β”‚   β”‚   └── *.png             # PWA icons
β”‚   β”œβ”€β”€ src/                  # React source code
β”‚   β”‚   β”œβ”€β”€ components/       # Reusable UI components
β”‚   β”‚   β”œβ”€β”€ hooks/            # Custom React hooks
β”‚   β”‚   β”œβ”€β”€ services/         # API integrations
β”‚   β”‚   └── utils/            # Helper functions
β”‚   β”œβ”€β”€ vite.config.js        # Vite configuration with PWA
β”‚   └── package.json
β”‚
β”œβ”€β”€ server/                   # Express + Socket.IO backend
β”‚   β”œβ”€β”€ auth-utils.js         # Authentication utilities
β”‚   β”œβ”€β”€ index.js              # Server entry point
β”‚   β”œβ”€β”€ rooms.js              # Room management
β”‚   β”œβ”€β”€ security.js           # Security middleware
β”‚   └── utils.js              # Utility functions
β”‚
β”œβ”€β”€ docs/                     # Documentation
β”‚   └── USER_GUIDE.md         # User guide
β”‚
β”œβ”€β”€ .env                      # Environment variables
β”œβ”€β”€ package.json              # Root dependencies
└── README.md

πŸ“± Android TWA Distribution

This project can be distributed as a native Android app using Trusted Web Activity (TWA). The android/ directory contains a Gradle project that wraps the PWA, allowing you to publish the app on the Google Play Store for a seamless, native-like experience.

Building the Android App

cd android
./gradlew assembleDebug  # or assembleRelease for production

The output APK will be in android/app/build/outputs/apk/.

You can customize the TWA settings and assets in the android/ directory as needed.

βš™οΈ Configuration

Environment Variables

The application uses the following environment variables (see .env file):

# Server
PORT=3001
NODE_ENV=development

# Security (REQUIRED)
INACTIVITY_TIMEOUT_MINUTES=10
MAX_FAILED_ATTEMPTS=5
LOCKOUT_DURATION_MINUTES=10
ROOM_CODE_SALT=your-secure-salt-here

# Room Settings
ROOM_EXPIRY_MINUTES=60
INVITE_TOKEN_EXPIRY_MINUTES=5
MAX_MESSAGES_PER_MINUTE=30

# Redis (optional)
# Redis (optional)
# REDIS_URL=redis://localhost:6379

### Client Environment Variables
Create a `.env` file in the `client` directory for frontend configurations:
```env
# WebRTC ICE Servers (Optional - for custom TURN/STUN servers)
VITE_ICE_SERVERS=[{"urls":"stun:stun.l.google.com:19302"}]

### Available Scripts
- `npm run dev`: Start development servers (client + server)
- `npm run server`: Start backend server only
- `npm run client`: Start frontend client only
- `npm run build`: Build frontend for production
- `npm start`: Start production server

## πŸ”§ Development

### Frontend Development
The client is built with React and Vite:

```bash
cd client
npm run dev  # Starts on http://localhost:5173

Backend Development

The server uses Node.js with Express and Socket.IO:

npm run server  # Starts on http://localhost:3001

API Endpoints

  • GET / - Health check
  • POST /api/rooms - Create room
  • GET /api/rooms/:code - Get room info
  • WebSocket events: joinRoom, sendMessage, leaveRoom

πŸš€ Deployment

The application is currently deployed on Render:

Deployment Configuration

The deployment uses the render.yaml configuration for automatic builds and deployments.


Built with ❀️ for privacy-focused communication