Skip to content
Safouene1 on GitHub Safouene Turki on Linkedin

Why Mattermost switched to a Monorepo?

Mattermost is a popular open-source chat platform that is used by businesses of all sizes. In 2023, Mattermost decided to switch to a monorepo architecture. This decision was made after careful consideration of the benefits and challenges of a monorepo. I've interviewed Mattermost Engineers and here are is the article

There are a number of reasons that led to the necessity of monorepo for Mattermost. Some of the key reasons include:

  • Growing codebase: Mattermost's codebase had grown significantly over time. This made it difficult to manage and maintain the code.
  • Fragmented development: Mattermost's developers were working on different parts of the codebase in different repositories. This made it difficult to collaborate and share code, espcially being an open source project , contributors making a change in the web app and server had to make 2 different Pull requests with different reviewers and a longer process.

"The main motivation for switching to a monorepo was to increase developer experience. For example, to work on a feature you would have to open a PR on server and then on webapp, for running up a test server make sure both the branches are same and all that. With monorepo everything is in single place. There are no more silos." - Harrison Healey Web Lead

  • Inefficient CI/CD: Mattermost's CI/CD process was inefficient. This was due to the fact that the code was spread across different repositories. (mostly caused by Inefficient builds and deployements When you have multiple repositories, you have to build each repository separately. This can take a long time, especially that the repositories are large.)
  • Improved vulnerability management: With all of the code in one place, it is easier to track and manage security vulnerabilities. This is because security tools can scan the entire codebase for vulnerabilities, rather than having to scan each repository individually. Improved code review: With all of the code in one place, it is easier for developers to review code without having several seperate pull requests. This can also help to identify and fix security vulnerabilities before they are exploited.

Benefits of a Monorepo

There are many benefits to using a monorepo architecture. Some of the key benefits include:

  • Improved code organization: With all of the code in one place, it is easier to organize and maintain the code. This is because all of the code is in one place, it is easier to see how the different parts of the code interact with each other. This can help to prevent errors and make it easier to debug problems.
  • Improved collaboration: With all of the code in one place, it is easier for developers to collaborate on projects. This is because developers can easily see what other developers are working on and can easily share code and ideas. This can help to improve the quality of the code and make it easier to develop new features.
  • Improved productivity: With all of the code in one place, it is easier for developers to find the code they need and get to work. This is because developers do not have to switch between different repositories to find the code they need. This can save developers time and help them to be more productive.
  • Improved testing: With all of the code in one place, it is easier to test the code and ensure that it is working correctly. This is because developers can easily run tests on all of the code in the repository. This can help to ensure that the code is free of errors and that it is working as expected.
  • Improved security: With all of the code in one place, it is easier to secure the code and protect it from vulnerabilities. This is because developers can easily scan the code for vulnerabilities and can easily fix any vulnerabilities that are found. This can help to protect the code from being exploited by attackers.

Challenges of a Monorepo

There are also some challenges to using a monorepo architecture. Some of the key challenges include:

  • Managing dependencies: With all of the code in one place, it is important to carefully manage dependencies. This includes ensuring that all of the dependencies are compatible with each other and that they are up to date. If a dependency is not compatible with another dependency, it can cause problems with the code. It is also important to make sure that dependencies are up to date, as outdated dependencies can contain security vulnerabilities.
  • Testing: With all of the code in one place, it is important to have a good testing strategy in place. This will help to ensure that changes to the code do not break other parts of the codebase. It is important to test all of the code in the repository, including the code that is not currently being worked on. This can help to ensure that the code is free of errors and that it is working as expected.
  • Documentation: With all of the code in one place, it is important to have good documentation in place. This will help developers to understand the code and how it works. It is important to document all of the code in the repository, including the code that is not currently being worked on. This can help developers to understand the code and to make changes to the code as needed.

Mattermost's Transition to a Monorepo

Mattermost's transition to a monorepo was not without its challenges. However, the company was able to successfully complete the transition in a matter of weeks.

One of the biggest challenges that Mattermost faced was managing dependencies. The company had to carefully review all of the dependencies in its codebase and ensure that they were compatible with each other. Mattermost also had to develop a good testing strategy in order to ensure that changes to the code did not break other parts of the codebase.

Overall, Mattermost's transition to a monorepo was a success. The company has seen a number of benefits since making the switch, including improved code organization, collaboration, productivity, testing, and security. Impact of a switch to a monorepo on open source contributions

The impact of a switch to a monorepo on open source contributions can be positive. With all of the code in one place, it is easier for developers to contribute to the project. This is because they do not have to switch between different repositories to find the code they need to work on. Additionally, with all of the code in one place, it is easier for developers to collaborate on projects. This is because they can easily see what other developers are working on and can easily share code and ideas.

Conclusion

There are many benefits to using a monorepo architecture. However, there are also some challenges that need to be considered. If you are considering switching to a monorepo, it is important to carefully weigh the benefits and challenges before making a decision.