Skip to content

A web application built to test and learn event-driven architectures a.k.a microservices.

License

Notifications You must be signed in to change notification settings

MagnusAk78/play_with_microservices

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

play_with_microservices

Build Status License

Table of contents

General info

This is a very asynchronous Rubik's cube web application that I built while learning about event-driven architecture following the book 'Practical Microservices'. The code is completely rewritten but keeping the architecture of the original. I chose the Rubik's cube as my implementation since they may have many states but very simple actions. I use the cubejs package for interaction and representation of the Rubik's cube. After registration and log-in, users can create their own cubes. Three different 'applications' handles the creation, listing, and handling of the cubes. The applications create commands that are messages sent to the message store connected to a stream. Streams are connected to a category ('cubes') and a unique id (cubeId). The cubes component subscribes to these commands and act upon them. If the command is accepted, the component creates an event message. (E.g. the 'Create' command leads to an 'Created' event.) The events are again stored to the message store and the cubes aggregator module subscribe to the events. The aggregator can load a rubik's cube state by running a reduce command over all events and then crate a specific view data (database entry) for the applications to show to the users. This architecture allows for decoupling between users actions (commands), system results (events), and database entries (aggregation). However, since every action automatically becomes a background task, it results in slower response times for the user. Since solving rubik's cubes should be a time sensitive task, this architecure is perhaps the worst example for this sort of appllication, but that is besides the point.

Features

  • Register user
  • Create rubik's cubes
  • Do moves to solve the cubes

Sources

Technologies

Some selected packages.

Setup

Install

Crete .env file

COOKIE_SECRET=some secret
LOG_LEVEL=e.g. debug
MONGO_URI_DB=Url to database for view data, e.g. mongodb://127.0.0.1:27017/view-data
MONGO_URI_MESSAGE_STORE=Url to database for view data, e.g. mongodb://127.0.0.1:27017/message-store
PORT=web server listening port to e.g. 3000

Run

Start a MongoDB instance.

$ npm run start

License

About

A web application built to test and learn event-driven architectures a.k.a microservices.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published