{"id":19062490,"url":"https://github.com/manuel-alvarez-alvarez/microservices-workshop","last_synced_at":"2025-04-25T08:59:54.158Z","repository":{"id":134999103,"uuid":"93388999","full_name":"manuel-alvarez-alvarez/microservices-workshop","owner":"manuel-alvarez-alvarez","description":"Main repository for the workshop `From Monoliths to Microservices using CQRS and Event Sourcing`","archived":false,"fork":false,"pushed_at":"2017-06-21T15:05:15.000Z","size":17651,"stargazers_count":8,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-25T01:17:24.721Z","etag":null,"topics":["cqrs","docker","microservice","monolith"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/manuel-alvarez-alvarez.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-06-05T09:41:48.000Z","updated_at":"2020-05-22T06:09:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"70c741a2-290d-4a4b-807b-b350704a1c23","html_url":"https://github.com/manuel-alvarez-alvarez/microservices-workshop","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manuel-alvarez-alvarez%2Fmicroservices-workshop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manuel-alvarez-alvarez%2Fmicroservices-workshop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manuel-alvarez-alvarez%2Fmicroservices-workshop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manuel-alvarez-alvarez%2Fmicroservices-workshop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/manuel-alvarez-alvarez","download_url":"https://codeload.github.com/manuel-alvarez-alvarez/microservices-workshop/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250787712,"owners_count":21487263,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cqrs","docker","microservice","monolith"],"created_at":"2024-11-09T00:26:17.644Z","updated_at":"2025-04-25T08:59:54.138Z","avatar_url":"https://github.com/manuel-alvarez-alvarez.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# From Monoliths to Microservices using CQRS and Event Sourcing [Download](https://github.com/manuel-alvarez-alvarez/microservices-workshop/raw/master/From%20Monoliths%20to%20Microservices%20using%20CQRS%20and%20Event%20Sourcing.pptx)\n\n## Introduction\n\nIn a Microservices architecture state is distributed across many applications and databases. Keeping all the microservices consistent is a non trivial task and here is where CQRS and Event Sourcing really shine.\n\nIn this workshop we will move from a terrible Monolith to a nice Microservices app using CQRS/ES as the middle man. The recipe to Microservices that we will follow here will be:\n1. Start with an ugly Monolith.\n2. Add some CQRS and ES to the Monolith using Spring Streams and Apache Kafka.\n3. Break your CQRS Monolith into small microservices using Spring Cloud.\n\n## Prerequisites\n\n### Git\n\nYou must have a working installation of GIT in your machine (Git Downloads)[https://git-scm.com/downloads]. You can test that it works by running the following command:\n\n```shell\n$ git clone https://github.com/manuel-alvarez-alvarez/microservices-workshop.git\n```\n\nBy the way, it will clone the main repository for the workshop (two birds one stone).\n\n\n### JDK 8\n\nMake sure you have a working installation of the JDK 8 in your machine ([Java SE Development Kit 8 Downloads](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html)). You can test it by running the following command in a console:\n\n```shell\n$ javac -version\n```\n\n### Docker\n\nYou must have a working installation of Docker as well, the community verison will work just fine ([Download Docker Community Edition](https://www.docker.com/community-edition#/download)). You can test it by running the following command in a console:\n\n```shell\n$ docker run docker/whalesay cowsay Ready to rock\n```\n\nYou should see something like this:\n```\n _______________\n\u003c Ready to rock \u003e\n ---------------\n    \\\n     \\\n      \\\n                    ##        .\n              ## ## ##       ==\n           ## ## ## ##      ===\n       /\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"___/ ===\n  ~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ /  ===- ~~~\n       \\______ o          __/\n        \\    \\        __/\n          \\____\\______/\n```        \n\nIn order to prevent downloading too much data the day of the conference I recomment you to prefetch some of the docker images we are going to use:\n\n```shell\n$ docker pull openjdk:8-alpine\n```\n\n```shell\n$ docker pull wurstmeister/zookeeper:3.4.6\n```\n\n```shell\n$ docker pull wurstmeister/kafka:0.10.2.1\n```\n\nRemember to install ```docker-compose``` if it's not installed by default ([Install Docker Compose](https://docs.docker.com/compose/install/)). . You can test it by running the following command in a console:\n\n```shell\n$ docker-compose -v\n```\n\n\u003e **Information**. In a linux machine docker commands require ```sudo``` but you can manage it as non-root user following this [guide](https://docs.docker.com/engine/installation/linux/linux-postinstall/).\n\n## Domain\n\n\u003e **Disclaimer**. All resemblance with reality is pure fiction, nothing shown here is accurate from a physics point of view.\n\nThe purpose of this workshop is to build a particle detector that will try to find evidence of the theoretical particle called [Chameleon](https://en.wikipedia.org/wiki/Chameleon_particle). The current [Standard Model](https://en.wikipedia.org/wiki/Standard_Model) includes the following particles:\n\n![Standard Model](https://upload.wikimedia.org/wikipedia/commons/0/00/Standard_Model_of_Elementary_Particles.svg)\n\nThe workshop will provide you an [accelerator](https://github.com/manuel-alvarez-alvarez/microservices-workshop-common/tree/master/accelerator) that will send [snapshots](https://github.com/manuel-alvarez-alvarez/microservices-workshop-common/blob/master/api/src/main/java/es/malvarez/microservices/api/Snapshot.java) every 5 seconds to a kakfa instance containing the lists of detected particles in the different [experiments](https://github.com/manuel-alvarez-alvarez/microservices-workshop-common/blob/master/api/src/main/java/es/malvarez/microservices/api/Experiment.java). For each [deteced particle](https://github.com/manuel-alvarez-alvarez/microservices-workshop-common/blob/master/api/src/main/java/es/malvarez/microservices/api/DetectedParticle.java) you will find the following information:\n\n1. The  [experiment](https://github.com/manuel-alvarez-alvarez/microservices-workshop-common/blob/master/api/src/main/java/es/malvarez/microservices/api/Experiment.java) where it was detected\n2. The [spin](https://github.com/manuel-alvarez-alvarez/microservices-workshop-common/blob/master/api/src/main/java/es/malvarez/microservices/api/Spin.java) of the particle\n3.  The [charge](https://github.com/manuel-alvarez-alvarez/microservices-workshop-common/blob/master/api/src/main/java/es/malvarez/microservices/api/Charge.java) of the particle\n4.  The mass in MeV/c2 (it's always an exact number, e.g. for an electron it will always be 0.511MeV/c2 and for the tau neutrino it will be 15.5 MeV/c2)\n\nThe tool we are about to build should:\n\n1. Detect collisions inside [snapshots](https://github.com/manuel-alvarez-alvarez/microservices-workshop-common/blob/master/api/src/main/java/es/malvarez/microservices/api/Snapshot.java). A collision happens when three or more particles are detected in the same [experiment](https://github.com/manuel-alvarez-alvarez/microservices-workshop-common/blob/master/api/src/main/java/es/malvarez/microservices/api/Experiment.java)\n2.  Analize each one of the collisions and get the [type](https://github.com/manuel-alvarez-alvarez/microservices-workshop-common/blob/master/api/src/main/java/es/malvarez/microservices/api/ParticleType.java) of the particles to find the elusive [chameleons](https://en.wikipedia.org/wiki/Chameleon_particle)\n\n\n## Workflow\n\nAs stated before, we are going to follow the next steps in the workshop:\n\n1. Build a monolith in order to get used to the domain and some technologies we will use later\n2. Convert the monolith ot a CQRS/ES application\n3. Break the CQRS/ES application into different microservices\n\nIn order to do it there are several branches (the ones with the suffix *_start* are the starting point for the step, and the ones with *_end* contain my very own lousy solution).\n\n* Monolith\n1. ```git checkout monolith_start```\n2. ```git checkout monolith_end```\n* CQRS/ES\n1. ```git checkout cqrs_start```\n2. ```git checkout cqrs_end```\n* Microservices\n1. ```git checkout microservices_start```\n2. ```git checkout microservices_end```\n\nSo let's start buidling the **Monolith**\n\n```shell\n$ git checkout monolith_start\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmanuel-alvarez-alvarez%2Fmicroservices-workshop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmanuel-alvarez-alvarez%2Fmicroservices-workshop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmanuel-alvarez-alvarez%2Fmicroservices-workshop/lists"}