We are building a chat application that will be a mix of popular chat applications Slack and WhatsApp.
The features we are planning to clone are :
- Direct Chats
- Group Chats (Channels)
- Pin Chats
- Online / Offline Status
- Read Receipts
The tech stack we'll be using is :
- Frontend - React.JS
- Backend - NodeJS, ExpressJS
- Database - MongoDB
- Storage - Firebase
The authentication related endpoints such as user registration, login.
This end point will be used to create a new account
POST /api/auth/register
{
data: {
name: String,
phoneNumber: String,
image: File,
email: String,
password: String,
confirmPassword: String
},
};{
status: 201,
data: {
message: String,
token: String
}
}{
status: 400 || 500,
data: {
message: String,
}
}| Status Code | Message |
|---|---|
| 201 | Account Created Successfully |
| 400 | Invalid Input |
| 500 | Something went wrong, please try again later |
This end point will be used to sign in to an existing account
POST /api/auth/login
{
data: {
email: String,
password: String,
},
};{
status: 200,
data: {
message: String,
token: String
}
}{
status: 400 || 500,
data: {
message: String,
}
}| Status Code | Message |
|---|---|
| 200 | Signed In Successfully |
| 400 | Invalid Input |
| 500 | Something went wrong, please try again later |
The user related endpoints such as fetching user profile, verifying login, updating profile details or password
This end point will be used to verify the login by verifying the JWT token and if all's well, fetch the profile of the user
GET / api / user;
{
headers: {
Authorization: `Bearer ${token}`;
}
}{
status: 200,
data: {
message: String,
userData: Object
}
}{
status: 402 || 404 || 500,
data: {
message: String,
}
}| Status Code | Message |
|---|---|
| 200 | User profile fetched successfully |
| 402 | Unauthorized |
| 404 | No token found OR no user found |
| 500 | Something went wrong, please try again later |
This endpoint will be used to get all the users except the current logged in user
GET / api / user / all;
{
headers: {
Authorization: `Bearer ${token}`;
}
}{
status: 200,
data: {
message: String,
users: Object[]
}
}{
status: 402 || 404 || 500,
data: {
message: String,
}
}| Status Code | Message |
|---|---|
| 200 | Users fetched successfully |
| 402 | Unauthorized |
| 404 | No token found |
| 500 | Something went wrong, please try again later |
This endpoint will be used to update the profile details of the currently logged in user
PATCH /api/user
{
headers: {
Authorization: `Bearer ${token}`;
},
body: {
name: String,
phoneNumber: String,
image: File,
}
}{
status: 200,
data: {
message: String
}
}{
status: 400 || 402 || 404 || 500,
data: {
message: String,
}
}| Status Code | Message |
|---|---|
| 200 | Profile updated successfully |
| 400 | Invalid inputs |
| 402 | Unauthorized |
| 404 | No token or user found |
| 500 | Something went wrong, please try again later |
This endpoint will be used to update the password of the currently logged in user
PATCH /api/user/password
{
headers: {
Authorization: `Bearer ${token}`;
},
body: {
oldPassword: String,
newPassword: String,
confirmNewPassword: String
}
}{
status: 200,
data: {
message: String
}
}{
status: 400 || 402 || 404 || 500,
data: {
message: String,
}
}| Status Code | Message |
|---|---|
| 200 | Password changed successfully |
| 400 | Invalid inputs |
| 402 | Unauthorized |
| 404 | No token or user found |
| 500 | Something went wrong, please try again later |
This endpoint will be used to fetch the profile of user by using his ID
GET /api/user/:userId
{
headers: {
Authorization: `Bearer ${token}`;
}
}{
status: 200,
data: {
message: String,
user: Object
}
}{
status: 404 || 500,
data: {
message: String,
}
}| Status Code | Message |
|---|---|
| 200 | Profile fetched successfully |
| 404 | No token or user found |
| 500 | Something went wrong, please try again later |
The chat related endpoints such as creating or removing a chat, renaming group chats or adding new members. Pinning chats or unpinning them, etc.
This end point will be used to create a new chat
POST /api/chat/
{
headers: {
Authorization: `Bearer ${token}`;
},
data: {
users: String[],
isGroupChat: Boolean,
groupChatName: String,
}
}{
status: 201,
data: {
message: String,
chat: Object
}
}{
status: 400 || 402 || 404 || 500,
data: {
message: String,
}
}| Status Code | Message |
|---|---|
| 201 | Chat created successfully |
| 400 | Invalid Chat Name |
| 402 | Unauthorized |
| 404 | No token found OR no user found |
| 500 | Something went wrong, please try again later |
This end point will be used to rename a group chat
PATCH /api/chat/rename/:chatId
{
headers: {
Authorization: `Bearer ${token}`;
},
data: {
groupChatName: String,
}
}{
status: 200,
data: {
message: String,
chat: Object
}
}{
status: 400 || 402 || 404 || 500,
data: {
message: String,
}
}| Status Code | Message |
|---|---|
| 200 | Chat renamed successfully |
| 400 | Invalid Chat Name |
| 402 | Unauthorized |
| 404 | No token found OR no chat found |
| 500 | Something went wrong, please try again later |
This end point will be used to add user to a group chat
PATCH /api/chat/add/:chatId
{
headers: {
Authorization: `Bearer ${token}`;
},
data: {
user: String
}
}{
status: 200,
data: {
message: String,
chat: Object
}
}{
status: 402 || 404 || 500,
data: {
message: String,
}
}| Status Code | Message |
|---|---|
| 200 | User added successfully |
| 402 | Unauthorized |
| 404 | No token found OR no chat found |
| 500 | Something went wrong, please try again later |
This end point will be used to remove user from a group chat
PATCH /api/chat/remove/:chatId
{
headers: {
Authorization: `Bearer ${token}`;
},
data: {
user: String
}
}{
status: 200,
data: {
message: String,
chat: Object
}
}{
status: 402 || 404 || 500,
data: {
message: String,
}
}| Status Code | Message |
|---|---|
| 200 | User removed successfully |
| 402 | Unauthorized |
| 404 | No token found OR no chat found |
| 500 | Something went wrong, please try again later |
This end point will be used to remove a chat
DELETE /api/chat/:chatId
{
headers: {
Authorization: `Bearer ${token}`;
},
}{
status: 200,
data: {
message: String,
}
}{
status: 402 || 404 || 500,
data: {
message: String,
}
}| Status Code | Message |
|---|---|
| 200 | Chat deleted successfully |
| 402 | Unauthorized |
| 404 | No token found OR no chat found |
| 500 | Something went wrong, please try again later |
This end point will be used to fetch all the chats of the currently logged in user
GET /api/chat/
{
headers: {
Authorization: `Bearer ${token}`;
},
}{
status: 200,
data: {
message: String,
chats: Object[]
}
}{
status: 402 || 404 || 500,
data: {
message: String,
}
}| Status Code | Message |
|---|---|
| 200 | Chats fetched successfully |
| 402 | Unauthorized |
| 404 | No token found |
| 500 | Something went wrong, please try again later |
This end point will be used to fetch a specific chat
GET /api/chat/:chatId
{
headers: {
Authorization: `Bearer ${token}`;
},
}{
status: 200,
data: {
message: String,
chat: Object
}
}{
status: 402 || 404 || 500,
data: {
message: String,
}
}| Status Code | Message |
|---|---|
| 200 | Chats fetched successfully |
| 402 | Unauthorized |
| 404 | No token found |
| 500 | Something went wrong, please try again later |
This end point will be used to pin a chat
POST /api/chat/pin/:chatId
{
headers: {
Authorization: `Bearer ${token}`;
},
}{
status: 200,
data: {
message: String
}
}{
status: 402 || 404 || 500,
data: {
message: String,
}
}| Status Code | Message |
|---|---|
| 200 | Chat pinned successfully |
| 402 | Unauthorized |
| 404 | No token found OR no chat found |
| 500 | Something went wrong, please try again later |
This end point will be used to unpin a chat
DELETE /api/chat/pin/:chatId
{
headers: {
Authorization: `Bearer ${token}`;
},
}{
status: 200,
data: {
message: String
}
}{
status: 402 || 404 || 500,
data: {
message: String,
}
}| Status Code | Message |
|---|---|
| 200 | Chat unpinned successfully |
| 402 | Unauthorized |
| 404 | No token found OR no chat found |
| 500 | Something went wrong, please try again later |
The endpoints to create edit or remove messages from a chat
This end point will be used to create a new message transaction for a chat
POST /api/message/
{
headers: {
Authorization: `Bearer ${token}`;
},
data: {
message: String,
chatId: String,
transactionType: String,
messageId: String (OPTIONAL)
}
}{
status: 201,
data: {
message: String
}
}{
status: 400 || 402 || 404 || 500,
data: {
message: String,
}
}| Status Code | Message |
|---|---|
| 201 | Transaction created successfully |
| 400 | Invalid message OR chat ID or transaction type |
| 402 | Unauthorized |
| 404 | No token found OR no chat found |
| 500 | Something went wrong, please try again later |
This end point will be used to check if newer transactions have been made for a chat after a given transaction
GET /api/message/transaction/:chatId/:transactionId
{
headers: {
Authorization: `Bearer ${token}`;
},
}{
status: 200,
data: {
message: String,
unfetchedTransactions: Boolean
}
}{
status: 402 || 404 || 500,
data: {
message: String,
}
}| Status Code | Message |
|---|---|
| 200 | Transaction status fetched successfully |
| 402 | Unauthorized |
| 404 | No token found OR no chat found OR No transaction found |
| 500 | Something went wrong, please try again later |
This end point will be used to fetch all messages for a chat
GET /api/message/:chatId
{
headers: {
Authorization: `Bearer ${token}`;
},
}{
status: 200,
data: {
message: String,
messages: Object[]
}
}{
status: 402 || 404 || 500,
data: {
message: String,
}
}| Status Code | Message |
|---|---|
| 200 | Messaged fetched successfully |
| 402 | Unauthorized |
| 404 | No token found OR no chat found |
| 500 | Something went wrong, please try again later |
This end point will be used to fetch all transactions for a chat after a certain transaction
GET /api/message/:chatId/:transactionId
{
headers: {
Authorization: `Bearer ${token}`;
},
}{
status: 200,
data: {
message: String,
transactions: Object[]
}
}{
status: 402 || 404 || 500,
data: {
message: String,
}
}| Status Code | Message |
|---|---|
| 200 | Transactions fetched successfully |
| 402 | Unauthorized |
| 404 | No token found OR no chat found |
| 500 | Something went wrong, please try again later |