CodeBlanks Logo Icon CodeBlanks

What is a monorepo?

Learn the single repository model of the monorepo approach.

What is a monorepo?

A monorepo is a development approach where multiple projects or applications are stored in a single Git repository. For example, a company's web application, mobile application, and shared libraries can exist in the same repository.

company/
├── frontend/
├── backend/
├── mobile/
└── shared/

This allows projects to manage shared files and changes through a single repository.

One repository, multiple projects

When using a monorepo, each project has its own directory, but all projects share the same Git history. A single commit can contain changes affecting multiple projects.

workspace/
├── api/
│   └── index.js
├── web/
│   └── app.js
└── packages/
    └── utils.js

This model makes sharing common code and reviewing cross-project changes easier. However, cloning and maintenance costs can increase in large repositories.

Practice Create monorepo directories

Create the frontend, backend, and shared directories for a monorepo. Then list the directories using the find command.

Starter code

terminal
# Proje dizinlerini oluştur
# Dizinleri listele

Sample solution

terminal
mkdir -p frontend backend shared
find . -maxdepth 1 -type d | sort

Expected output

.
./backend
./frontend
./shared

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 Which approach describes storing a company's web, mobile, and server projects in one Git repository?

  • Multirepo
  • Monorepo Correct answer
  • Submodule
  • Worktree

Explanation: In the monorepo approach, multiple projects can be stored in different directories of the same Git repository.

2 Complete the shared repository structure

Question
workspace/
├── frontend/
├── backend/
└── ____/
Answer
workspace/
├── frontend/
├── backend/
└── shared/

Explanation: A monorepo can contain different project directories such as frontend, backend, and shared.

3 Monorepo components

Term Meaning
Monorepo Stores multiple projects in one repo
Single repo One Git repository
Multi-project Multiple projects
Ortak kod Shared between projects

All lessons in Expert