Skip to content
Ajit Blogs A working notebook India
AJITBLOGS

Field notes on software, cloud, and the work of shipping.

Angular / structure

When one Angular app becomes a workspace

Moving a growing Angular project into Nx is less about a generator and more about drawing useful boundaries.

A small Angular application is easy to hold in your head. Every feature lives in the same source tree, imports are short, and the build has one obvious purpose. That convenience starts to fade when the app gains a community feed, an article reader, a profile area, and several kinds of shared state. The code still compiles, but the shape of the project no longer explains the product.

That was the point where Nx became interesting. The migration generator is helpful, yet the generator is not the real work. The real work is deciding which pieces deserve to be independent and which pieces should stay close together. A monorepo without boundaries is just a larger folder.

Start with shared foundations

The first candidates for a library are usually environment settings, shared models, common components, and services used across feature areas. Moving them out of the application removes duplicate imports and makes the dependency direction visible. Each library should have a clear public entry point. If another project has to reach deep into a folder to find a service, the boundary is not finished.

Path mappings in the workspace configuration make those imports readable. They also make circular dependencies easier to spot. A feature can depend on a data access library, and a UI library can depend on a model library, but the arrows should not point in both directions. When they do, the application starts to behave like a knot again.

Do not split everything at once

It is tempting to turn every folder into a project. That creates a diagram that looks organized and a build that is harder to understand. A better rule is to split when a boundary has a reason to exist: a feature has its own state, a group of components is reused in more than one place, or a service has a test suite that benefits from isolation. Otherwise, keep the code together until the need is real.

Small components can also become single file components during the move. A template, styles, and a tiny class in one place are often easier to read when the component has no meaningful internal structure. The choice is not about following a trend. It is about reducing the distance between related pieces of code.

The migration is a design review

Once the workspace is in place, the next pass should be tests and integration checks. The important question is not whether the generator completed. The important question is whether the new boundaries make future work easier to describe. If they do, the migration has done its job. If they do not, the folder structure is only decoration.

Notebook note: a workspace is useful when it makes dependency direction obvious. If every project can import every other project, the extra structure is mostly ceremony.

Reference shelf

Selected external references for going deeper.

Type a title, subject, or phrase. Results appear as you type.

Press Escape to close25 entries indexed