Real-TimeChatApp
Multi-room real-time chat application with live messaging, user authentication, and persistent chat history.
Tech Stack
- Server: Node.js, Express
- Real-Time Communication: Socket.IO, WebSockets
- Database: MongoDB, Mongoose
- Authentication: JSON Web Tokens (JWT), bcrypt
- Views and Templates: Pug (Jade), CSS3, Vanilla JavaScript
Getting Started
Prerequisites
- Node.js 16 or higher
- MongoDB instance (local or remote)
Installation and Execution
-
Navigate to the application directory:
cd myapp -
Install dependencies:
npm install
-
Configure environment variables in
config/db.jsandconfig/jwt.js. -
Start the application:
npm start
Open
http://localhost:3000in your web browser.
Architecture
The application adopts the Model-View-Controller pattern built on Node.js and Express. WebSocket connections are managed by a Socket.IO server mounted on top of the native Node HTTP server, routing chat events and broadcast messages across specific rooms. User authentication is verified via JWT tokens in custom middleware, while Mongoose models define message schemas and user credentials in MongoDB.