A mono-repo or mono repository is when all services and front end codebase are stored in a single version control system (VCS) repository but are deployed as microservices. It allows for several applications to be stored in one repository.
Companies like Dropbox, Google, Facebook, Twitter, and others organize their code in a single repository. On the flip side, the opposite of mono-repo is poly-repo. This means one repository per project. i.e. If you have five projects then you will have five repositories.
Benefits of using a mono-repository
- Visibility: Everyone can see the code and assets for every project since they are located in one place.
- Easier collaboration and code-sharing: A single repository makes it easier for a development team to collaborate, track features, and work together on a shared infrastructure. The code, files, and assets are accessible to all, thereby allowing cross-team contributions. The team can share and reuse code and assets easily while keeping them isolated from one another.
- Code refactors are easy/atomic commits: Using a single repository enables large-scale refactoring. It helps to fix bug issues fast. You can also make a single change across multiple projects in a single commit. Thus, it accelerates development.
- A single source of truth: It makes it easier to coordinate and manage dependencies.
Disadvantages of using a mono-repository
- Unable to restrict access- There is no way to restrict access to some parts of the app. This means that every member will have access to view the entire codebase, resulting in security issues later on.
- Git performance: Git uses a directed acyclic graph (DAG) to represent the history of a project. When working on large-scale projects, if there is a huge number of commits being tracked by GIT simultaneously over the same repo, there might be a decline in its performance as history deepens. The GIT’s performance slows down because of the number of refs and the files tracked.
- Higher build time: Since you have a lot of source code in one place, the build time is higher compared to building separate projects alone.