I'm connecting to a MySQL database with a fastapi backend and I require live updates between the back and frontend when inventory in the database is changed. The primary goal is to avoid showing stock on items that are actively being sold (change from 1 to 0) during time of lookup. I can't find a library that helps organize this sort of functionality and it looks like I'll need to implement it myself. Is there a best method to do so? At first glance it looks like I'm probably going to be doing a lot of object sorting/editing in my websocket callback. Unfortunately the functions that are responsible for getting and sending back the data don't all pull identical information. The current workflow goes something like so: Frontend connects to backend socket - the socket accepts a string url to use as an identifier. Frontend sends request. Request processed as normal but prior to return statement sorts through connected websockets, finds one with matching route and adds the return data to a dictionary containing the matched socket. Web socket remains open. If another window creates a change on the same route the editing sockets data is pushed to all others. Frontend updates based on data received from socket. This is really limited by the identifier that I can pass through and means that an update on the inventory route won't affect the sales route. Does anyone with experience have a good solve/recommendation to make this work? Current Class being used to manage the websockets: def __init__(self): self.activate_connections: list[WebSocket] = [] async def connect(self, websocket: WebSocket, route: str): await websocket.accept() self.activate_connections.append({ 'socket': websocket, 'route': route }) async def disconnect(self, websocket: WebSocket, route: str): for socket in self.activate_connections: if (socket['route'] == route): self.activate_connections.remove(socket) async def addReturnedData(self, data: dict, route: str): for connection in self.activate_connections: print(connection) if connection['route'] == route: connection['data'] = data async def broadcast(self, newData: dict): print(newData) jsonData = json.dumps(newData) print(jsonData) for connection in self.activate_connections: await connection['socket'].send_json(jsonData) Continue reading...