This is the backend server for the Real-Time Chat Application, built using Spring Boot with GraphQL to handle messaging and status updates.
- GraphQL API for efficient data fetching
- Subscriptions for real-time message updates
- Spring Boot for scalable backend services
- MongoDB for data storage
- WebSockets for real-time communication
- Secure & Lightweight architecture
- Framework: Spring Boot
- GraphQL Library: GraphQL Java & Spring Boot GraphQL
- Database: MongoDB
- Messaging: WebSockets, GraphQL Subscriptions
- Build Tool: Maven
- Security: JWT Authentication (optional)
- JDK 17+
- Maven
- MongoDB (running locally or via Docker)
-
Clone the repository:
git clone https://github.com/anubhav-auth/messagingPrac.git cd messagingPrac
-
Configure the application properties (
src/main/resources/application.properties
):spring.data.mongodb.uri=mongodb://localhost:27017/chat_db
-
Build and run the server:
mvn clean install mvn spring-boot:run
enum MessageStatus {
UNSENT
SENT
DELIVERED
READ
}
type Message {
id: String!
topic: String!
content: String!
sender: String!
receiver: String!
status: MessageStatus!
sentAt: String!
deliveredAt: String!
readAt: String!
}
type MessageStatusUpdates {
id: String!
receiver: String!
status: MessageStatus!
deliveredAt: String!
readAt: String!
}
type Query {
syncMessages(topic: String): [Message!]!
}
type Mutation {
sendMessage(id: String!, topic: String!, content: String!, sender: String!, sentAt: String!): Message!
statusUpdate(messageId: String!, topic: String!, status: MessageStatus!, deliveredAt: String!, readAt: String!): MessageStatusUpdates!
}
type Subscription {
messageAdded(topic: String!): Message!
messageUpdates(topic: String!): MessageStatusUpdates!
}
query GetMessages($topic: String!) {
syncMessages(topic: $topic) {
id
content
sender
receiver
status
sentAt
deliveredAt
readAt
}
}
-
Build the Docker image:
docker build -t chat-backend .
-
Run the container:
docker run -p 8080:8080 --name chat-backend chat-backend
- Fork the repository.
- Create a new branch (
feature/new-feature
orbugfix/fix-issue
). - Commit your changes with meaningful messages.
- Push to your branch and create a Pull Request.
This project is licensed under the MIT License. See the LICENSE
file for details.
For any queries, feel free to reach out:
- Email: anubhavauth@gmail.com
- GitHub: anubhav-auth
Happy Coding! 🚀