This is a distributed chat application built using Golang and gRPC. The application allows multiple clients to connect to multiple servers and exchange messages in real-time.
The servers use Redis to store client information, allowing clients to connect to any server and maintain their session. The application also uses Kafka for Pub/Sub messaging, allowing servers to communicate with each other and route messages to the appropriate client.
The project includes a proto file defining the gRPC service, as well as server and client implementations. The client includes a simple command-line interface for sending and receiving messages.
- One on one chat
- Chat history
- Ability to add more features as needed
- gRPC for communication
- Golang for building the application
- Redis for storing the gRPC session
- Distributed client-server architecture for enabling communication
- Individuals who want to experiment with building chat applications
- Companies who want to use a basic chat application for their internal communication needs
- Anyone who wants to learn about gRPC and distributed systems
- It starts 2 server, and then we can run cli for each client
- Start the server by running the following command in the terminal:
cd chat-apps/docker
docker-compose up -d
- Register users by sending POST requests to the following endpoint:
curl -X POST localhost:3000/v1/chat-apps/users -d '{ "username":"user1","name":"bar", "phone": "8098080"}'
curl -X POST localhost:3000/v1/chat-apps/users -d '{ "username":"user2","name":"bar", "phone": "8098080"}'
curl -X POST localhost:3000/v1/chat-apps/users -d '{ "username":"user3","name":"bar", "phone": "8098080"}'
curl -XGET localhost:3000/v1/chat-apps/users?username=user1
- Start the client by running the following command in the terminal:
go run cmd/client/client.go -grpc :50055 -http :3000
- Once the client is started, enter the username when prompted. After registration, enter the sender's name and message to send the message. The client will also receive incoming messages.
- Pre-requisite
- Install redis
- Update connection detail in config.json
- Start application
- start service
cd chat-apps/
go mod tidy
go mod vendor
- Start server and create multiple user
go run cmd/server/chat-apps.go -grpc :50050 -http :3000
- Register users by sending POST requests to the following endpoint:
curl -X POST localhost:3000/v1/chat-apps/users -d '{ "username":"user1","name":"bar", "phone": "8098080"}'
curl -X POST localhost:3000/v1/chat-apps/users -d '{ "username":"user2","name":"bar", "phone": "8098080"}'
curl -X POST localhost:3000/v1/chat-apps/users -d '{ "username":"user3","name":"bar", "phone": "8098080"}'
curl -XGET localhost:3000/v1/chat-apps/users?username=user1
- Start client
go run cmd/client/client.go -grpc :50055 -http :3000
- Once the client is started, enter the username when prompted. After registration, enter the sender's name and message to send the message. The client will also receive incoming messages.
- queue for dead message not verified
- group message
- unread message utility
username should be metadata so that during failure, we will be able to close connection