Alpha

Back to posts

Monorepo: Introduction

14 May 2023 — 4 min read

Post Image

Contents

Chapter 1: Introduction

Chapter 2: Setup with PnPM

Monorepo is a hot topic recently. Monorepo is a software development practice has many benefits to adopting a monorepo approach that can significantly improve development efficiency, code quality, and collaboration.
 
In this article, we will explore the concept of monorepo in more detail.
 

 

 

What is Monorepo?

 
A monorepo is a single repository contains multiple projects. This can include multiple applications, services, libraries, and other related code.
 

 

 

Why Monorepo?

 
Monorepo is to centralize code base and reduce duplication of code across multiple repositories. With all code in one place, it becomes easier to share and reuse code between projects.
 
Here are some benefits of monorepo:
 

 

  • Visibility: everyone can see all the code of every teams in an organization. A developer can know what the others are working on. This is better for collaboration and contribution.
     
  • Centralisation: one place to manage the dependencies can reduce the versioning conflicts.
     
  • Share and reuse code: all the libs are stored in one repository, we can easily install them as dependencies and reuse it across the projects.
     
  • Atomic commit: a developer can update several projects in one commit to finish a feature that needs to change across the projects.
     
  • Consistency: there is only one code convention and lint for all the projects. Easier to maintain and develop.
     
  • Share CI/CD config: we can reuse the development/deployment process for every project in the repository.
     

 

 

Why not Monorepo?

 
While monorepo can offer many benefits, such as centralized code management, easier code sharing, and improved consistency, it's important to acknowledge that this approach also comes with some potential drawbacks.
 

 

  • Low performance: because monorepo contains all the code in one repository, the repo will grow bigger over time. The bigger the repo, the longer to clone/load the project.
     
  • Low Ownership: we cannot restrict access to specific projects or modules for one team. This can lead to issues with code quality, maintenance, coordination and policy.
     

 

 

Toolings

 

  • Bazel
  • Gradle
  • Lage
  • Lerna
  • Nx
  • Pants
  • Rush
  • Turborepo
     

 

 

Summary

 

Monorepo is an great approach to store all the code into single repository, rather than using multiple repositories. It offers many benefits such as code sharing, coding standard, ...
 
It is very useful for every project, whether it's a personal project or a large team project and especially microservices where there are many small services that need to be managed and integrated.
 
Do not use monorepo when you need strong ownership for each project.


Or

Alpha

Fullstack developer who converts pepsi into code.


Or

Contact

General