Monorepo and Microservices are two completely different concepts yet often used interchangeably
You might have managed multiple repositories for inter related projects. Monorepo simply puts all these inter related projects into one single repositories. This way you have to manage one single repository for all the projects. You setup deployment flow with single repo. Monorepo also enable code sharing. It originally originated in 2000s. The Software development strategy has been widely used for enterprise development.
Monorepo is implemented on top of microservices in many cases. Microservices is a software development technique which is quite hot right now. A variant of Service Oriented Architecture(SOA) that arranges applications as a collection of losely coupled services. Instead of having everything in one single application we have multiple losely coupled microservices. Each service can have separate database, can be written in different languages and are also easy to replace.
Microservices interact with each other using TCP, kafka, or any other such facility. Each microservice when enabled to use TCP can communicate with other connected services via Message Patterns and Event Patterns. Event Patterns are basically events emitted that sends a signal to execute a certain functionality. For example, sending an email once db is updated. Message Pattern on the other hand allows to exchange data between microservices.
For example, you need some data from DB microservice you send it a message pattern and retrieve data. Now if you are creating all the microservices with same technology you can also create Monorepo in such a way to share package dependencies in between. Like NestJS implements Monorepo architecture. In NestJS you can have as many apps as you need in a separate apps folder. You can have a common libs folder shared among all the apps. You can enable intercommunication using kafka, TCP. Now you must ask how to implement these architectures? For that you need to check out my other blog which is part of this series.
Be First to Comment