This repo contains a demo stack for a reactive architecture.
The front-end is responsible for serving the main web page.
It creates a websocket connection back to itself to pass messages.
When a user comments, it is emitted over the websocket connection to the app.
This app takes this and publishes the comment.received event to the #MessageBus
This app listens for comments.updated events and upon receiving one, published a message on the socket so the web page can update itself.
PORTset this to the port you want the service to serve fromRABBITMQ_HOSTNAMEthe host address of your rabbitmq service
PORT=80 npm start
The parser is a service which "normalizes" comments.
This app listens for comment.received events and upon receiving one it truncates the message to 100 characters and publishes the event comment.normalized with the truncated data.
If the comment has the word hate in it, it publishes the event comment.normalize-error.
RABBITMQ_HOSTNAMEthe host address of your rabbitmq service
npm start
The db is a service which saves comments.
This app listens for comment.normalized events and upon receiving one it saves the message into the database (currently redis)
After saving it publishes comments.updated event with all the comments in the database
It also listens for user.connected events and upon receiving one it publishes comments.updated event with all the comments in the database
RABBITMQ_HOSTNAMEthe host address of your rabbitmq serviceREDIS_HOSTthe host address of your redis service
npm start
The emailer is a service which sends emails.
This app listens for comment.received events and upon receiving one it it sends an email to the address defined by EMAIL_ADDR
RABBITMQ_HOSTNAMEthe host address of your rabbitmq serviceEMAIL_ADDRthe email address to send emails to
npm start
The message bus is RabbitMQ
The datastore is Redis
There are 3 compose files.
docker-compose.yml- Use to launch the entire applicationdocker-compose-local.yml- Use to launch everything but front-end and rabbitdocker-compose-remote.yml- Use to launch front-end and rabbit.
I split local and remote because remote should be launched on a server which everyone should have access to and local for services that do not need access.
The configuration files for Kubernetes live in ./deployments
The files at the root of deployments are deploy files and the files in the deployments/services define all the k8 services.
Every service has a Dockerfile at the root. Simply run docker build . to build docker images.
These docker images are also build on docker hub with the following format:
- runnable/reactive-demo:frontend
- runnable/reactive-demo:parser
- runnable/reactive-demo:db
- runnable/reactive-demo:emailer