A modern, real-time chat application built with Node.js, Socket.io, and MongoDB. Connect with friends, create chat rooms, and enjoy seamless messaging with typing indicators and live updates.
- Secure Registration: Create accounts with encrypted passwords using bcrypt
- Username Validation: Real-time username availability checking with suggestions
- Session Management: Persistent login sessions with Passport.js
- User Profile Settings: Update name and username with validation
- Password Security: Strong password requirements and confirmation validation
- Instant Messaging: Real-time message delivery using Socket.io
- Message History: Persistent chat history stored in MongoDB (last 100 messages)
- Typing Indicators: See when others are typing in real-time
- Message Timestamps: All messages include time stamps for better context
- Auto-scroll: Automatic scrolling to latest messages
- Create Rooms: Start your own chat rooms with custom names
- Room Ownership: Room creators have administrative privileges
- Member Management: View all room members with role indicators
- Room Settings: Rename rooms and manage members (creators only)
- Member Removal: Kick members from rooms (creators only)
- Room Navigation: Easy switching between multiple rooms
- Send Invitations: Invite users to join your rooms by username
- Invitation Management: Accept or decline room invitations
- Smart Validation: Prevents duplicate invitations and validates user existence
- Notification System: Real-time feedback for invitation actions
- Mobile-First: Optimized for mobile devices and tablets
- Adaptive UI: Dynamic interface elements based on screen size
- Touch-Friendly: Large touch targets and intuitive navigation
- Sidebar Navigation: Collapsible sidebar for room and user management
- Modern Design: Clean, minimalist interface with Font Awesome icons
- Color-Coded Messages: Different styling for own vs. others' messages
- Visual Feedback: Success/error messages and loading states
- Accessibility: Keyboard navigation and screen reader friendly
- Node.js: JavaScript runtime environment
- Express.js: Web application framework
- Socket.io: Real-time bidirectional communication
- MongoDB: NoSQL database for data storage
- Mongoose: MongoDB object modeling
- Passport.js: Authentication middleware
- bcrypt: Password hashing library
- express-session: Session management
- connect-flash: Flash message middleware
- EJS: Embedded JavaScript templating
- CSS3: Modern styling with Flexbox/Grid
- JavaScript (ES6+): Client-side functionality
- Font Awesome: Icon library
- Socket.io Client: Real-time communication
- UUID: Unique identifier generation
- Moment.js: Date and time formatting
- Cookie Parser: Cookie handling middleware
- Autoprefixer: CSS vendor prefixing
- Node.js (v14 or higher)
- MongoDB (local installation or MongoDB Atlas)
- npm or yarn package manager
-
Clone the repository
git clone https://github.com/TH3-MA3STRO/chatapp.git cd chatapp -
Install dependencies
npm install
-
Environment Setup Create a
.envfile in the root directory:MONGO_URI=mongodb://localhost:27017/chatapp # OR for MongoDB Atlas: # MONGO_URI=mongodb+srv://username:password@cluster.mongodb.net/chatapp PORT=3000 SESSION_SECRET=your_session_secret_here
-
Start MongoDB
- Local MongoDB: Ensure MongoDB service is running
- MongoDB Atlas: Use connection string in MONGO_URI
-
Run the application
Development mode:
npm run production
Production mode:
npm start
-
Access the application Open your browser and navigate to
http://localhost:3000
chatapp/
├── 📂 config/
│ ├── authenticate.js # Authentication middleware
│ └── passport.js # Passport configuration
├── 📂 models/
│ ├── User.js # User schema
│ ├── Room.js # Chat room schema
│ ├── Chat.js # Message schema
│ └── Invite.js # Invitation schema
├── 📂 routes/
│ ├── auth.js # Authentication routes
│ └── service.js # Application routes
├── 📂 utils/
│ ├── messages.js # Message formatting utilities
│ └── users.js # User management utilities
├── 📂 views/
│ ├── 📂 partials/
│ │ ├── head.ejs # HTML head section
│ │ ├── nav.ejs # Navigation bar
│ │ └── bottomnav.ejs # Bottom navigation
│ ├── login.ejs # Login page
│ ├── register.ejs # Registration page
│ ├── home.ejs # Dashboard
│ ├── chat.ejs # Chat room interface
│ ├── create.ejs # Room creation
│ ├── invitation.ejs # Invitations page
│ ├── roomsettings.ejs # Room management
│ ├── usersettings.ejs # User profile settings
│ └── 404.ejs # Error page
├── 📂 public/
│ ├── 📂 css/ # Stylesheets
│ └── 📂 js/ # Client-side JavaScript
├── app.js # Main application file
└── package.json # Dependencies and scripts
{
id: String, // Unique user identifier
name: String, // Display name
username: String, // Unique username
password: String, // Hashed password
room: Array, // Array of joined room IDs
status: String // User status (optional)
}{
name: String, // Room name
id: String, // Unique room identifier
members: Array, // Array of member objects
creator: String, // Creator username
membersData: Object, // Detailed member information
time: String // Creation timestamp
}{
room: String, // Room ID
name: String, // Sender username
message: String, // Message content
time: String // Message timestamp
}{
toInvite: String, // Recipient username
senderName: String, // Sender display name
senderUsername: String, // Sender username
roomName: String, // Room name
roomID: String // Room identifier
}- Register: Create a new account with a unique username
- Login: Access your dashboard with your credentials
- Create Room: Start a new chat room or join existing ones
- Invite Friends: Send invitations to other users
- Start Chatting: Enjoy real-time conversations!
- Creating Rooms: Click "Create Room" and enter a room name
- Joining Rooms: Accept invitations from other users
- Managing Members: Room creators can rename rooms and remove members
- Room Settings: Access via the settings icon in the room
- Send Messages: Type in the message box and press Enter or click send
- View History: Previous messages load automatically when joining
- Typing Indicators: See real-time typing notifications
- Message Status: Visual confirmation of sent messages
- Profile Settings: Update your name and username
- Account Security: Usernames must be unique across the platform
- Session Management: Stay logged in across browser sessions
GET /register- Registration pagePOST /register- Create new userGET /login- Login pagePOST /login- Authenticate userGET /logout- Logout user
GET /home- User dashboardGET /create- Room creation pagePOST /create- Create new roomGET /room/:id- Join chat roomGET /invitations- View invitationsPOST /invite- Send invitationGET /invitation/:id/:action- Handle invitation responseGET /:id/rsettings- Room settingsGET /:user/usettings- User settings
joinRoom- Join a chat roomchatMsg- Send messagetyping- Typing indicatortyping_remove- Stop typing indicatordisconnect- User disconnection
We welcome contributions! Please follow these steps:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit changes:
git commit -m 'Add amazing feature' - Push to branch:
git push origin feature/amazing-feature - Open a Pull Request
- Follow existing code style and conventions
- Add comments for complex functionality
- Test your changes thoroughly
- Update documentation as needed
This project is licensed under the ISC License. See the LICENSE file for details.
- Socket.io for real-time communication capabilities
- MongoDB for reliable data storage
- Express.js for robust web framework
- Font Awesome for beautiful icons
- bcrypt for secure password hashing
- Message history limited to last 100 messages per room
- No file sharing capabilities
- Basic user status system
- 📎 File and image sharing
- 🌙 Dark/Light theme toggle
- 🔔 Push notifications
- 👥 User online status
- 📞 Voice/Video calling
- 🎭 Custom emoji reactions
- 🔍 Message search functionality
For support, please open an issue on GitHub or contact the development team.
Made with ❤️ by TH3-MA3STRO
⭐ Star this repository if you found it helpful!