Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/samy-soliman/go-next-ts-chat
Deploying a Realtime chat built with Go, Next & Typescript using GitHub Actions | Docker-Compose | Kubernets | Prometheus | Grafana | Terraform
https://github.com/samy-soliman/go-next-ts-chat
devops docker docker-compose github-actions gke golang googlecloud grafana kubernetes nextjs postgresql prometheus terraform
Last synced: 1 day ago
JSON representation
Deploying a Realtime chat built with Go, Next & Typescript using GitHub Actions | Docker-Compose | Kubernets | Prometheus | Grafana | Terraform
- Host: GitHub
- URL: https://github.com/samy-soliman/go-next-ts-chat
- Owner: samy-soliman
- Created: 2024-01-03T19:39:35.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-03-11T23:28:58.000Z (8 months ago)
- Last Synced: 2024-11-15T21:51:32.931Z (2 days ago)
- Topics: devops, docker, docker-compose, github-actions, gke, golang, googlecloud, grafana, kubernetes, nextjs, postgresql, prometheus, terraform
- Language: Go
- Homepage:
- Size: 35.1 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: ReadME/Development.md
Awesome Lists containing this project
README
# Development
## Hub Architecture
![Initial Hub Architecture](/assets/hub_initial.jpg)
First, we have the hub running on a separate goroutine, which is the central place that manages different channels and contains a map of rooms. The hub has a Register and an Unregister channel to register/unregister clients, and a Broadcast channel that receives a message and broadcasts it out to all the other clients in the same room.
![Client joins room](/assets/join_room.jpg)
A room is initially empty. Only when a client hits the `/ws/joinRoom` endpoint, that will create a new client object in the room and it will be registered through the hub's Register channel.
![Hub Architecture](/assets/hub_architecture.jpg)
Each client has a `writeMessage` and a `readMessage` method. `readMessage` reads the message through the client's websocket connection and sends the message to the Broadcast channel in the hub, which will then broadcast the message out to every client in the same room. The `writeMessage` method in each of those clients will write the message to its websocket connection, which will be handled on the frontend side to display the messages accordingly.