Home Insights Scalable monorepo solution with Nx

Scalable monorepo solution with Nx

Scalable monorepo solution with Nx

Over the last few years, the demand for complex scalable architecture with independently deployable modules and loosely-coupled units has increased. Recently, one of our clients, who has an online chemical platform, requested a solution to develop a complex extendable architecture that allows cross applications communication over the process boundaries, including the capability to manage consistent releases and versioning of the project.

The challenge

The customer has more than 15,000 registered suppliers and ~94k visitors per month, so the main business objective was to run all changes partially to be able to conduct A/B testing and support all up-and-running functionality.

As there were separate UI applications written in Angular already, our technical task was to migrate existing applications and add brand-new functionality written in React.js. Along with that, other requirements were to:

  • increase visibility and discoverability on changes to avoid hardness of tracking them within another repos;
  • provide a way for different teams to own different parts of the application and choose a set of technologies that suit the purpose of the application and the expertise of the team;
  • standardize code and tooling across the teams.

Reasons we chose Nx as monorepo build system

To cover all requested business and technical requirements, Grid Dynamics engineers decided to go with a micro frontend monorepo architecture solution. There are several points that led us to this decision:.

  • large project size;
  • combination of new applications and existing ones;
  • easier tracking of development flow;
  • quick global changes introduction;
  • shared libs/components;
  • multi technology stacks support;
  • partial unit deployment.

After comparing the monorepo build systems, we decided to choose Nx as a powerful application integration solution. We did a deep analysis of the Lerna and Nx tools to define which would be the most applicable for our scenario.

Nx vs Lerna

CriteriaNxLerna
affected projects rebuilding+
packages publishingmay create only publishable libraries, not apps+
code sharing++
ownership management+
powerful code generators+
workspace visualizations+
multi-technologies support (BE + FE)+
linking multiple packages+
packages/app dependencies visualization+

The decision to set up monorepo with Nx was based on the following Nx pros:

  1. Nx allows the setup of advanced deployment strategies to deploy the new version side by side with the previous version, ensuring the new version works as expected. If a bug is detected, you can quickly redirect traffic to the previous version.
  2. Nx is able to use the dependency graph to determine which projects are affected by a change to the code. This helps to avoid bugs in affected apps/libs.
  3. Nx allows for consistent code generation. Generators allow you to customize and standardize organizational conventions and structure, removing the need to perform the same manual setup tasks repetitively.
  4. Nx has an accurate architecture diagram, where most architecture diagrams become obsolete in an instant, and every diagram becomes out of date as soon as the code changes. Because Nx understands your code, it generates an up-to-date and accurate diagram of how projects depend on each other.
  5. Nx enables controlled code sharing. While sharing code becomes much easier to share, there should also be constraints of when and how code should be depended on. Even though everyone has access to the repo does not mean that anyone should change any project. Projects should have owners such that changes to that project requires their approval- this can be defined using a CODEOWNERS file.

The solution

One of the most important criteria in the process of moving to monorepo is to define a step-by-step scenario of creating a new application and migrating existing ones. Below is a high-level diagram of the monorepo implementation flow that may be a start point for each specific project.

monorepo development & architecture diagram

The results

As a result of the monorepo setup, we achieved a fully maintainable, solid architectural approach with a set of modern auxiliary web development tools and an automation pipeline that helped us to work faster on tedious tasks, and visualize and analyze changes in a more thorough way. In the scope of this project, all business and technical requirements were resolved and met expected results. In conclusion, Nx proved to be a reliable solution for huge Angular/React apps.

Tags

You might also like

Vibrant translucent cubes and silhouettes of people in a digital cityscape, visually representing the dynamic and layered nature of AI software development, where diverse technologies, data, and human collaboration intersect to build innovative, interconnected digital solutions
Article
Your centralized command center for managing AI-native development
Article Your centralized command center for managing AI-native development

Fortune 1000 enterprises are at a critical inflection point. Competitors adopting AI software development are accelerating time-to-market, reducing costs, and delivering innovation at unprecedented speed. The question isn’t if you should adopt AI-powered development, it’s how quickly and effectivel...

Colorful, translucent spiral staircase representing the iterative and evolving steps of the AI software development lifecycle
Article
Agentic AI now builds autonomously. Is your SDLC ready to adapt?
Article Agentic AI now builds autonomously. Is your SDLC ready to adapt?

According to Gartner, by 2028, 33% of enterprise software applications will include agentic AI. But agentic AI won’t just be embedded in software; it will also help build it. AI agents are rapidly evolving from passive copilots to autonomous builders, prompting organizations to rethink how they dev...

Code on the left side with vibrant pink, purple, and blue fluid colors exploding across a computer screen, representing the dynamic nature of modern web development.
Article
Tailwind CSS: The developers power tool
Article Tailwind CSS: The developers power tool

When it comes to the best web development frameworks, finding the right balance between efficiency, creativity, and maintainability is key to building modern, responsive designs. Developers constantly seek tools and approaches that simplify workflows while empowering them to create visually strikin...

Cube emitting colorful data points, with blue, red, and gold light particles streaming upward against a black background, representing data transformation and AI capabilities.
Article
Data as a product: The missing link in your AI-readiness strategy
Article Data as a product: The missing link in your AI-readiness strategy

Most enterprise leaders dip their toe into AI, only to realize their data isn’t ready—whether that means insufficient data, legacy data formats, lack of data accessibility, or poorly performing data infrastructure. In fact, Gartner predicts that through 2026, organizations will abandon 60% of AI pr...

Multicolor whisps of smoke on a black background
Article
Headless CMS for the AI era with Grid Dynamics, Contentstack, and Google Cloud
Article Headless CMS for the AI era with Grid Dynamics, Contentstack, and Google Cloud

For many businesses, moving away from familiar but inherently unadaptable legacy suites is challenging. However, eliminating this technical debt one step at a time can bolster your confidence. The best starting point is transitioning from a monolithic CMS to a headless CMS. This shift to a modern c...

Orange blocks against a grey background to represent microservices in the cloud
Article
Cloud modernization playbook: From monolith to microservices
Article Cloud modernization playbook: From monolith to microservices

Many organizations have already embraced practices like Agile and DevOps to enhance collaboration and responsiveness in meeting customer needs. While these advancements mark significant milestones, the journey doesn't end here. Microservices offer another powerful way to accelerate business capabil...

5 emerging Kubernetes use cases beyond container scheduling
Article
Kubernetes use cases beyond container scheduling
Article Kubernetes use cases beyond container scheduling

From AI/ML workloads and multi-tenancy to test labs and edge computing, uncover 5 practical examples of Kubernetes-based platform engineering.

Get in touch

Let's connect! How can we reach you?

    Invalid phone format
    Submitting
    Scalable monorepo solution with Nx

    Thank you!

    It is very important to be in touch with you.
    We will get back to you soon. Have a great day!

    check

    Something went wrong...

    There are possible difficulties with connection or other issues.
    Please try again after some time.

    Retry