16 Jun 2025 / 5 min. read

Case Study: Implementing Nx for Shared Angular and NestJS Packages Across Multiple Projects

Case study photo 2

Introduction

Managing multiple Angular and NestJS projects that share common libraries can be challenging. Code duplication, dependency tracking, and deployment complexities can slow down development. Nx, a powerful monorepo tool, helps streamline package management, build optimization, and deployment efficiency.

In this case study, we explore how our team successfully implemented Nx for enterprise-scale Angular and NestJS projects, optimizing workflows and improving productivity. These libraries include:

  • Styling Library: Common UI components and themes.
  • External Services Connector: Standardized communication with third-party APIs.
  • Datatables Library: Shared table components and utilities using PrimeNG.
  • Authentication & Authorization (Keycloak): Unified security for frontend and backend.
  • Kafka Audit & Logging: Centralized event-driven logging for NestJS.
  • Workflow Libraries: Generic plug-and-play frontend and backend workflow modules.
  • Deployment Pipeline: Automated tracking, building, and deployment of affected packages.

By adopting Nx, we streamlined development, testing, and CI/CD pipelines while ensuring scalability.

Why We Chose Nx for Monorepo Management

Nx provides a structured monorepo approach that optimizes builds, enforces best practices, and enables efficient dependency management. The key benefits we observed include:

  • Code Reusability: Single source of truth for shared libraries across multiple applications.
  • Optimized Build Performance: Affected packages rebuild only when necessary, reducing CI/CD times.
  • Scalability & Collaboration: Supports multiple teams working in parallel with ease.
  • Consistency & Best Practices: Standardized development patterns across projects.

Nx’s dependency graph, workspace organization, and tooling ensure that all projects stay in sync without unnecessary overhead.

Implementing Shared Libraries

Styling Library

We created a reusable styling library containing:

  • SCSS themes.
  • UI component wrappers (e.g., buttons, modals, form controls).
  • Global typography and layout settings.

This ensured UI consistency and reduced redundancy across all Angular applications.

External Services Connector

This library standardizes external API integrations using a common interface and error-handling mechanism. This provided:

  • Reusable API service classes.
  • Centralized error handling.
  • Consistent data transformation across projects.
Shared packages photo 3

Datatables Shared Library

A wrapper around PrimeNG DataTables with:

  • Reusable filtering, sorting, and pagination.
  • Customizable column definitions.
  • Backend integration support.

This allowed teams to implement complex data tables with minimal configuration, enhancing productivity.

Authentication & Authorization with Keycloak

For security, we implemented authentication and authorization libraries for both frontend and backend:

  • Frontend (auth-fe): Keycloak Angular integration with JWT handling.
  • Backend (auth-be): Keycloak NestJS integration with role-based access control.

These libraries enabled seamless authentication and authorization across all applications, ensuring compliance with security standards.

Kafka Audit & Logging (NestJS)A reusable NestJS module for logging audit events using Kafka. It provided:

  • Centralized logging.
  • Structured logging format for easy analysis.
  • Configurable event topics.

This ensured that all services followed a unified logging and auditing process, improving traceability.

Workflow Libraries (Frontend & Backend)

To facilitate workflow automation, we developed plug-and-play workflow libraries with:

  • Entities & Controllers: Predefined abstract models for workflow management.
  • Condition-based Actions: Automatic triggers based on predefined conditions.
  • Approval Processes: Multi-step approval system with dynamic rules.
  • State Management: Easily configurable workflow state transitions.

These libraries significantly reduced development time for workflow-based applications and streamlined business processes.

Optimizing Deployment with Affected Packages

Managing multiple libraries across applications required an efficient CI/CD pipeline. Our deployment strategy included:

  1. Tracking Dependencies: Nx automatically detects affected libraries and applications.
  2. Building Only Affected Packages: Instead of rebuilding everything, only changed parts are built.
  3. Deploying Incrementally: Using Nx CLI and Jenkins pipelines, we ensured faster deployments with minimal downtime.

By leveraging Nx’s dependency tracking, we optimized build times and improved deployment efficiency, allowing teams to ship features faster.

Results and Key Takeaways

Adopting Nx for managing shared Angular and NestJS libraries brought significant improvements:

  • Increased Development Efficiency: Shared code reduced redundancy and improved collaboration.
  • Optimized Build Performance: Dependency tracking enabled faster, incremental builds.
  • Seamless Deployment Automation: CI/CD automation reduced deployment risks and downtime.

Nx has proven to be a game-changer for our organization, enabling better monorepo management and development scalability. If you manage multiple projects with shared Angular and NestJS libraries, adopting Nx can help you achieve faster development cycles and improved maintainability.

By embracing Nx monorepo architecture, we unlocked scalability, efficiency, and seamless collaboration, setting a solid foundation for future growth.

Your Questions Answered

Question: What is Nx and why is it used in Angular and NestJS projects?
Answer: Nx is a powerful monorepo tool used to manage multiple Angular and NestJS projects in a single workspace. It streamlines package management, optimizes builds, and improves development scalability by enabling shared libraries, dependency tracking, and CI/CD automation.

Question: What benefits did the team experience by adopting Nx?
Answer: The team saw improved development efficiency, reduced CI/CD build times through affected-package tracking, enhanced code reusability, and standardized best practices across applications. Nx also supported seamless collaboration among teams and scalable architecture.

Question: What types of shared libraries were implemented using Nx?
Answer: The team created shared libraries for styling, external API integration, data tables, authentication & authorization (via Keycloak), Kafka-based audit logging, and frontend/backend workflow management. These libraries reduced code duplication and ensured consistency.

Question: How did Nx improve build performance and deployment?
Answer: Nx tracks changes and only rebuilds affected libraries and applications, significantly reducing build times. Integration with Jenkins allowed for incremental deployments, minimizing downtime and increasing release frequency.

Question: How was authentication and authorization handled across frontend and backend?
Answer: The team used Keycloak with custom frontend (auth-fe) and backend (auth-be) libraries to manage authentication and role-based access. This ensured secure and unified identity management across all projects.

Question: What is the purpose of the Kafka Audit & Logging library?
Answer: It centralizes logging for NestJS services using Kafka. The library supports structured formats, configurable topics, and consistent event tracking across applications, enhancing observability and traceability.

Question: How did workflow libraries help in automating business processes?
Answer: The frontend and backend workflow libraries included abstract entities, condition-based triggers, approval mechanisms, and state management. These tools accelerated the development of workflow-driven applications.

Question: Who should consider using Nx for their projects?
Answer: Nx is ideal for teams managing multiple Angular and/or NestJS applications that share code. It's particularly beneficial for enterprises seeking scalable, efficient, and collaborative development workflows.

 

Share on:

You may also like:

null
7 Jul 20258 min. read

A comprehensive analysis of ServiceNow Integrated Risk Management (IRM)

ServiceNow IRM transforms risk into opportunity with automation, real-time insights, and global success stories in compliance and resilience
How to get snow dev instance
20 Jun 20258 min. read

ServiceNow developer instance and how to get one

Explore ServiceNow hands-on with a free developer instance perfect for learning, testing, and building apps safely.