Nx + Angular + NestJS Mono-Repository Starter: A Comprehensive Guide

Nov 15, 2023 | Programming

In the rapidly evolving world of software development, creating efficient workflows is crucial. The Nx, combined with Angular, and NestJS, creates a powerful mono-repository starter that can significantly enhance your development experience. This guide walks you through setting it up, understanding its workflows, troubleshooting common issues, and ensuring you have everything you need to start coding like a pro!

Workflows Overview

The power of this starter lies in its automated workflows, which enhance development efficiency. Below are key workflows and their triggers:

  • Source code security scanning: Manual or scheduled (weekly)
  • Containerization: Manual
  • Publish npm packages: PR merge event (destination: trunk)
  • User acceptance testing: Manual
  • Full testing, deliverables build, and deployment: PR merge event (destination: trunk)
  • Code ownership validation: Scheduled (weekly)
  • Quality gates (pull request validation): PR open event (destination: trunk)

Setting Up Your Environment

To get started with the project, ensure your system meets the following requirements:

Supported Operating Systems

  • Debian Based Linux: Recommended. Check out this setup guide for assistance on development environment setup.
  • OSX: Should work alongside Linux. Requirements to set up the dev environment will have to be explored independently. Use yarn install:all:osx to install dependencies.
  • Windows: Compatibility is not guaranteed. Refer to available installation options for protolint, and use PowerShell for installations. Recommended shell: Git BASH.

Core Dependencies

  • Bash 5
  • Node.js
  • Yarn
  • Git

Preferred Package Manager

  • Yarn for dependencies installation in the project root.
  • npm for dependencies installation in the functions folder.

How to Use the Command Line Tools

The project includes various package scripts contained within the package.json. To view these, you can use:

npx nx run tools:help

Committing Changes to the Repo

Using commitizen cli is mandatory. Ensure all dependencies are installed; then run:

git cz

Generating Applications and Libraries

Here’s where the magic happens! Using the power of Nx, you can easily generate applications and libraries in the same workspace. Think of Nx as a factory:

Analogy: Imagine you are in a bakery where every different type of bread (application/library) can be baked using the same flour (workspace). Instead of keeping a separate store for each kind, you have a single facility that produces all types efficiently!

To Generate an Application:

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

To Generate a Library:

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

Running a Development Server

To start the local development server, just run:

npx nx serve my-app

Navigate to localhost:4200 to see your app running!

Troubleshooting Common Issues

Should you encounter any hiccups along the way, here are a few troubleshooting tips:

  • Ensure all dependencies are correctly installed as per the environment instructions.
  • If you have problems with package installations, clean your npm cache with npm cache clean --force.
  • If the app does not compile, check for typos in the commands provided above.

For deeper insights, or to collaborate on AI development projects, stay connected with fxis.ai.

Conclusion

At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox