What Is a Monorepo?
Some development teams use a monorepo. Some use multiple repositories. Here we cover what a monorepo is — and the benefits of using it.
What Is a Monorepo? And Why Should You Care?
A monorepo (mono repository) is a single repository that stores all of your code and assets for every project.
Using a monorepo is important for many reasons. It creates a single source of truth. It makes it easier to share code. It even makes it easier to refactor code.
Difference Between Monorepo and Monolith
A monorepo is a single repository. A monolith is a massive codebase.
A monolith could be managed in a monorepo. But a monolith could also be split into multiple repositories. Similarly, a monorepo could be used with microservices instead of a monolith.
In this blog, we’re going to focus on the monorepo.
Monorepo vs. Multirepo
A monorepo keeps everything in one repository. A multirepo (multiple repositories) typically has one repository for each project. The more projects, the more repositories. A multirepo is also known as polyrepo.
So, which one is better? Should you keep everything together in one repository? Or should you divide it up into multiple repositories?
Monorepo Is Usually Best For…
Using a single repository gives you visibility into your code and assets for every project. This helps you manage dependencies.
A single repository makes it easier to collaborate. That’s because everyone can access the code, files, and assets. So, developers can share and reuse assets.
Using a single repository can help you accelerate development. For instance, you can make atomic changes (one action to make a change across multiple projects).
Multirepo Is Usually Best For…
Managing a monorepo at scale in Git would never work. As the repository gets bigger, a monorepo in Git becomes a huge problem. So if you have teams using Git, it’s best to have multiple repositories.
Another Git challenge is that Git lacks security. Learn how to lock down Git.
Open Source or Third Party Projects
In some version control systems, you’ll need multiple repositories to use open source projects or work with third party teams. Then you can ensure that third party developers only have access to the project they're working on.
(Of course, with Perforce version control — Helix Core — you can do this with a monorepo or multirepo. You can restrict permissions down to the file level, even in a monorepo. And you can even bring Git projects into your pipeline with Helix4Git.)
So, Why Use a Mono Repository?
Using a mono repository is a good idea for many companies. You can keep all of source code (and other files/digital assets) from every team in one repository. This makes it easier to share with everyone. And it helps you maintain a single source of truth.
After any commit, the new code is visible to and usable by all of your developers. This helps avoid painful merges that are prevalent with trunk-based development.
Here are some reasons why you should consider using a mono repository:
- You want a single source of truth.
- You want to share and reuse code easily.
- You want visibility to manage dependencies (e.g., if you make a change, what else will be impacted?).
- You want to make atomic changes (e.g., one operation to make a change across multiple projects).
- You want teams to collaborate more.
- You want to make large-scale changes (e.g., code refactoring).
If you decide to go the monorepo route, you’ll be in good company. Leading companies — like Google — use a monorepo.
Example: Why Does Google Use a Monorepo?
Google is one of many large companies that famously uses a monorepo.
Google decided early on to use a monorepo — and scaled it up as the company grew. In 2015, the Google monorepo held:
- 86 terabytes of data.
- 2 billion lines of code.
- 9 million unique source files.
So, why did Google choose a monorepo — and stick with it? Because using a monorepo is key to an open and collaborative culture.
Salesforce, Facebook, and Twitter also famously use monorepos.
Of course, if you choose a monorepo, you need a VCS that can support it. And Helix Core can support your monorepo.
Benefits of a Monorepo With Helix Core
There are a lot of great reasons to use a monorepo. And Helix Core is the best version control for your monorepo.
Here are 4 key benefits of using Helix Core for your monorepo.
Helix Core is a powerful version control system. It’s the best option for high performance at scale.
When you have a monorepo in Helix Core, it can handle:
- 10s of 1,000s of users (even geographically distributed teams).
- Unlimited files.
- Petabytes of data.
Helix Core gives you visibility and control into your monorepo. In fact, Helix Core gives you the best of both worlds — monorepo and multirepo.
For example, multirepo isolates behavior. Monorepo ensures shared responsibility and visibility. With Helix Core, you can have the benefits of both.
You can use Perforce Streams to isolate behavior at a branch level. And you can still get visibility into shared responsibility across branches.
Helix Core is secure — and offers customizable security controls. You can use authentication measures like MFA. And you can set access controls down to the file level.
These security permissions help you work with third party developers on your monorepo.
Helix Core is flexible. You can use Perforce Streams to customize and automate workflows for your team.
This helps your team collaborate better on your monorepo.
Your developers will get fast feedback — and faster builds. They’ll be able to spend less time dealing with tools and processes — and more time delivering value.
Get Started With Helix Core
Helix Core gives you a single source of truth across all projects. And it gives you power, control, security, and flexibility for your teams.
See for yourself how Helix Core will help you. You can get started for free for up to 5 users.