Skip to content

Simple Chat service using Hexagonal Architecture with Go

Notifications You must be signed in to change notification settings

posilva/simplechat

Repository files navigation

Simple Chat

Simple Chat service using Hexagonal Architecture with Go


How to run

Use Makefile targets

Short version if you have all the tools installed and configured (never happens :) ) (it will start a local web page http://localhost:8081 that you can connect to play with chat)

make setup

Create containers to run the service with docker compose

make infra-up

Run local infra setup - executes terraform code against LocalStack

make infra-local #

Executes tests and creates coverage report against local infra

make cover


Architecture

  • Handler: http with WebSocket
  • Repository: DynamoDB
  • Notifier: RabbitMQ
  • Moderator: Ignore (just passthrough the message, no moderation done)
sequenceDiagram 
    title: Connect Flow
    Client -->> WebSocket: Connect(uID, roomID)
    WebSocket -->> ChatService: Register(uID, roomID)
    ChatService -->> Notifier: Register(uID, roomID, receiver)
    Notifier ->> ChatService: Registered 
    ChatService --> WebSocket: Registered
    WebSocket -> Client: Connected 

Loading
sequenceDiagram 
    title: Send Message Flow
    Client -->> WebSocket: Send(message, roomID)
    WebSocket -->> ChatService: Send(message, roomID)    
    ChatService -->> Moderator: Check(message)
    Moderator ->> ChatService: ModeratedMessage
    ChatService -->> Repository: Store(ModeratedMessage)
    Repository ->> ChatService: ModeratedMessageStored
    ChatService -->> Notifier: Broadcast(ModeratedMessage, GroupId)
    Notifier ->> ChatService: Sent OK
    ChatService ->> WebSocket: Sent
    WebSocket ->> Client: Sent
Loading

TODO

  • Implement a Presence component that embeds the notification system
  • Integrate a mock framework (gomock)
  • Add logging
  • Integrate Golang Linters
  • Implement WebSocket Handler
  • Add Grafana, Prometheus to Docker Compose
  • Separated UnitTest from Integration Tests (with local infra)
  • Improve tests that cover errors
  • Add CICD with Github Actions
  • Add Configuration (Consul, Vault)
  • Add metricts
  • Add rate limiting
  • Add Load Tests Local
  • Add Load Tests Cloud
  • Add deployment on ECS
  • Add deployment on K8S
  • Add deployment on Nomad
  • Explore coverage report in Github [https://github.com/johejo/go-cover-view]

FIX

  • - Remove dependency of AWS CLI by running in a container