Skip to content

Latest commit

 

History

History
80 lines (57 loc) · 3.79 KB

README.md

File metadata and controls

80 lines (57 loc) · 3.79 KB

Go Microservices Realtime Finance Chat Application with RabbitMQ, Websockets, JWT, Mux, Gorm(MySQL), And React

The goal of this exercise is to create a browser-based chat application using Go. This application allows several users to talk in one or more chatrooms and also to get stock quotes from an API using a specific command.

Requirement

The following tools are required to run the project

  • Go (Golang)
  • RabbitMQ
  • MySQL
  • Docker(optional)

Context

I use the poly repo ideology, hence, the project works in collaboration with two other repositories:


This service reads published stock bot requests to env.STKBT_RECEIVER_QUEUE queue on RabbitMQ and reads the processed stock response on env.STKBT_PUBLISHER_QUEUE queue on RabbitMQ.


Starting The App


Step 1 : Start RabbitMQ

RabbitMQ is the message broker between the bot service and the chat service. To run it with docker, run the folling command in your terminal:

docker run -d --hostname rabbitmq-svc --name rbbtmq -p 15672:15672 -p 5672:5672 rabbitmq:3.11.3-management


Step 2 : Update Env file

copy the .env.example to .env and update the entries.

Step 3 : Starting the app

run the folling command in your terminal go run cmd/main.go


Step 4 : Start Bot service app

visit this repo: https://github.com/omept/go-stockbot-rabbitmq.git on steps for stating the app


Step 5 : Start React frontend app

visit this repo https://github.com/omept/go-chat-react.git on steps for stating the react frontend app


REST Endpoints

The table below describes the endpoints available on the app:

#### Routes ⚡
| Routes                     | HTTP Methods | Params                         | Description                                      |
| :------------------------- | :----------- | :----------------------------- | :----------------------------------------------- |
| /v1/api/auth/signup        | POST         | `email` `password` `user_name` | Creates a new user and returns jwt session token |
| /v1/api/auth/login         | POST         | `email` `password`             | Logs in a user and returns the jwt session token |
| /v1/api/chat/create        | POST         | `name`                         | Creates a new chat room with the name provided   |
| /v1/api/chat/rooms         | POST         | none                           | returns a list of chat rooms                     |
| /v1/api/chat/room-messages | POST         | `roomId`                       | Returns the latest 50 messages in a chat room    |
| /v1/ws                     | GET          | none                           | websocket connection url                         |

App tests

Run the command below to execute tests

go test github.com/omept/go-chat/services

Useful Links