Nest.js Fundamentals — DI and Module System
Nest.js provides a DI container and Module system at the framework level in the Node.js ecosystem. A summary of its core design principles: IoC, DI, Module, and Provider.
Nest.js provides a DI container and Module system at the framework level in the Node.js ecosystem. A summary of its core design principles: IoC, DI, Module, and Provider.
Facade provides a simple entry point to a complex subsystem, cutting the coupling between the client and the internals. A service layer or a library SDK is effectively a Facade. It differs from Adapter (interface conversion) and Mediator (two-way coordination).
Layered architecture separates code into horizontal layers by technical responsibility. A summary of the four-layer structure, dependency direction rules, and how DIP decouples layers.
Core Kafka concepts (topics, partitions, consumer groups, replication) and the background behind KRaft mode, which removes the ZooKeeper dependency.
Core concepts of Hexagonal Architecture and its idiomatic implementation in Go using implicit interfaces and package structure for dependency direction control.
Decorator replaces the subclass explosion of inheritance with composition. It stacks wrappers that keep the same interface to add behavior at runtime. java.io, Python function decorators, and web middleware chains are all variations on the same intent.
Builder is the answer when three limits of constructors meet at once — many parameters, some optional, and step-wise validation. With fewer than all three, simpler tools suffice. When the language provides rich named/default parameters, the need for Builder shrinks as well.
Factory’s shared intent is separating creation from use. The three variants — Factory Method, Abstract Factory, and Static Factory Method — split creation differently and suit different conditions. Static Factory Method is the variant most often encountered in practice, and DI containers absorb part of Factory’s explicit role.
Singleton is one of the simplest patterns but the canonical anti-pattern debate. The decision to bundle single-instance guarantee with global access into one pattern causes tight coupling and test difficulty. DI is the general alternative that separates the two intents.
DIP (principle), IoC (pattern), and DI (technique) sit at different levels of abstraction. The hierarchy must be clear before framework features and design principles can be told apart.