websocket-chat

module
v0.0.0-...-a2ea4c1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2024 License: MIT

README

Single group chat

Build

Prerequisites
  • Docker 26.0.0
  • Makefile 3.81
  1. Clone project:
git clone git@github.com:vlasashk/websocket-chat.git
cd websocket-chat
  1. Run:
    1. Server
      make run_server
      
    2. Client
      make run_client
      
  2. Tests with coverage:
make test_server

Project information

Architecture
sequenceDiagram
    participant C as Client
    participant S as Server
    participant R as Redis
    participant K as Kafka
    participant SS as Storage Service
    participant P as Postgres DB

    C->>+S: Connect via Websocket
    S->>+SS: HTTP /register
    SS->>+P: Store user nickname
    P-->>-SS: Return user ID
    SS-->>-S: Return user ID
    S->>+R: Fetch last 10 messages from cache
    R-->>-S: Return messages
    S-->>-C: Send last 10 cached messages

    loop Each Message
        C->>+S: Send message
        S->>+R: Cache message
        R-->>-S: Confirm cache update
        S->>+K: Forward message to Kafka
        S-->>-C: Broadcast message to all clients
        K->>+SS: Pass message to Storage Service
        SS->>+P: Store message in Postgres
    end

    note over S: Caches last 10 messages
Restrictions/Peculiarities
  • Single chat group - server as a single space for all clients (all clients communicate in a single common space)
Tools used

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL