A modern, real-time chat application built with React and Node.js
Features β’ Demo β’ Installation β’ API Documentation β’ Deployment
- About
- Features
- Tech Stack
- Demo & Screenshots
- Installation
- Environment Variables
- API Documentation
- Project Structure
- Challenges & Solutions
- AI Tools Used
- Deployment
- Contributing
- License
Emitly is a full-stack real-time chat application that enables users to communicate instantly with one-on-one messaging and group chats. Built with modern web technologies, it provides a seamless chatting experience similar to WhatsApp and other popular messaging platforms.
- β Real-time messaging with Socket.IO
- β One-on-one and group chats
- β Read receipts (sent, delivered, read status)
- β User presence (online/offline indicators) β Not yet implemented
- β Emoji support with emoji picker
- β Message deletion (soft delete)
- β Typing indicators
- β Notifications for new messages
- β Responsive design with Tailwind CSS
- β JWT-based authentication
Note: Delete chat and user online status are not yet implemented.
- User registration and login
- Secure JWT token-based authentication
- Protected routes and API endpoints
- Guest user support
- One-on-One Chats: Private conversations between two users
- Group Chats: Create and manage group conversations
- Real-time Messaging: Instant message delivery using Socket.IO
- Message Status: View sent, delivered, and read receipts
- Typing Indicators: See when someone is typing
- Emoji Support: Rich emoji picker for expressive messages
- Message Deletion: Delete your own messages (soft delete)
- Message Timestamps: View when messages were sent
- User Search: Find and connect with other users
- User Profiles: View and update user profiles
- Online Status: See who's online in real-time β Coming soon
- Avatar Support: Custom profile pictures
- Real-time notifications for new messages
- Unread message counts
- Notification badges
- Modern, clean interface
- Responsive design (mobile-friendly)
- Smooth animations and transitions
- Loading states and error handling
- React 18.2.0 - UI library
- React Router DOM 7.6.1 - Routing
- Tailwind CSS 3.3.3 - Styling
- Socket.io Client 4.8.1 - Real-time communication
- Axios 1.9.0 - HTTP client
- Emoji Picker React 4.15.0 - Emoji picker component
- React Hot Toast 2.5.2 - Toast notifications
- React Scrollable Feed 2.0.3 - Scrollable chat feed
- Lucide React 0.544.0 - Icons
- Node.js 18+ - Runtime environment
- Express.js 4.18.2 - Web framework
- Socket.io 4.8.1 - WebSocket server
- MongoDB 8.15.0 - Database (via Mongoose)
- JWT (jsonwebtoken 9.0.2) - Authentication
- Bcryptjs 3.0.2 - Password hashing
- Dotenv 16.5.0 - Environment variables
- CORS 2.8.5 - Cross-origin resource sharing
- Nodemon 3.1.10 - Development server auto-reload
- Concurrently 8.2.2 - Run multiple scripts simultaneously
- Proxy Configuration: Frontend uses a proxy (
"proxy": "http://127.0.0.1:5000"infrontend/package.json) to forward API requests to the backend during development - Single Command: Use
npm run devto run both frontend and backend together - Production: Backend serves static frontend files directly (no proxy needed)
Try Emitly now: https://emitly.onrender.com/
Clean and modern login/signup interface
Real-time messaging with emoji support
Create and manage group conversations
- Node.js (v18.0.0 or higher)
- npm (v8.0.0 or higher)
- MongoDB Atlas account (or local MongoDB instance)
git clone https://github.com/Piyush-t24/Emitly.git
cd EmitlyInstall backend and frontend dependencies:
# Install root dependencies (includes backend)
npm install --legacy-peer-deps
# Install frontend dependencies
npm install --legacy-peer-deps --prefix frontendCreate a .env file in the root directory:
cp .env.example .envEdit .env and add your configuration:
MONGO_URI=mongodb+srv://username:[email protected]/emitly?retryWrites=true&w=majority
JWT_SECRET=your_super_secret_jwt_key_here
PORT=5000
NODE_ENV=productionImportant:
- Get your MongoDB connection string from MongoDB Atlas
- Generate a strong JWT secret (you can use:
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))")
npm run devThis will start both backend and frontend simultaneously:
- Backend server on
http://localhost:5000 - Frontend development server on
http://localhost:3000
How it works:
- The frontend has a proxy configured (
"proxy": "http://127.0.0.1:5000"infrontend/package.json) - All API requests from frontend (e.g.,
/api/user,/api/chat) are automatically proxied to the backend - This means you don't need to specify full backend URLs in your frontend code
- The frontend runs on port 3000, backend on port 5000, but API calls work seamlessly
Backend only (at root):
npm startor for development with auto-reload:
npm run serverFrontend only:
npm start --prefix frontendNote: When running separately, make sure the backend is running first, as the frontend proxy depends on it.
npm run buildThis builds the React frontend and prepares it for deployment.
| Variable | Description | Example |
|---|---|---|
MONGO_URI |
MongoDB connection string | mongodb+srv://user:[email protected]/emitly |
JWT_SECRET |
Secret key for JWT tokens | your_super_secret_key_here |
PORT |
Backend server port | 5000 |
NODE_ENV |
Environment mode | development or production |
See .env.example for the template.
For complete API documentation including all endpoints, request/response formats, Socket.IO events, and authentication details, please refer to:
π API_DOCUMENTATION.md
The API documentation includes:
- Base URLs for development and production
- Authentication guide
- All REST API endpoints (User, Chat, Message, Notification, Health Check)
- Socket.IO events (client β server and server β client)
- Request/response examples
- Error handling
Emitly/
βββ backend/
β βββ config/
β β βββ db.js # MongoDB connection
β β βββ generateToken.js # JWT token generation
β βββ controllers/
β β βββ chatControllers.js
β β βββ messageControllers.js
β β βββ notificationControllers.js
β β βββ userControllers.js
β βββ middleware/
β β βββ authMiddleware.js # JWT authentication
β β βββ errorMiddleware.js # Error handling
β βββ Models/
β β βββ chatModel.js
β β βββ messageModel.js
β β βββ notificationModel.js
β β βββ userModel.js
β βββ routes/
β β βββ chatRoutes.js
β β βββ messageRoutes.js
β β βββ notificationRoutes.js
β β βββ userRoutes.js
β βββ server.js # Express server & Socket.IO
β
βββ frontend/
β βββ public/
β β βββ assets/
β β β βββ EmitlyLogo/
β β β βββ screenshots/
β β βββ index.html
β βββ src/
β β βββ components/
β β β βββ Authentication/
β β β β βββ Login.js
β β β β βββ Signup.js
β β β βββ miscellaneous/
β β β β βββ GroupChatModal.js
β β β β βββ ProfileModal.js
β β β β βββ SideDrawer.js
β β β β βββ UpdateGroupChatModal.js
β β β βββ ScrollableChat.js
β β β βββ SingleChat.js
β β β βββ MyChats.js
β β β βββ userAvatar/
β β βββ Context/
β β β βββ ChatProvider.js # Global state management
β β βββ Pages/
β β β βββ Homepage.js
β β β βββ ChatPage.js
β β βββ services/
β β β βββ keepAliveService.js # Render.com keep-alive
β β βββ config/
β β β βββ ChatLogics.js
β β βββ App.js
β β βββ index.js
β βββ package.json
β
βββ .env.example # Environment variables template
βββ .gitignore
βββ package.json # Root package.json
βββ RENDER_DEPLOYMENT.md # Deployment guide
βββ README.md # This file
Challenge: Ensuring messages are delivered instantly across all connected clients without polling.
Solution:
- Implemented Socket.IO for bidirectional real-time communication
- Created event handlers for
new message,message received, andtypingevents - Used React Context API to manage socket connections globally
Challenge: Tracking which users have read messages in group chats and one-on-one conversations.
Solution:
- Added
readByarray field to message schema - Implemented
markMessagesAsReadAPI endpoint - Created Socket.IO event
messages readto broadcast read status in real-time - Display read receipts with blue double ticks (similar to WhatsApp)
Challenge: Handling API requests between frontend and backend in development and production.
Solution:
- Development: Configured proxy in
frontend/package.json("proxy": "http://127.0.0.1:5000") to automatically forward API requests from frontend (port 3000) to backend (port 5000) - Production: Configured Express CORS middleware with function-based origin checking for separate deployments
- Enabled credentials for authenticated requests
- Configured Socket.IO CORS to match Express settings
- In production single deployment, backend serves static files directly (no CORS needed)
Challenge: Free tier services on Render spin down after 15 minutes of inactivity, causing slow first requests.
Solution:
- Created
/healthendpoint for keep-alive pings - Implemented frontend keep-alive service that pings server every 5 minutes
- Documented external ping services (UptimeRobot) for 24/7 uptime
Challenge: Implementing message deletion that works across all clients in real-time.
Solution:
- Added
deletedboolean field to message schema - Created
deleteMessageAPI endpoint with authorization checks - Implemented Socket.IO
message deletedevent for real-time updates - Updated UI to show "This message was deleted" for deleted messages
Challenge: Managing complex state across multiple components (chats, messages, notifications, online users).
Solution:
- Created
ChatProvidercontext for global state management - Used
useCallbackanduseMemoto optimize re-renders - Separated concerns with dedicated state hooks
Challenge: Messages displaying incorrectly with line breaks and spacing issues.
Solution:
- Normalized message content by replacing newlines with spaces
- Collapsed multiple spaces into single spaces
- Set proper CSS
white-spaceproperties for natural text wrapping
This project was developed with assistance from AI tools to accelerate development and solve complex problems:
- Code Generation: Generated boilerplate code for components, routes, and controllers
- Debugging: Helped identify and fix bugs in Socket.IO connections and state management
- Refactoring: Suggested improvements for code structure and performance optimization
- Documentation: Assisted in writing clear code comments and documentation
- Initial Setup: Generated project structure and configuration files
- Feature Implementation: Created Socket.IO event handlers and real-time features
- Bug Fixes: Identified issues with CORS, authentication, and state management
- Code Optimization: Suggested React hooks optimization and performance improvements
- Documentation: Helped write API documentation and deployment guides
- β‘ Faster development cycle
- π Reduced debugging time
- π Better code quality and best practices
- π― Focus on problem-solving rather than boilerplate
Live Demo: https://emitly.onrender.com/
- Render.com account
- MongoDB Atlas account
- GitHub repository
-
Create a New Web Service on Render
- Connect your GitHub repository
- Select the repository and branch
-
Configure Build Settings
- Build Command:
npm run build - Start Command:
npm start - Environment:
Node
- Build Command:
-
Set Environment Variables
NODE_ENV=production MONGO_URI=your_mongodb_connection_string JWT_SECRET=your_jwt_secret PORT=5000 -
Deploy
- Click "Create Web Service"
- Wait for deployment to complete
-
Prevent Cold Starts (Optional)
- Use UptimeRobot or similar service to ping
/healthevery 5 minutes - Or the built-in keep-alive service will work when users are active
- Use UptimeRobot or similar service to ping
- Vercel: For frontend (requires separate backend deployment)
- Railway: Similar to Render, supports full-stack
- Netlify: For frontend, with serverless functions
- Heroku: Classic PaaS option
See RENDER_DEPLOYMENT.md for detailed deployment instructions.
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Follow existing code style
- Write meaningful commit messages
- Test your changes thoroughly
- Update documentation if needed
This project is licensed under the ISC License.
Piyush Gupta
- GitHub: @Piyush-t24
- Email: [[email protected]]
- Socket.IO for real-time communication
- React for the amazing UI library
- Tailwind CSS for beautiful styling
- MongoDB Atlas for database hosting
- Render for hosting platform
Watch the video walkthrough to see Emitly in action:
Note: Video link will be added soon. Check back later for a detailed walkthrough of the application features and functionality.
Made with β€οΈ using React, Node.js, and Socket.IO
β Star this repo if you found it helpful!



