Skip to content

Repository files navigation

angular-nx-demo

🚀 Quick Start

# Clone the repository
git clone <your-fork-url>
cd <your-repository-name>

# Install dependencies
# (Note: You may need --legacy-peer-deps)
npm install

# Serve the Angular demo application (this will simultaneously serve the API backend)
npx nx serve demo

# ...or you can serve the API separately
npx nx serve api

# Build all projects
npx nx run-many -t build

# Run tests
npx nx run-many -t test

# Lint all projects
npx nx run-many -t lint

# Run e2e tests
npx nx e2e demo-e2e

# Run tasks in parallel

npx nx run-many -t lint test build e2e --parallel=3

# Visualize the project graph
npx nx graph

⭐ Featured Nx Capabilities

This repository showcases several powerful Nx features:

1. 🔒 Module Boundaries

Enforces architectural constraints using tags. Each project has specific dependencies it can use:

  • scope:shared - Can be used by all projects
  • scope:demo - demo-specific libraries
  • scope:api - API-specific libraries
  • type:feature - Feature libraries
  • type:data - Data access libraries
  • type:ui - UI component libraries

Try it out:

# See the current project graph and boundaries
npx nx graph

# View a specific project's details
npx nx show project demo --web

Learn more about module boundaries →

2. 🎭 Playwright E2E Testing

End-to-end testing with Playwright is pre-configured:

# Run e2e tests
npx nx e2e demo-e2e

# Run e2e tests in CI mode
npx nx e2e-ci demo-e2e

Learn more about E2E testing →

4. ⚡ Vitest for Unit Testing

Fast unit testing with Vite for Angular libraries:

# Test a specific library
npx nx test data

# Test all projects
npx nx run-many -t test

Learn more about Vite testing →

5. 🔧 Self-Healing CI

The CI pipeline includes nx fix-ci which automatically identifies and suggests fixes for common issues:

# In CI, this command provides automated fixes
npx nx fix-ci

This feature helps maintain a healthy CI pipeline by automatically detecting and suggesting solutions for:

  • Missing dependencies
  • Incorrect task configurations
  • Cache invalidation issues
  • Common build failures

Learn more about self-healing CI →

📁 Project Structure

├── apps/
│   ├── demo/           [scope:demo]    - Angular e-commerce app
│   ├── demo-e2e/                       - E2E tests for demo
│   └── api/            [scope:api]     - Backend API
├── libs/
│   ├── demo/
│   │   ├── feature-products/        [scope:demo,type:feature] - Product listing
│   │   ├── feature-product-detail/  [scope:demo,type:feature] - Product details
│   │   ├── data/                    [scope:demo,type:data]    - Data access
│   │   └── shared-ui/               [scope:demo,type:ui]      - UI components
│   ├── api/
│   │   └── products/    [scope:api]    - Product service
│   └── shared/
│       └── models/      [scope:shared,type:data] - Shared models
├── nx.json             - Nx configuration
├── tsconfig.json       - TypeScript configuration
└── eslint.config.mjs   - ESLint with module boundary rules

🏷️ Understanding Tags

This repository uses tags to enforce module boundaries:

Project Tags Can Import From
demo scope:demo scope:demo, scope:shared
api scope:api scope:api, scope:shared
feature-products scope:demo, type:feature scope:demo, scope:shared
data scope:demo, type:data scope:shared
models scope:shared, type:data Nothing (base library)

📚 Useful Commands

# Project exploration
npx nx graph                                    # Interactive dependency graph
npx nx list                                     # List installed plugins
npx nx show project demo --web                 # View project details

# Development
npx nx serve demo                              # Serve Angular app
npx nx serve api                               # Serve backend API
npx nx build demo                              # Build Angular app
npx nx test data                               # Test a specific library
npx nx lint feature-products                   # Lint a specific library

# Running multiple tasks
npx nx run-many -t build                       # Build all projects
npx nx run-many -t test --parallel=3          # Test in parallel
npx nx run-many -t lint test build            # Run multiple targets

# Affected commands (great for CI)
npx nx affected -t build                       # Build only affected projects
npx nx affected -t test                        # Test only affected projects

🎯 Adding New Features

Generate a new Angular application:

npx nx g @nx/angular:app my-app

Generate a new Angular library:

npx nx g @nx/angular:lib my-lib

Generate a new Angular component:

npx nx g @nx/angular:component my-component --project=my-lib

Generate a new API library:

npx nx g @nx/node:lib my-api-lib

You can use npx nx list to see all available plugins and npx nx list <plugin-name> to see all generators for a specific plugin.

Nx Cloud

Nx Cloud ensures a fast and scalable CI pipeline. It includes features such as:

Install Nx Console

Nx Console is an editor extension that enriches your developer experience. It lets you run tasks, generate code, and improves code autocompletion in your IDE. It is available for VSCode and IntelliJ.

Install Nx Console »

🔗 Learn More

💬 Community

Join the Nx community:

About

Angular Nx Demo

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages