Better Programming

Advice for programmers.

Follow publication

The Pros and Cons of Monorepos, Explained

Should you keep all of your code in a single directory?

Harsha Vardhan
Better Programming
Published in
3 min readSep 23, 2020
A basic monorepo approach
Photo from Brigad Engineering Blog.

What Is Monorepo?

As the name suggests, Monorepo (mono repository) is an architectural pattern where a single repository will contain all the code for a given project.

In other words, you can have several apps in one repo. You can either have a website code base, mobile app code base, etc. in a single repo. Or you can also have a single repo that contains several different modules of a complex application, where each module is an isolated app.

Monorepo vs. Multirepo

As I said before, Monorepo keeps everything in a single repo. Multirepo (aka Polyrepo), on the other hand, has one repository per project. If there are four projects, there will be four repositories.

Advantages of Using a Monorepo

Using a Monorepo architecture pattern has several advantages. Let’s look into them:

  • One source of truth — Instead of having a lot of repositories with their own configs, we can have a single configuration to manage all the projects, making it easier to manage.
  • Code reuse — If there is a common code or a dependency that has to be used in different projects, we can actually share them easily.
  • Transparency — It gives us visibility of code used in every project. We will be able to check all the code in a single place.
  • Atomic changes — We can make a single change and reflect the changes in all the packages, thus making development much quicker.

Disadvantages of Using a Monorepo

When there are advantages, there should also be some disadvantages. Let’s have a look at a few disadvantages:

  • Unable to restrict access — Every member who has access to the repo will have access to view all the code. There’s no way to restrict some parts of the app, which is irrelevant to the user.
  • Long build times — Since there is a lot of code in one place, the build time is much longer compared to building separate projects independently.
  • Git performance —…

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Harsha Vardhan
Harsha Vardhan

Written by Harsha Vardhan

Engineer, Photographer, Tech Blogger. Builds products and writes for developers. I love to code and love to help others code :)

Responses (1)

Write a response