A POC for setting up a SocketIO microservice that emits changes in Mongo databases
For a full explanation, see my blog: Abaganon Mongo Change Stream Sockets
A SocketIO microservice is created that listens to change streams from databases (specified in sockets/config.json) in a Mongo replica set.
A simple front-end exists that allows you to connect to a socket room based on UUID. Then you can update/insert documents attached to that UUID by using the other front-end form (which sends a post request to a simple back-end that tells Mongo to update/insert the document). If you're listening to the same UUID socket room of the document you've updated/created, you'll see those updates printed below.
Finally, Mongo-Express is installed so you can see the data you've been playing with and Redis is installed to store socket connections states (allowing you to scale the socket service as needed).
You need Docker installed (not in Swarm mode).
docker compose up -d
Everything should build and deploy automatically.