The NestJS Patterns I Actually Reach For
Modules, providers, guards — the framework hands you a lot. Here's the small subset I keep returning to across production APIs.
NestJS gives you a generous toolbox. Across the production APIs I've shipped, I've ended up leaning on a small subset of it most of the time — and reaching for the rest only when a problem genuinely calls for it.
Modules by feature, not by layer. Every feature gets a folder with its controller, service, a few DTOs and its tests. The `controllers/` + `services/` split reads well in a tutorial and falls apart around the tenth feature.
Guards for auth, interceptors for logging, pipes for validation — that's the trinity that carries most of the weight. Custom decorators only when there's an obvious, repeated win, never for cleverness.
And one rule that's saved me repeatedly: services don't call each other across feature boundaries directly. They go through events. It keeps features from quietly fusing into a monolith-inside-a-monolith.