Implemented a scalable full-stack chat room application that allows real-time group chat and message voting for a 3-day hackathon
- User account creation (sign in / sign up)
- Chat room info with online member count display
- Group chat
- Upvote/downvote or undo upvote/downvote each message (no multivoting)
- Frontend: React Javascript
- Backend: Go, Gin
- Protocol: RESTful API, Websockets
- Message Queue: Redis
- Database: MongoDB
- Local Deployment: Docker
- Infrastructure: Minikube
- Basic password authentication and secure storage
- JSON Web Token for authentication and secure connections
- Horizontally scalable API Server and Chat Server (messaging, upvote/downvote)
- Decoupled API Server and Chat Server
Note: The Load Balancer is not implemented and is only to show how the Client load can be distributed evenly among Chat Servers, since the Chat Servers are implemented to be able to horizontally scale.
- The Client will contact the API Server to create a new account in which the new user info will be stored in User Database.
- The Client will then sign in and retrieve a JSON Web Token (JWT) and Chat Server's server info.
- Client can then use the JWT and server info to authenticate and establish web socket connection with a Chat Server.
- After the Client is connected, the Chat Server will push all the chat history to the Client through the web socket.
- The Client can now send messages in the chat room.
- The Chat Server will receive the message, process it, store it in Chat Database, and publish it to the Pub/Sub Redis message channel.
- All subscribed Chat Servers will receive the message and broadcast it to all the connected Clients through web socket.
- All online Clients can now either upvote/downvote or undo upvote/downvote the messages in the chat room.
- The Chat Server receives the vote, update both the vote count and voter in the database, and publish the updated message.
Run docker containers and access at http://localhost:8080
docker compose up
-
Create a minikube cluster
minikube start
-
Point your shell to minikube's docker-daemon
minikube docker-env eval $(minikube -p minikube docker-env)
-
Build and pull your docker images
docker compose build docker compose pull
-
Deploy api server, chat server, mongodb, and redis into the minikube cluster
kubectl apply -f deployment