This is a chat application built using Node.js, Express.js, MongoDB, Socket.IO, and other technologies. It provides features like user authentication, real-time messaging, chat editing and deletion, profile picture upload, and more.
- User Authentication: Users can register and log in to access the chat application.
- User Authorization: Only authenticated users can access the dashboard, and non-authenticated users are redirected to the login/register page.
- Real-Time Messaging: Users can chat with each other in real-time.
- Message Editing and Deletion: Users can edit and delete their own messages.
- Profile Picture Upload: Users can upload a profile picture during registration.
- Backend: Node.js, Express.js, MongoDB, Mongoose
- Real-Time Communication: Socket.IO
- Authentication and Authorization: bcrypt, express-session, cookie-parser
- File Upload: Multer, Cloudinary
- Frontend Templating Engine: EJS
- Other Middleware: body-parser, cors
- Clone this repository to your local machine.
git clone <repository-url>
- Navigate to the project directory.
cd chat-application
- Install dependencies.
npm install
- Configure environment variables.
- Create a .env file in the root directory.
- Add the necessary environment variables ((e.g., MongoDB connection string, session secret, Cloudinary credentials).)
- Example :
- PORT = 8000 - MONGODB_URL = "mongodb+srv://<Your Name>:<Your Password>@chat-app.xzstind.mongodb.net/Chat-App?retryWrites=true&w=majority&appName=Chat-App" - SESSION_SECRET = "YourSessionSecret"
- Example :
- Create a helper folder under cloudinary.ejs file
- Example :
const cloudinary = require('cloudinary'); cloudinary.v2.config({ cloud_name: 'Your cloud name', api_key: 'Your api key', api_secret: 'Your api secret', secure: true, }); module.exports = cloudinary;
- Example :
- Start the server.
npm start
- Ensure that the backend server is running.
- Open a web browser and navigate to the URL where the backend server is hosted (e.g., http://localhost:8000).
- You should see the login/register page. Follow the instructions to register or log in.
- After logging in, you'll be redirected to the dashboard where you can start chatting with other users.