DhruvikDonga / wordsbattle

text based games more to come
http://www.miniwordgames.com
26 stars 4 forks source link

WB-8: Refactor Golang backend code #12

Closed DhruvikDonga closed 2 weeks ago

DhruvikDonga commented 1 year ago

Table of Contents

  1. Context
  2. Purpose
  3. Severity
  4. Approach
  5. Expected Results
  6. Task list

Context 🚀

Currently, the backend codebase, which is written in Golang, has many internal issues that have a high possibility of causing problems in further development and expansion plans.

There are many places where over-engineering has occurred, resulting in the addition of useless code and a lack of proper code structuring around the WebSocket and lobby implementation. Proper error handling is also lacking.

Purpose 🎯

The main purpose of developing this ticket is to address the following issues and introduce new features:

Severity 🛑

The development of this ticket will indeed require a significant amount of time and should be treated as a priority. Neglecting it can result in a more unstable existing system, which can lead to further complications down the line. Additionally, by addressing these issues and improving the system, there is an opportunity to open-source it, which can bring several benefits.

It's essential to allocate the necessary time and resources to address the issues, improve the stability of the existing system, and seize the opportunity to open-source the project. By doing so, you can not only resolve immediate concerns but also leverage the benefits that come with open-source collaboration. There is also a proposal to introduce multiple wsServers and wsClients every time a new game is created for better package management.

Approach 📐

The approach to this ticket should indeed be different from other tickets, considering the specific requirements and goals involved. Here are some methods that can be employed:

By incorporating these methods into the ticket's approach, you can enhance the clarity, quality, and maintainability of the codebase, ultimately improving the overall development process and the system's production-readiness.

Expected Results 🌟

The expected results are subject to changes as the development progresses:

Please note that these expected results may evolve or be refined based on the ongoing development process and user feedback.

Task list ✅

This ticket will be in development unless all the checklist are done this is used to keep track new tasks might be added simultaneously

DhruvikDonga commented 1 year ago
graph TD
    node7((wordsbattle app))
    node1[[HTTP server URL for ws connect :-/ws?name=Username]]
    node2[[Game server <small>game->cow</small><br><small>Maintains maps list of rooms and clients <small><br><small>Create/Delete rooms , Add/Remove clients</small>]]
    node3[[Room server <small>game->cow</small>]]
    node13[[Room Server State manager]]
    node4[Client]
    node5[[Client Readpump <br><small>Recieve the messages concurrently<br> from client</small>]]
    node8([Join Room])
    node9([Leave Room])
    node10([Join Random Room])
    node11([Send Message to a room])
    node6[[Client Writepump <br><small>write the messages concurrently<br> to clients</small>]]
    node12((VueJS game UI))

    node7-->|intialized in main thread|node1
    node7-->|intialized in main thread|node2
    node1-->node4
    node4-->node5
    node4-->node6
    node5-->node8
    node5-->node9
    node5-->node10
    node5-->node11

    node2-->node3
    node8-->node2
    node10-->node2
    node9-->node2

    node11-->node3
    node3-->node6

    node6-->node12
    node12-->node1

    node3-->node13
    node13-->|manages the state of room <br>the store values of client<br>Customizable to send the messages from server side|node3
DhruvikDonga commented 1 year ago
graph LR
    node1(Message Processor)
    node4(Observer Lobby Server)
    node5(wsclient1)
    node2(Message Reciever 1)
    node3(Message Sender 1)
    node6(Algorithm and room state watcher)
    node7(wsclient2)
    node8(Message Reciever 2)
    node9(Message Sender 2)
    node10(wsclient3)
    node11(Message Reciever 3)
    node12(Message Sender 3)
    node13(wsclient4)
    node14(Message Reciever 4)
    node15(Message Sender 4)
node16(Message Processor arch)
    node17[clients list]
    node18(client1 message sender)
    node19(client2 message sender)
    node20(client3 message sender)

    node21[[Client connected]]
    node22[[Client disconnected]]
    node23[[Room created]]
    node24[[Room deleted]]
    node25[[Client Joined a Room]]
    node26[[Client Left a Room]]
    node27[[Event Triggers]]

    node28[(Clients Map <br>cid_key--struct)]
    node29[(Rooms Map <br>roomname_key--struct)]
    node30[(Room to client map <br>roomkey--map-clinetkeys)]

    node31[[Message Send in a processor <br> 1. Action to be done/message type <br> 2. Room address <br> 3. If not 2nd then client address <br> 4. Message body]]

node31-->node16
    node16-->node17
    node17-->node18
    node17-->node19
    node17-->node20
    node17-->node30

    node27-->node21
    node27-->node22
    node27-->node23
    node27-->node24
    node27-->node25
    node27-->node26

    node21-->node28
    node22-->node28

    node23-->node29
    node24-->node29

    node25-->node30
    node26-->node30
    node30-->node28
    node28-->node17

    node2-->node1-->node3
    node8-->node1-->node9
    node11-->node1-->node12
    node14-->node1-->node15

    node6-->node1
    node5-.->node2
    node5-.->node3

    node7-.->node8
    node7-.->node9

    node10-.->node11
    node10-.->node12

    node13-.->node14
    node13-.->node15

    node4-.->node5
    node4-.->node6
    node4-.->node1
    node4-.->node7
    node4-.->node10
    node4-.->node13
DhruvikDonga commented 11 months ago

gomeshstream a package which will have seperate ws rooms handeling logic :- https://github.com/DhruvikDonga/gomeshstream package is in development parallel to this issue