Dwarves
Memo
Type ESC to close search bar

From Multi Repo To Monorepo A Case Study With Nghenhan Turbo Monorepo

In this case study, we share our experience of transitioning from multi-repository structure to a monorepo using Turbo in our project. This migration led to numerous benefits, including a 60% reduction in build times, a 40% increase in developer productivity, and simplified dependency management. Our goal is to offer valuable insights and lessons learned throughout our journey to help others considering a similar transition.

Introduction

Over the past two years, we have developed NgheNhan - a trading platform that not only enables users to manage their accounts efficiently but also allows them to analyze market data and trading performance in realtime.

As the project expanded, our team faced challenges in managing dependencies and deploying updates across multiple repositories. Coordinating changes between components and maintaining consistency across codebases became increasingly difficult as our engineering team grew. This prompted our decision to migrate to a monorepo structure using Turbo.

Challenges

Throughout the migration process, we encountered several challenges such as updating reusable components, including integrating different codebases into the new monorepo structure, refactoring code and dependency packages to ensure compatibility, caching previous builds to speed up build times with minimizing the Javascript bundle size, and updating development processes to reflect the new workflow.

These challenges necessitated updating references to files and components to match the new structure and ensuring the correct integration of all code into the new repository.

As we move forward, we may face challenges related to scalability and flexibility. However, we firmly believe that the benefits of the monorepo approach far outweigh these challenges, and we are confident in our ability to address them proactively.

Solution: Turbo and the Monorepo Advantage

Turbo, a purpose-built tool for managing monorepos, offers numerous benefits that streamline the development process. Some of these advantages include:

Migration Process

Here is the diagram for the full flow of the migration process of our apps:

Our migration process entailed several well-planned steps to ensure a seamless transition to a monorepo using Turbo:

  1. Setting up Turbo: We started by configuring Turbo to manage our dependencies, scripts, and builds within the monorepo.
  2. Consolidating code: We migrated all of our code from multiple repositories into a single Turbo repository, updating dependencies and organizing reusable code in a scalable manner. This also involved configuring CI/CD builds on Vercel for our apps.
  3. Refactoring: We thoroughly analyzed our existing codebase, identifying areas where components were tightly coupled or resources were excessively shared. We refactored these components to improve the reliability and scalability of our codebase, positively impacting bundle size and performance.
  4. Preview app with Storybook: We created a preview app using Storybook to better understand the input/output of each component and ensure that everything was working as expected. This made it easier for our developers to integrate components into our apps in the future.
  5. Extensive testing and deployment: After completing the migration and refactoring efforts, we thoroughly tested and deployed our codebase to ensure that everything was working as expected. We resolved any issues that arose during the testing process and made certain that our apps ran smoothly in the live environment.

Results and Key Learnings

The migration to a monorepo with Turbo was a success, with several noteworthy benefits:

Throughout the migration process, we learned several valuable lessons:

  1. Thorough planning and preparation are crucial for a successful migration.
  2. Clear communication and collaboration among team members ensure a smoother transition.
  3. Monitoring and addressing potential scalability and maintainability issues are essential for long-term success.

The transition to a monorepo with Turbo has been a game-changer for our team. We can now collaborate more effectively, build faster, and manage dependencies with ease, enabling us to focus on delivering high-quality software. — An Tran, Lead Developer at NgheNhan

Conclusion

The migration to a monorepo using Turbo required significant effort, but the results have been overwhelmingly positive. Our team experienced improved collaboration, faster build times, simplified dependency management, and better code quality. We remain committed to continuously refining our code management practices and leveraging tools like Turbo to stay at the forefront of software development.

Follow us on