COMPANY : CODTECH IT SOLUTIONS
NAME : ROHAN KUMAR GUPTA
INTERN ID : CT4MKNM
DOMAIN : BACKEND WEB DEVELOPMENT
DURATION : 4 WEEKS
MENTOR : NEELA SANTOSH
The Chat Application API is a backend service designed to provide real-time messaging capabilities for users. This system enables secure and efficient communication between users while ensuring data persistence using MongoDB. Additionally, the API includes an email verification system using Mailtrap, ensuring that users confirm their accounts before engaging in conversations.
The project is developed using Node.js and Express.js for backend development. It leverages MongoDB as the database to store user details, chat messages, and authentication tokens. The application also integrates Socket.IO for real-time messaging and Mailtrap for email verification.
- Node.js & Express.js: Backend framework for building API endpoints.
- MongoDB & Mongoose: NoSQL database for storing chat messages and user details.
- Socket.IO: Enables real-time communication between users.
- JWT (JSON Web Token): Used for secure authentication and user authorization.
- Mailtrap: A virtual email system used for user verification emails.
- Bcrypt: Library used for hashing passwords to enhance security.
- Nodemailer & Mailgen: Handles email sending and formatting.
-
User Authentication:
- Users can register and log in securely.
- Passwords are encrypted using Bcrypt.
- JWT tokens are used for authentication and authorization.
-
Email Verification:
- New users receive a verification email via Mailtrap.
- The system prevents unverified users from logging in.
-
Real-Time Messaging:
- Users can send and receive messages instantly using Socket.IO.
- Supports private one-on-one chats.
-
Message Storage:
- Messages are stored in MongoDB for historical reference.
- Users can retrieve past conversations.
-
API Integration:
- The API is designed to be integrated with any frontend application.
- Follows RESTful principles for easy scalability.
- A user registers by providing an email and password.
- A verification email is sent using Mailtrap.
- Upon verification, the user can log in and generate a JWT token.
- The user can start messaging other verified users in real time.
- Messages are sent via Socket.IO and stored in MongoDB for retrieval.
- Users can retrieve their chat history from the database.
-
Clone the repository and install dependencies:
npm install
-
Set up a
.envfile with MongoDB connection string and Mailtrap credentials. -
Start the API server:
npm run dev
-
Access the API documentation at
http://127.0.0.1:8080/docs. -
Example request to register a new user:
curl -X POST "http://127.0.0.1:8080/register" -H "Content-Type: application/json" -d '{"email":"user@example.com", "password":"securepassword"}'
{
"message": "Registration successful! Please check your email for verification.",
"success": true
}This Chat Application API is a scalable and secure system designed to facilitate real-time messaging between users. By integrating MongoDB for data storage and Mailtrap for email verification, the system ensures a smooth user experience. Future improvements could include group messaging, multimedia support, and AI-powered chatbots for enhanced user interaction.
Upon running the API and making a request, the system will:
- Register a user and send an email for verification.
- Authenticate users using JWT.
- Enable real-time chatting through Socket.IO.
- Store and retrieve chat messages from MongoDB.


