https://chattr-x.onrender.com/

A modern, real-time chat application with a sleek UI/UX, featuring a distinctive C-shaped Pac-Man logo. Built with React, Node.js, Socket.io, and MongoDB.
- OpenRouter Integration: Powered primarily by Gemini 2.0 Flash for maximum speed and reliability.
- Fail-safe Logic: Automatic fallback to direct Google Gemini SDK if primary provider fails.
- Two-Mode Personality: Switch between Casual (vibe-check) and Tech (expert) modes.
- Interactive Commands:
/kira status,/kira roast,/kira recap, and more. - Random Join-in: Kira intelligently jumps into tech discussions.
- Anonymous Public Chat: No signup required, just pick a username and start chatting
- Real-time Messaging: Instant message delivery with Socket.io
- Ephemeral Messages: Messages auto-delete after 24 hours
- Multiple Message Types: Text, images, voice messages, and stickers etc
- Emoji Reactions: React to messages with emojis
- @@Message Pinning**: Pin important messages for everyone to see
- Online Users: See who's currently active in the chat
- @@Typing Indicators**: Know when someone is typing
- Easter Eggs: Global animations triggered by secret phrases (
let it snow,glitch, etc.). - Dark/Light Mode: Toggle between themes.
- Responsive Design: Works perfectly on mobile, tablet, and desktop (optimized with
h-dvh). - Smooth Animations: Framer Motion powered animations
- Modern Design: Clean, vibrant interface with Tailwind CSS
- Voice Waveforms: Visual waveform display for voice messages
- Interactive Elements: Hover effects, transitions, and micro-interactions
- Secure Login: JWT-based authentication
- User Management: View, kick, and ban users
- Message Moderation: Delete messages and manage pins
- Real-time Statistics: Active users, message counts, and more
- Broadcast Announcements: Send messages to all users
- Settings Control: Configure chat features and limits
- Node.js 18+ with Express.js
- Socket.io for real-time communication
- MongoDB Atlas for database
- OpenRouter API (Primary AI - Gemini 2.0 Flash)
- Google Gemini SDK (Fallback AI)
- Cloudinary for persistent media & file storage
- JWT for admin authentication
- Bcryptjs for password security
- React 18 with Vite
- Tailwind CSS for styling
- Framer Motion for animations
- Socket.io Client
- Lucide React for icons
- Canvas API for global animations (snow, etc.)
Make sure you have installed:
- Clone the repository
git clone https://github.com/Priyanshu-x/Chattr.git
cd Chattr- Set up the Backend
# Navigate to backend directory
cd backend
# Install dependencies
npm install
# Create uploads directories
mkdir -p uploads/images uploads/voice
# Create .env file
cp .env.example .env
# Edit .env file with your configurations- Set up the Frontend
# Navigate to frontend directory (from project root)
cd frontend
# Install dependencies
npm install- Start MongoDB
# On macOS with Homebrew
brew services start mongodb/brew/mongodb-community
# On Windows/Linux
mongod- Start the Application
Terminal 1 (Backend):
cd backend
npm run devTerminal 2 (Frontend):
cd frontend
npm run dev- Access the Application
- Main Chat: http://localhost:5173
- Admin Panel: http://localhost:5173/admin
- Admin Credentials: username:
admin, password:admin123
anonymous-chat-app/
├── backend/
│ ├── config/
│ ├── controllers/
│ ├── middleware/
│ ├── models/
│ ├── routes/
│ ├── uploads/
│ ├── server.js
│ └── package.json
├── frontend/
│ ├── src/
│ │ ├── components/
│ │ │ ├── admin/
│ │ │ ├── chat/
│ │ │ ├── layout/
│ │ │ └── ui/
│ │ ├── context/
│ │ ├── hooks/
│ │ ├── utils/
│ │ └── App.jsx
│ ├── public/
│ └── package.json
└── README.md
# Server Configuration
PORT=5000
NODE_ENV=development
CLIENT_URL=http://localhost:5173
# Database
MONGODB_URI=mongodb+srv://...
# Kira AI Configuration
KIRA_ENABLED=true
OPENROUTER_API_KEY=sk-or-v1-...
GEMINI_API_KEY=AIzaSyA...
# Cloudinary Configuration
CLOUDINARY_CLOUD_NAME=...
CLOUDINARY_API_KEY=...
CLOUDINARY_API_SECRET=...
# JWT Secret (Change in production!)
JWT_SECRET=your-super-secret-key
# Default Admin Credentials
ADMIN_USERNAME=admin
ADMIN_PASSWORD=admin123The frontend is configured to connect to the backend at http://localhost:5000. If you change the backend port, update the Socket.io and Axios configurations in:
src/context/SocketContext.jssrc/utils/api.js(if created)
- Join the Chat: Visit the main page and choose a username
- Send Messages: Type and send text messages
- Upload Images: Click the image icon to share photos
- Record Voice: Hold the mic button to record voice messages
- Use Stickers: Click the smile icon to access stickers
- React to Messages: Double-click a message or use the reaction button
- View Online Users: Check the sidebar to see who's online
- Access Admin Panel: Go to
/adminand login - View Statistics: Monitor real-time chat statistics
- Manage Users: View, kick, or ban problematic users
- Moderate Messages: Delete inappropriate messages or pin important ones
- Send Announcements: Broadcast messages to all users
- Configure Settings: Adjust chat features and limits
GET /api/user/username- Generate random usernameGET /api/user/avatar- Generate random avatar
GET /api/chat/messages- Get recent messages (with pagination)GET /api/chat/pinned- Get pinned messagesPOST /api/chat/upload/image- Upload image filePOST /api/chat/upload/voice- Upload voice file
POST /api/admin/login- Admin login
GET /api/admin/stats- Get chat statistics
GET /api/admin/users- Get all active usersPOST /api/admin/users/:id/kick- Kick a userPOST /api/admin/users/:id/ban- Ban a user
DELETE /api/admin/messages/:id- Delete a messagePATCH /api/admin/messages/:id/pin- Toggle message pinPOST /api/admin/announcement- Send announcement
join-chat- User joins the chatnew-message- Send a new messagetoggle-reaction- Add/remove reaction to messagetyping-start- User starts typingtyping-stop- User stops typing
message-received- New message broadcastrecent-messages- Initial message historyuser-joined- User joined notificationuser-left- User left notificationonline-users- Updated online users listuser-typing- Typing indicatorreaction-updated- Message reaction updatedmessage-deleted- Message deleted by adminmessage-pin-updated- Message pin status changedadmin-announcement- Admin broadcast messageuser-banned- User banned notificationuser-kicked- User kicked notification
- JWT-based admin authentication
- Secure password hashing with bcryptjs
- Protected admin routes
- Message sending limits
- File upload restrictions
- API endpoint protection
- XSS prevention
- File type validation
- Content sanitization
- Maximum file size limits
NODE_ENV=production
PORT=5000
MONGODB_URI=mongodb://your-mongo-connection-string
JWT_SECRET=your-very-secure-jwt-secret-key
ADMIN_USERNAME=your-admin-username
ADMIN_PASSWORD=your-secure-admin-password- Install Heroku CLI
- Create Heroku App
heroku create your-app-name- Set Environment Variables
heroku config:set NODE_ENV=production
heroku config:set MONGODB_URI=your-mongo-uri
heroku config:set JWT_SECRET=your-jwt-secret
heroku config:set ADMIN_USERNAME=admin
heroku config:set ADMIN_PASSWORD=secure-password- Deploy
git push heroku main- Build the frontend
cd frontend
npm run build-
Update API URLs in your frontend code to point to your deployed backend
-
Deploy the
distfolder to your hosting service
- Create a MongoDB Atlas account
- Create a new cluster
- Get your connection string
- Update
MONGODB_URIin your environment variables
- Backend: Update the Message model and add handling in socket events
- Frontend: Create new message bubble component and update MessageInput
- Add sticker images to
frontend/public/stickers/ - Update
StickerPicker.jsxwith new sticker data - Consider using a sticker API for dynamic content
- Add new color schemes to
tailwind.config.js - Update
ThemeContext.jsto support multiple themes - Add theme selection UI in settings
For production, consider using cloud storage:
- AWS S3: For scalable file storage
- Cloudinary: For image optimization and management
- Firebase Storage: For easy integration
- MongoDB indexing for faster queries
- Connection pooling
- Message pagination
- File compression
- CDN for static assets
- Component lazy loading
- Virtual scrolling for large message lists
- Image lazy loading
- Bundle splitting
- Service workers for offline support
MongoDB Connection Error
# Check if MongoDB is running
mongosh
# If not installed, install MongoDB Community EditionPort Already in Use
# Kill process using port 5000
lsof -ti:5000 | xargs kill -9
# Or change PORT in .env fileSocket.io Connection Issues
- Check if backend server is running
- Verify CORS configuration
- Check browser console for errors
File Upload Fails
- Check uploads directory exists and has write permissions
- Verify file size limits
- Check supported file types
- Fork the repository
- Create a feature branch
git checkout -b feature/amazing-feature- Commit your changes
git commit -m 'Add some amazing feature'- Push to the branch
git push origin feature/amazing-feature- Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Socket.io for real-time communication
- Tailwind CSS for the amazing utility-first CSS framework
- Lucide React for beautiful icons
- Framer Motion for smooth animations
- MongoDB for the flexible database
- React for the powerful frontend framework
If you have any questions or need help:
- Create an issue on GitHub
- Check the troubleshooting section
- Review the API documentation
Happy Chatting! 💬✨