A module is a class decorated with @Module() that acts as the organizational unit of a NestJS app. It groups related controllers, providers, and imports. Every app has at least one root module (AppModule). NestJS uses the module graph to wire up the DI container at startup.
A module is a class annotated with the @Module() decorator. NestJS uses the information provided by this decorator to organize the application structure and build the dependency injection container.
Every NestJS app has at least one root module — AppModule.
Modules encapsulate a closely related set of capabilities.
The module graph is used by NestJS to resolve provider dependencies.
Modules are singletons by default — the same instance is shared across the app.
If you need to add a new service for sending emails, how would you structure a NestJS module for it, and what steps are required to make the service available to other parts of the app?
What happens if you forget to import a module that provides a controller you want to use in another module?
Where would you place shared utility functions and how would you expose them through a module?
We have a UsersModule and an AuthModule, but Auth needs the UsersService. How would you resolve this circular dependency using NestJS modules?
After moving some providers into a new module, a previously working endpoint started returning 500 errors. Walk me through how you would debug the issue and what module‑related pitfalls you’d check.
If you need to load a module only in a testing environment, what approaches does NestJS provide and what are the trade‑offs?
Our monolith is growing and we plan to split it into several bounded‑context modules that will be loaded lazily. How would you design the module hierarchy to minimize startup time and keep DI performant?
How would you share a cache service across multiple dynamically loaded modules without creating duplicate instances, and which module configuration patterns would you use?
When integrating a third‑party library that requires global configuration, how would you decide between a global module and a scoped module, considering testability and future scaling?
We are migrating a legacy Express codebase to NestJS. How would you reorganize the existing code into NestJS modules to ensure clean separation of concerns while allowing incremental migration?
Several teams need a common authentication module that must evolve independently. What architectural strategies would you employ to version and share this module without causing breaking changes for downstream services?
If the company mandates that all modules expose only explicit public providers and avoid accidental leaks, how would you enforce this at the framework or CI level?