Code icon

Engineering

Reading progress

A diagram explaining monorepo vs multirepo
A diagram explaining monorepo vs multirepo

Shifting Huddle01 to Monorepo Architecture ⚒️

For any digital experience-focused company, code quality security is a critical factor. The code's architecture, storage, access, and evolution are essential considerations. To manage this, all software projects utilize version control software.

Author Image

Huddle01

Feb 6, 2023

Share on

For any digital experience-focused company, code quality security is a critical factor. The code's architecture, storage, access, and evolution are essential considerations. To manage this, all software projects utilize version control software.

Current Approaches and Multirepo

The Multirepo approach involves dividing the codebase into multiple repositories, each maintained independently. This is often the starting point for small projects. However, as the number of repositories grows, the overhead of maintaining them increases, resulting in challenges such as code duplication, dependency management, and end-to-end testing. Additionally, a small change in one repository may impact multiple repositories, requiring review and merge processes that Monorepo addresses.

What is Monorepo?

Monorepo is a central repository that holds all the code for a project or a company. Instead of having multiple repositories for different projects, all the code is stored and versioned in one place. This approach has several advantages, such as better collaboration across teams and simplified dependency management, as well as disadvantages, such as limitations around access control and version control tooling issues.

Advantages of Monorepo

  1. Improved Team Collaboration

    1. All projects are housed in one repository, enabling all team members to view and utilize the code, making it easier to create and leverage shared libraries and reducing technical debt.

    2. The co-location of code makes it easier to identify and resolve inter-dependencies and potential conflicts.

  2. Streamlined Dependency Management

    1. Multiple teams within a company may work on different projects that share common dependencies. Storing all dependencies in a central location resolves the diamond dependency problem.

    2. This approach allows for faster and more straightforward dependency upgrades, downgrades, and testing, and facilitates the detection of vulnerabilities in shared libraries.

  3. Large-Scale Code Refactoring

    1. MonoRepo allows for comprehensive code changes across multiple areas of the codebase to be executed and reviewed in a single pull request, speeding up the time to deployment.

Disadvantages of Monorepo

  1. Build Pipeline Complexity

    1. Each repository may have its build pipeline, making it challenging to standardize processes. To overcome this, some companies like Google and Meta have developed their build solutions.

    2. While MonoRepo allows for module caching, the cost of setting up the infrastructure is higher.

  2. Access Control Limitations

    1. Access control is a major challenge in Monorepo, as granting access to the entire codebase for all engineers may not be desirable.

    2. Open-sourcing parts of the code is more challenging, as it requires extraction of code dependencies and packages.

  3. Version Control Tooling Issues

    1. Large codebases, such as those at Google or Microsoft, with many tests, linters, and commits, can result in performance issues in version control systems. This led Google to develop its own VCS tool.

Huddle01 and Monorepo

The decision to use Monorepo or Multirepo ultimately depends on the specific use case and the organization's ability to effectively manage the challenges posed by Monorepo. The choice of architecture reflects and influences the company's culture, impacting factors such as speed of development, collaboration across departments, and lines of ownership.

At Huddle01, we initially used a Multirepo approach for managing our services, but as the number of services grew, we switched to a Monorepo structure using TurboRepo. This solution met our requirements for a Monorepo, including support for open-sourcing our services.