MonoRepo vs MultiRepo?

Highlight the difference between Mono and Multi Repo

Satrio Wibowo
5 min readSep 22, 2022
Difference between monorepo, monolith, and multirepo. Image source: https://www.toptal.com/front-end/guide-to-monorepos

What is MonoRepo?

Monorepo (mono = one, repo = repository) is a git strategy to use a single repository that holds many projects. While these projects may be related, they are logically independent and run by different teams.

While monorepo may have similar structure with monolith architecture, Monorepo is not a monolith architecture. By concept, each project in monorepo must be able to run independently, with the exception of shared dependencies. For example, Team A may be write a poorly written code and badly written test case, this will NOT affect team B as their code is on different side of the repo.

To make the example clearer, look at monolith architecture directory structure below:

Monolith Architecture

We can observe that in monolith architecture the program shared a single entry point (that is index.js). Look for the difference in monorepo directory structure:

Monorepo Directory Structure

In the example, we can observe that panel and www have their own entry files (index.js) and maintaining each application autonomy while also be able to reuse the same libraries that both application may use. This approach commonly used by Google (src/android-10, src/android-11) and Microsoft.

What is MultiRepo / Poly-Repo?

Polyrepo (poly = many, repo = repository), as the name suggest, is the opposite of monorepo. Instead of using single repository to host multiple part of a project, poly-repo separates each project repository into their own and in the later stage those repos will be merged into single place.

So, how poly-repo looks like from directory structure standpoint?

MultiRepo Directory Structure

In multirepo system, there is multiple repositories that run as one component with each repositories have their own entry point (index.js) and routing system. This approach commonly used by open-source projects.

After we understand how monorepo and multirepo system looks like by their directories, you may be asking what is the pros and cons of each system. And here is the reasons you need to use one or the other

MonoRepo Pros and Cons

Advantages of Monorepo

Visibility and Discoverability: When you need to look up for certain code, it is really easy to look for because everything is in one place. It can also increase developer’s awareness of how other department solve the problem they may face. If there is a chance to reuse chunk of code, it will be easy for them to find.

Supports team collaboration: Because everything is in a single place, each team can work collaboratively. Code sharing also can be done easier to reduce code replication.

Easier code refactoring: Because everything is in a single place, steps required to improve the code is easier as long as the external behavior did not change.

Encourage Standardization: Because basically everyone working on a single thing, monorepo encourage a more united and standardized coding style, reducing teams fragmentation because one prefer one style over the other.

Disadvantages of Monorepo

BIG. REPO. SIZE. With everything in one place, the storage size required to pull the source code can be HUGE. For example, to download Android Open Source Project (AOSP) Source Code you need at least 250GB of free disk space to check out the code and an extra 150 GB to build it. If you conduct multiple builds, you need additional space.

Overwhelming for new joiners: Because everything available from day one, the amount of code that new joiners need to learn is so much it can overwhelm them. Proper onboarding and support are crucial to manage this problem.

Longer build time: As the code getting bigger and bigger, build times required can also be greatly increased, which will slow things down.

Lack of Access Control: Because everyone have access to everything, this may pose a security issue. Also, file ownership may also be muddied because everyone can modify any files. Clear standard operational protocol and code hierarchies are required to address this problem.

Risk of Tight-Coupling: When you are working on the same repository, you may tempted to couple your code with other existing code. This in-fact will defeat monorepo strategy purpose and make your application back to monolithic system.

How about Multirepo?

Advantages of Multirepo

Independent Service Releases: Because each repository only contains the code for some service and nothing else, each repository can have their own development and release cycle.

Independent Library Versioning: Because each repository have their own structure, there is no need to worry if certain code requires certain library version and other part requires other certain library version. Each part are moving on their own.

Clear Access Control: Because everything is not in one place, developer A may be only given access to feature A and developer B may be only given access to feature B. This will also make code ownership clearer.

Allows Teams To Work Autonomously: Because each team is work separately, each team can design the library’s architecture and work in isolation from other teams. They can make decisions based on what the library does in general context without being affected by requirements set from external team (other than returns data, of course).

Disadvantages of Multirepo

Library re-sync is often required: Whenever a team introduces a breaking changes, other teams will need to catch up to use the latest releases from other teams. Given that different teams may have different priorities, this may be difficult to achieve.

Team Fragmentation: Because each teams did not need to interact with each other, they may produces a new subcultures within the company, such as employing different methodologies of programming or management, or utilizing different sets of development tools. This may create a culture shock when a developers move to work in a different team.

Conclusion

Whenever you use monorepo or multirepo approach, remember that these strategies will depends on how you and your team manage and implement the strategies. No matter how good the approach you use, if you are not consistent with your implementation, it will ends up to go to waste anyway. So be consistent and use the tools and strategy according to your teams need! 😃

Happy Coding!

--

--