This is an alpha, sneak peek of Monorepo Maestros. For this iteration, I'm getting all of my thoughts down. In the future, we'll have better information architecture, graphics, and other awesomeness. Your feedback is welcome!

Thinking in graphs

Thinking about your applications in the context of a monorepo is slightly different than working with a single application repository. When you have multiple workspaces in your repo, you'll want to thinking of your workspaces as associated with each other as a graph of dependencies and tasks.

This is important to stand depending on your role within the monorepo:

Notably, you may only be one of these roles within your monorepo but it is still important to understand the concept of a directed acyclic graph (DAG) as you learn about how to use a monorepo. (We will be calling this simply "a graph" for short as we talk about this idea. No need to get hung up on the fancy words!)

Visualizing a monorepo graph

Creating a mental picture of what a monorepo graph looks like is often a great way to get started with learning (and explaining!) how a monorepo connects workspaces and tasks together. As an example, let's take a look at the repository that holds this application, some starter workspaces, and "Turbo Studio."

First, clone the repository and install its dependencies:

Terminal
git clone https://github.com/anthonyshew/maestros
pnpm i
Terminal
git clone https://github.com/anthonyshew/maestros
pnpm i

Note: You will need pnpm installed on your machine to run this repository.

Next, run the command to build and start "Turbo Studio":

Terminal
turbo start:studio
Terminal
turbo start:studio

Note: We are using global Turbo here. You can install it with 'npm i -g turbo@latest' or add a script in the root of the repository with this command.

You should see a message that a Next.js app is now running at localhost:3000. When you visit, you'll get a graph that looks similar to this one. Monorepo Graph

This graph shows the steps that it takes to build Maestros:

  1. You or your CI run the turbo build pipeline.
  2. turbo finds the maestros app has a build task.
  3. turbo sees that the build task for the maestros workspace depends on the generate task in the @repo/db workspace. This dependency can be found in the root's turbo.json.

This is a simple pipeline with few steps. In the left sidebar, you can change the task to turbo run lint or turbo run typecheck see graphs with slightly more complexity. You can also edit turbo.json or workspace dependencies to see what changes you can bring to your task graph.

Using this visualization in your own repository

You can copy the "Turbo Studio" workspace into your project using Turborepo Generators.

Terminal
turbo generate workspace -c https://github.com/anthonyshew/maestros/tree/main/apps/studio
# > Follow the prompts. You don't need to install any workspace dependencies.
pnpm install # or your package manager
turbo start:studio
Terminal
turbo generate workspace -c https://github.com/anthonyshew/maestros/tree/main/apps/studio
# > Follow the prompts. You don't need to install any workspace dependencies.
pnpm install # or your package manager
turbo start:studio

Visit your browser and start inspecting your repository's graphs!

As a repo maintainer

If you're one of the folks entrusted with keeping the monorepo running smoothly, you'll want to keep your graph in mind as you work with the monorepo for a few reasons.

As an application developer

It's important to understand the characteristics of your graph as an application developer, as well.