NestJS 11 Clean Architecture

Organize NestJS 11 projects with Clean Architecture and dependency injection.

7|3|Updated Nov 27, 2025
One-click install
npx skills add https://github.com/maksymilian-majer/kata-camp-hair-products --skill nestjs-11-clean-architecture
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: NestJS 11 Clean Architecture
Source: https://github.com/maksymilian-majer/kata-camp-hair-products/tree/main/.claude/skills/nestjs-architecture
Command: npx skills add https://github.com/maksymilian-majer/kata-camp-hair-products --skill nestjs-11-clean-architecture

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Projects built with NestJS often suffer from architectural drift as they grow, making maintenance and testing harder. This Skill provides a practical NestJS 11 Clean Architecture pattern that enforces dependency injection, clear domain boundaries, and a predictable module layout to improve scalability and reliability.

Core Features & Use Cases

  • Layered structure: Controller → Service → Repository → Database with inward dependencies.
  • DI tokens and clean interfaces: avoid direct instantiations and promote testability.
  • Domain logic in services and shared types to enable reuse across modules and potential CQRS adoption.
  • Use Case: organize a new backend feature by creating a module, controller, service, and repository following the conventions described.

Quick Start

Create a new NestJS 11 project and organize modules, controllers, services, and repositories following the conventions outlined above.

Frequently Asked Questions about NestJS 11 Clean Architecture

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure a NestJS backend with clean architecture?

Structure a NestJS backend using a layered Controller → Service → Repository pattern with inward dependencies. This approach enforces clear domain boundaries and places business logic in services to improve testability and prevent architectural drift as projects scale.

What is the best way to organize NestJS modules for scalability?

The best way to organize NestJS modules for scalability is enforcing dependency injection with symbol tokens and clear interfaces. This predictable module layout separates controllers, services, and shared types, enabling reuse and potential CQRS adoption.

Why does NestJS dependency injection cause architectural drift in large projects?

NestJS architectural drift happens when projects bypass dependency injection and use direct instantiations or parent imports. Enforcing DI tokens and clean interfaces prevents this drift by maintaining predictable module boundaries and ensuring testable code.

Can I use TypeScript interfaces for NestJS dependency injection tokens?

Yes, you can use TypeScript interfaces for NestJS dependency injection by utilizing symbol tokens. This clean architecture pattern avoids direct instantiations and promotes high testability across your backend API modules.

How do I handle validation errors in a NestJS clean architecture service?

Handle validation errors in a NestJS clean architecture service by throwing a plain ValidationException. Placing this domain logic securely within services ensures consistent error handling while keeping your layered structure predictable.

Does clean architecture work with existing NestJS controllers and repositories?

Clean architecture works with existing NestJS projects by reorganizing controllers, services, and repositories to enforce inward dependencies. Applying symbol tokens for DI and removing parent imports integrates the pattern without breaking current functionality.