How nrwl/nx-examples works
Project Type and Purpose
• This is an Nx‐managed monorepo containing multiple frontend applications (a React “cart” app and an Angular “products” app), end-to-end test suites for each, and a rich set of shared libraries for features (cart page, home page, product detail page), state management, UI components, assets, styling, and tooling.
• It’s designed to enable rapid development of multiple user-facing SPAs with shared code, unified testing, and centralized build/configuration via Nx.
File Structure Analysis
• Top-level “apps” folder
• apps/cart – React SPA
• apps/products – Angular SPA
• apps/cart-e2e & apps/products-e2e – Cypress E2E suites
• Top-level “libs” folder grouping:
• Feature libs: libs/cart/cart-page, libs/products/home-page, libs/products/product-detail-page
• Shared feature code: libs/shared/cart/state, libs/shared/product/data, state, types, ui
• Shared UI/helpers: libs/shared/header, libs/shared/styles, libs/shared/jsxify, libs/shared/assets, libs/shared/e2e-utils
• CI/CD scripts under .circleci and tools/scripts/deploy.ts
• Centralized TypeScript, ESLint, Prettier, Babel, and Jest configs
Key Insights from README
• Uses Nx to orchestrate builds, tests, and dependency graph generation
• Applications are generated via @nx/react and @nx/angular plugins
• Supports incremental and cached builds/tests (Nx Cloud)
• Encourages sharing code via libraries
a. Main Components
• React Cart App
• Angular Products App
• E2E Test Runner (Cypress)
• Shared Libraries (grouped by domain and concern)
• CI/CD Pipeline (CircleCI + Nx Cloud)
• Tooling Scripts (deploy.ts)
b. Interactions & Dependencies
• Apps import feature libs (cart-page, home-page, product-detail-page) and shared libs (state, UI, types, assets, styles)
• Shared state libs expose Redux/NgRx modules consumed by apps
• Shared UI libs (header, product-price) used across both apps
• E2E projects run tests against the dev or deployed endpoints of the SPAs
• CI/CD pipeline triggers “nx build”, “nx test”, “nx e2e” and uses tooling scripts to deploy artifacts
c. Architectural Patterns & Principles
• Monorepo modularity: clear separation of apps vs. libraries
• Feature-driven libraries: each page/component is its own lib for reuse
• Shared cross-cutting concerns: state management, UI primitives, styling
• Nx dependency graph enforces acyclic dependencies
• CI/CD with computation caching for fast incremental builds
d. Technologies & Frameworks
• React + TypeScript + Webpack for cart
• Angular + TypeScript for products
• Jest for unit tests
• Cypress for end-to-end tests
• Nx dev tools, Babel, ESLint, Prettier