Skip to content

aditya8Raj/anon-chat

Repository files navigation

Anonymous Chat Logo

💬 Anonymous Chat

Real-time anonymous chat rooms with zero data storage

Next.js TypeScript Socket.io Tailwind CSS MIT License

Live Demo


🌟 Overview

Anonymous Chat is a privacy-first, real-time messaging application that enables instant communication without any data persistence. Built with modern web technologies, it provides a secure, ephemeral chatting experience where conversations vanish the moment participants leave.

🔐 Privacy Promise: No databases, no logs, no history. Your conversations are truly temporary.


✨ Key Features

🔒 Privacy First

  • Zero Data Storage - No databases or logs
  • Truly Anonymous - No registration required
  • No Chat History - Messages exist only in memory
  • Ephemeral Rooms - Auto-deleted when empty

🚀 Real-time Experience

  • Instant Messaging - WebSocket-powered communication
  • Live Typing Indicators - See who's typing in real-time
  • Online Status - Track active participants
  • No Lag - Optimized for speed

🎨 Modern Design

  • Responsive UI - Works on all devices
  • Dark Theme - Easy on the eyes
  • Smooth Animations - Polished user experience
  • Mobile Optimized - Touch-friendly interface

🎯 How It Works

graph LR
    A[👤 User Visits] --> B{Action?}
    B -->|Create| C[🆕 Generate Room Code]
    B -->|Join| D[🔑 Enter Room Code]
    C --> E[📋 Share Code/Link]
    D --> F[✍️ Enter Display Name]
    E --> F
    F --> G[💬 Start Chatting]
    G --> H[👋 Leave Room]
    H --> I[🗑️ Messages Vanish]
Loading
  1. Create a Room - Get a unique 8-character room code
  2. Share the Link - Copy and send the room URL or code
  3. Join & Chat - Enter your display name and start messaging
  4. Leave Anonymously - No trace left behind when you exit

🛠️ Tech Stack

Layer Technology Purpose
Frontend Next.js React framework with SSR
Language TypeScript Type-safe development
Styling Tailwind Utility-first CSS
Backend Node.js JavaScript runtime
Real-time Socket.io WebSocket communication
State React Client-side state management

Architecture

┌─────────────────────────────────────────────────────────────┐
│                        Client (Browser)                      │
│  ┌────────────────────────────────────────────────────────┐ │
│  │  Next.js App (React + TypeScript)                      │ │
│  │  • Page Routing                                        │ │
│  │  • Socket.io Client                                    │ │
│  │  • Tailwind CSS Styling                                │ │
│  └────────────────────────────────────────────────────────┘ │
└───────────────────────────┬─────────────────────────────────┘
                            │ WebSocket Connection
                            ↕
┌───────────────────────────┴─────────────────────────────────┐
│                      Custom Node Server                      │
│  ┌────────────────────────────────────────────────────────┐ │
│  │  Socket.io Server                                      │ │
│  │  • Room Management (In-Memory)                         │ │
│  │  • Message Broadcasting                                │ │
│  │  • User Presence Tracking                              │ │
│  └────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
                    ⚠️ No Database Layer ⚠️

🚀 Getting Started

Prerequisites

Node.js npm

Ensure you have Node.js 18+ and npm 8+ installed on your machine.

node --version  # Should be v18.0.0 or higher
npm --version   # Should be 8.0.0 or higher

Installation

1️⃣ Clone the repository

git clone https://github.com/yourusername/anon-chat.git
cd anon-chat

2️⃣ Install dependencies

npm install

3️⃣ Run development server

npm run dev

4️⃣ Open in browser

Navigate to http://localhost:3000 🎉

Production Deployment

# Build the application
npm run build

# Start production server
npm start

The server will start on port 3000 (or PORT environment variable).


📁 Project Structure

anon-chat/
├── 📄 server.js                    # Custom Node.js + Socket.io server
├── 📄 next.config.js               # Next.js configuration
├── 📄 tailwind.config.js           # Tailwind CSS configuration
├── 📄 tsconfig.json                # TypeScript configuration
├── 📦 package.json                 # Dependencies and scripts
│
└── 📂 app/                         # Next.js App Router
    ├── 📄 layout.tsx               # Root layout with metadata
    ├── 📄 page.tsx                 # Home page (create/join room)
    ├── 📄 globals.css              # Global styles and animations
    │
    └── 📂 chat/
        └── 📂 [roomCode]/
            └── 📄 page.tsx         # Chat room interface

🎨 Features in Detail

🔐 Privacy & Security

  • No Database - All data stored in server memory only
  • Auto-Cleanup - Rooms deleted automatically when empty
  • No Tracking - Zero cookies, analytics, or user identification
  • Client-Side Only - Display names never leave the socket connection
  • No History - Late joiners cannot see previous messages

💬 Chat Functionality

  • Real-time Messaging - Instant message delivery via WebSockets
  • Room System - Unique 8-character alphanumeric room codes
  • Multi-User Support - Unlimited participants per room
  • Typing Indicators - See when others are composing messages
  • User Presence - Live count of online participants
  • Join/Leave Notifications - System messages for user activity
  • Link Sharing - One-click copy of room invitation link

🎯 User Experience

  • No Registration - Start chatting immediately
  • Name Selection - Choose any display name per room
  • Mobile Responsive - Optimized for phones and tablets
  • Dark Mode - Modern dark theme with gradient backgrounds
  • Smooth Animations - Fade-in effects and typing indicators
  • Keyboard Shortcuts - Press Enter to send messages
  • Auto-Scroll - Messages automatically scroll to bottom

🌐 API Events

Client → Server

Event Payload Description
join-room { roomCode, username } Join a chat room
send-message { roomCode, content, username } Send a message
typing { roomCode, username, isTyping } Update typing status
disconnect - User leaves (automatic)

Server → Client

Event Payload Description
message { id, type, content, username, timestamp } New message received
user-joined { username, message } User joined notification
user-left { username, message } User left notification
online-users string[] Updated list of online users
user-typing { username, isTyping } Typing indicator update

🔧 Configuration

Environment Variables

# Server Configuration
PORT=3000                    # Server port (default: 3000)
NODE_ENV=production          # Environment mode

Customization

  • Room Code Length: Modify in app/page.tsx (line 13)
  • Socket.io Config: Adjust in server.js (lines 21-25)
  • Theme Colors: Update in tailwind.config.js
  • Typing Timeout: Change in app/chat/[roomCode]/page.tsx (line 168)

🤝 Contributing

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

  1. 🍴 Fork the repository
  2. 🔨 Create a feature branch (git checkout -b feature/AmazingFeature)
  3. 💾 Commit your changes (git commit -m 'Add some AmazingFeature')
  4. 📤 Push to the branch (git push origin feature/AmazingFeature)
  5. 🎉 Open a Pull Request

🐛 Known Issues & Limitations

  • No Persistence - Messages lost on server restart (by design)
  • No File Sharing - Text messages only
  • No Encryption - WebSocket traffic not end-to-end encrypted
  • Memory-Based - High user count may impact server memory

📜 License

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


👨‍💻 Author

Aditya Raj

⭐ Star this repository if you find it useful!

Made with 💙 by Aditya Raj

↑ Back to Top

About

Real-time anonymous chat application with zero data storage. Built with Next.js, TypeScript, Socket.io, and Tailwind CSS. Privacy-first ephemeral messaging platform.

Topics

Resources

License

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Contributors