Developer Journey: Monorepos vs Polyrepos

Understanding the Developer's Journey

Every software developer embarks on a journey filled with peaks of optimism and valleys of despair. This journey, often characterized by cycles of disillusionment and understanding, is a shared experience among developers. Much like a mechanic tasked with repairing spaceships, developers navigate through complex challenges, drawing parallels between tasks and the interconnected nature of software development.

This metaphorical journey highlights the importance of understanding the tools and methodologies that can help streamline the development process, making it more efficient and less painful. Understanding these tools is crucial, especially when it comes to organizing and managing code repositories.

The Complexity of Polyrepos

Polyrepos, where each team or project maintains its own repository, offer significant autonomy. Teams can independently manage their projects, make technological decisions, and operate within their domain expertise. This approach fosters innovation and allows for specialized focus.

However, the autonomy of polyrepos comes at a cost. The overhead of managing multiple repositories can lead to inefficiencies, especially when sharing code across projects. The complexity of setting up CI pipelines, publishing, and managing dependencies can result in code duplication and inconsistencies.

In a polyrepo setup, developers often face challenges such as version mismatches and the fear of introducing breaking changes. This isolation can hinder collaboration and slow down progress when teams need to coordinate changes across multiple repositories.

Introducing the Monorepo Solution

Monorepos offer a compelling alternative by consolidating multiple projects into a single repository with well-defined relationships. This approach simplifies code sharing and reduces duplication, as developers can make atomic changes that propagate across all dependent projects.

With monorepos, teams benefit from consistent tooling and a unified development experience. This consistency reduces the mental overhead for developers, making it easier to contribute across different projects. Monorepos also allow for standardized build, test, and deployment processes, enhancing efficiency and reliability.

The structured nature of monorepos enables better dependency management, ensuring that all projects use the same versions of libraries and tools. This reduces the risk of compatibility issues and allows teams to focus on delivering features rather than managing infrastructure complexities.

Optimizing Monorepo Performance

As the size of a monorepo grows, so does the time required to run builds and tests. To address this, advanced tooling can analyze dependencies and optimize the build process. By creating a project graph, tools like Nx can determine which parts of the codebase are affected by a change, allowing for targeted testing and builds.

This targeted approach reduces CI times by only running necessary tests and builds, regardless of the overall size of the monorepo. Additionally, a computation cache can further speed up builds by storing and reusing results, ensuring that work is not duplicated across the organization.

By distributing tasks across multiple agents, teams can parallelize the workload, further reducing build and test times. This distributed approach efficiently utilizes resources and prevents bottlenecks, allowing for faster feedback and iteration.

Leveraging Monorepos for Enhanced Collaboration

Monorepos facilitate collaboration by breaking down barriers between teams. With a single repository, developers can easily share code and contribute to projects across the organization. This fosters a culture of collaboration and knowledge sharing, as teams work towards common goals.

Despite concerns about tight coupling, monorepos provide mechanisms for maintaining autonomy. Teams can control who contributes to their code and when deployments occur, ensuring that collaboration does not come at the expense of individual team priorities.

Monorepos are not a one-size-fits-all solution. Organizations can adopt monorepos incrementally, grouping projects that make sense to manage together. This flexible approach allows teams to balance the benefits of monorepos with the need for autonomy and independence.

The Path Forward with Monorepos

Monorepos offer significant advantages in terms of velocity, safety, and developer mobility. By consolidating projects into a single repository, teams can streamline their workflows and reduce the overhead associated with managing multiple repositories.

The journey towards adopting monorepos requires careful consideration of organizational dynamics and team collaboration. While monorepos provide a robust framework for managing complex codebases, they are not a panacea for all development challenges.

Ultimately, the decision to adopt a monorepo should be driven by the specific needs and goals of the organization. By leveraging the right tools and practices, teams can harness the power of monorepos to enhance their development processes and achieve greater success in their software projects.

Watch full talk with demos and examples:

Watch video on a separate page
Rate this content
Bookmark

This talk has been presented at JSNation US 2024, check out the latest edition of this JavaScript Conference.

FAQ

Yes, monorepos can be adopted incrementally by grouping projects that make sense together, allowing for flexibility in organizing code.

Dan is a metaphorical character representing developers. He is described as a mechanic who fixes spaceships, symbolizing the tasks and challenges faced by developers.

The main topic of the talk is about monorepos, their benefits, and how they compare to polyrepos in software development.

Challenges include inefficient code sharing, high code duplication, complex dependency management, and isolation, which can harm collaboration.

A monorepo is a single repository containing multiple distinct projects with well-defined relationships, allowing for easier code sharing and collaboration.

Monorepos offer benefits such as atomic changes, reduced code duplication, consistent tooling, and improved velocity, safety, and mobility in development.

Monorepos allow changes to be made across multiple projects with a single PR, reducing overhead and encouraging code sharing by simplifying the process.

Yes, teams can still have autonomy over their code, tools, and deployment within a monorepo, but a basic level of collaboration and agreement on certain tools is needed.

NX provides tools for analyzing project dependencies, caching computations, and distributing tasks across agents to optimize CI processes and improve efficiency.

Polyrepos refer to a structure where each team or project has its own repository. Advantages include team autonomy, technological freedom, and a cleanly separated architecture.

Max Kless
Max Kless
28 min
21 Nov, 2024

Comments

Sign in or register to post your comment.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Scaling Up with Remix and Micro Frontends
Remix Conf Europe 2022Remix Conf Europe 2022
23 min
Scaling Up with Remix and Micro Frontends
Top Content
This talk discusses the usage of Microfrontends in Remix and introduces the Tiny Frontend library. Kazoo, a used car buying platform, follows a domain-driven design approach and encountered issues with granular slicing. Tiny Frontend aims to solve the slicing problem and promotes type safety and compatibility of shared dependencies. The speaker demonstrates how Tiny Frontend works with server-side rendering and how Remix can consume and update components without redeploying the app. The talk also explores the usage of micro frontends and the future support for Webpack Module Federation in Remix.
Routing in React 18 and Beyond
React Summit 2022React Summit 2022
20 min
Routing in React 18 and Beyond
Top Content
Routing in React 18 brings a native app-like user experience and allows applications to transition between different environments. React Router and Next.js have different approaches to routing, with React Router using component-based routing and Next.js using file system-based routing. React server components provide the primitives to address the disadvantages of multipage applications while maintaining the same user experience. Improving navigation and routing in React involves including loading UI, pre-rendering parts of the screen, and using server components for more performant experiences. Next.js and Remix are moving towards a converging solution by combining component-based routing with file system routing.
Design Systems: Walking the Line Between Flexibility and Consistency
React Advanced 2021React Advanced 2021
47 min
Design Systems: Walking the Line Between Flexibility and Consistency
Top Content
The Talk discusses the balance between flexibility and consistency in design systems. It explores the API design of the ActionList component and the customization options it offers. The use of component-based APIs and composability is emphasized for flexibility and customization. The Talk also touches on the ActionMenu component and the concept of building for people. The Q&A session covers topics such as component inclusion in design systems, API complexity, and the decision between creating a custom design system or using a component library.
Understanding React’s Fiber Architecture
React Advanced 2022React Advanced 2022
29 min
Understanding React’s Fiber Architecture
Top Content
This Talk explores React's internal jargon, specifically fiber, which is an internal unit of work for rendering and committing. Fibers facilitate efficient updates to elements and play a crucial role in the reconciliation process. The work loop, complete work, and commit phase are essential steps in the rendering process. Understanding React's internals can help with optimizing code and pull request reviews. React 18 introduces the work loop sync and async functions for concurrent features and prioritization. Fiber brings benefits like async rendering and the ability to discard work-in-progress trees, improving user experience.
Full Stack Components
Remix Conf Europe 2022Remix Conf Europe 2022
37 min
Full Stack Components
Top Content
RemixConf EU discussed full stack components and their benefits, such as marrying the backend and UI in the same file. The talk demonstrated the implementation of a combo box with search functionality using Remix and the Downshift library. It also highlighted the ease of creating resource routes in Remix and the importance of code organization and maintainability in full stack components. The speaker expressed gratitude towards the audience and discussed the future of Remix, including its acquisition by Shopify and the potential for collaboration with Hydrogen.
A Framework for Managing Technical Debt
TechLead Conference 2023TechLead Conference 2023
35 min
A Framework for Managing Technical Debt
Top Content
Today's Talk discusses the importance of managing technical debt through refactoring practices, prioritization, and planning. Successful refactoring requires establishing guidelines, maintaining an inventory, and implementing a process. Celebrating success and ensuring resilience are key to building a strong refactoring culture. Visibility, support, and transparent communication are crucial for addressing technical debt effectively. The team's responsibilities, operating style, and availability should be transparent to product managers.

Workshops on related topic

Master JavaScript Patterns
JSNation 2024JSNation 2024
145 min
Master JavaScript Patterns
Top Content
Featured Workshop
Adrian Hajdin
Adrian Hajdin
During this workshop, participants will review the essential JavaScript patterns that every developer should know. Through hands-on exercises, real-world examples, and interactive discussions, attendees will deepen their understanding of best practices for organizing code, solving common challenges, and designing scalable architectures. By the end of the workshop, participants will gain newfound confidence in their ability to write high-quality JavaScript code that stands the test of time.
Points Covered:
1. Introduction to JavaScript Patterns2. Foundational Patterns3. Object Creation Patterns4. Behavioral Patterns5. Architectural Patterns6. Hands-On Exercises and Case Studies
How It Will Help Developers:
- Gain a deep understanding of JavaScript patterns and their applications in real-world scenarios- Learn best practices for organizing code, solving common challenges, and designing scalable architectures- Enhance problem-solving skills and code readability- Improve collaboration and communication within development teams- Accelerate career growth and opportunities for advancement in the software industry
AI on Demand: Serverless AI
DevOps.js Conf 2024DevOps.js Conf 2024
163 min
AI on Demand: Serverless AI
Top Content
Featured WorkshopFree
Nathan Disidore
Nathan Disidore
In this workshop, we discuss the merits of serverless architecture and how it can be applied to the AI space. We'll explore options around building serverless RAG applications for a more lambda-esque approach to AI. Next, we'll get hands on and build a sample CRUD app that allows you to store information and query it using an LLM with Workers AI, Vectorize, D1, and Cloudflare Workers.
Build Modern Applications Using GraphQL and Javascript
Node Congress 2024Node Congress 2024
152 min
Build Modern Applications Using GraphQL and Javascript
Featured Workshop
Emanuel Scirlet
Miguel Henriques
2 authors
Come and learn how you can supercharge your modern and secure applications using GraphQL and Javascript. In this workshop we will build a GraphQL API and we will demonstrate the benefits of the query language for APIs and what use cases that are fit for it. Basic Javascript knowledge required.
Building a Shopify App with React & Node
React Summit Remote Edition 2021React Summit Remote Edition 2021
87 min
Building a Shopify App with React & Node
Top Content
WorkshopFree
Jennifer Gray
Hanna Chen
2 authors
Shopify merchants have a diverse set of needs, and developers have a unique opportunity to meet those needs building apps. Building an app can be tough work but Shopify has created a set of tools and resources to help you build out a seamless app experience as quickly as possible. Get hands on experience building an embedded Shopify app using the Shopify App CLI, Polaris and Shopify App Bridge.We’ll show you how to create an app that accesses information from a development store and can run in your local environment.
Build a chat room with Appwrite and React
JSNation 2022JSNation 2022
41 min
Build a chat room with Appwrite and React
WorkshopFree
Wess Cope
Wess Cope
API's/Backends are difficult and we need websockets. You will be using VS Code as your editor, Parcel.js, Chakra-ui, React, React Icons, and Appwrite. By the end of this workshop, you will have the knowledge to build a real-time app using Appwrite and zero API development. Follow along and you'll have an awesome chat app to show off!
Hard GraphQL Problems at Shopify
GraphQL Galaxy 2021GraphQL Galaxy 2021
164 min
Hard GraphQL Problems at Shopify
WorkshopFree
Rebecca Friedman
Jonathan Baker
Alex Ackerman
Théo Ben Hassen
 Greg MacWilliam
5 authors
At Shopify scale, we solve some pretty hard problems. In this workshop, five different speakers will outline some of the challenges we’ve faced, and how we’ve overcome them.

Table of contents:
1 - The infamous "N+1" problem: Jonathan Baker - Let's talk about what it is, why it is a problem, and how Shopify handles it at scale across several GraphQL APIs.
2 - Contextualizing GraphQL APIs: Alex Ackerman - How and why we decided to use directives. I’ll share what directives are, which directives are available out of the box, and how to create custom directives.
3 - Faster GraphQL queries for mobile clients: Theo Ben Hassen - As your mobile app grows, so will your GraphQL queries. In this talk, I will go over diverse strategies to make your queries faster and more effective.
4 - Building tomorrow’s product today: Greg MacWilliam - How Shopify adopts future features in today’s code.
5 - Managing large APIs effectively: Rebecca Friedman - We have thousands of developers at Shopify. Let’s take a look at how we’re ensuring the quality and consistency of our GraphQL APIs with so many contributors.