nestjs

Structure NestJS applications with hexagonal architecture and CQRS patterns.

Updated Dec 26, 2025
One-click install
npx skills add https://github.com/JoyanLabs/template-nestjs-dashboard-better_auth --skill nestjs-joyanlabs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: nestjs
Source: https://github.com/JoyanLabs/template-nestjs-dashboard-better_auth/tree/main/skills/nestjs
Command: npx skills add https://github.com/JoyanLabs/template-nestjs-dashboard-better_auth --skill nestjs-joyanlabs

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes assets (resource) components.

What problem does it solve?

Hexagonal architecture and CQRS patterns help teams build scalable, maintainable NestJS backends by cleanly separating concerns across API, application, domain, and infrastructure layers.

Core Features & Use Cases

  • Hexagonal Architecture: Clear boundary definitions between controllers (API), application services (CQRS), and domain/entities.
  • CQRS with NestJS: Separate Commands and Queries to manage writes and reads.
  • Ports & Adapters: Abstract external services behind ports and implement adapters.
  • Guided architecture: Directory layout example shows structure (api, application, domain, infrastructure).

Quick Start

Create a minimal NestJS module that demonstrates hexagonal architecture with CQRS by implementing a sample Users feature including a controller, command, query, and a basic in-memory adapter.

Frequently Asked Questions about nestjs

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

FAQPage Schema
How do I structure a NestJS application with hexagonal architecture and CQRS?

Structure NestJS applications by applying hexagonal architecture and CQRS patterns to separate concerns across API controllers, application commands and queries, domain entities, and infrastructure adapters. This modular structure maintains clear boundaries and improves testability for scalable API backends.

What is the best way to separate read and write operations in a NestJS backend?

The best way to separate reads and writes in a NestJS backend is using CQRS patterns. This Skill implements distinct command and query buses, isolating write operations in application commands and read operations in application queries to optimize scalability and maintainability.

When should I use ports and adapters in my NestJS project?

Use ports and adapters in a NestJS project when you need to abstract external services behind ports and implement flexible adapters. This hexagonal architecture approach isolates infrastructure dependencies, ensuring your domain entities remain testable and independent from external service implementations.

Can I see a directory layout example for a modular NestJS application using domain entities?

Yes, this Skill provides a guided directory layout example separating modules into api/controllers, application/commands and queries, domain/entities, and infrastructure adapters. It includes a sample Users feature demonstrating a controller, command, query, and in-memory adapter.

Does implementing hexagonal architecture in NestJS require a lot of manual module setup?

Implementing hexagonal architecture in NestJS typically requires manual module setup to define boundaries, but this Skill provides a guided structure and sample Users feature to accelerate the process. It establishes clear separation between API, application, domain, and infrastructure layers automatically.

Why does separating domain logic from infrastructure matter in NestJS backends?

Separating domain logic from infrastructure matters in NestJS backends because it enforces clear separation of concerns, ensuring scalable module boundaries. This isolation prevents infrastructure changes from affecting core domain entities and significantly improves overall application testability.