# agodin3z/nestjs-cqrs-boilerplate architecture

> Architecture diagram of the GitHub repository agodin3z/nestjs-cqrs-boilerplate, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/agodin3z/nestjs-cqrs-boilerplate
- Repository: https://github.com/agodin3z/nestjs-cqrs-boilerplate

## Overview

##### Main Components Identification
The project follows a clean architecture with DDD principles, divided into four main layers:

a. Interface Layer (Presentation)
b. Application Layer (Use Cases)
c. Domain Layer (Business Logic)
d. Infrastructure Layer (External Concerns)

##### Specific Implementation Details

**[Client Applications]**
- ↓
**[HTTP Layer]**
- Controllers (app.controller)
- DTOs (response.dto)
- Middlewares (domain-filter, http-logger)
- Exception Filters
- ↓
**[Application Layer]**
- Query Handlers (hello.handler)
- Commands (not implemented yet but prepared)
- ↓
**[Domain Layer]**
- Services (app.service)
- Utils (error handling)
- ↓
**[Infrastructure Layer]**
- Configuration
- Health Check Module

##### Key Architectural Aspects to Highlight

a. CQRS Pattern Implementation:
- Separation between Query and Command paths
- Hello.query and its handler

b. DDD Layers:
- Clear separation between layers
- Dependencies flowing inward
- Domain layer at the core

c. Infrastructure Concerns:
- Configuration management
- Health check endpoints
- Docker containerization support

##### Technical Stack Indicators

Technology badges for:
- NestJS framework
- Node.js runtime
- Docker containerization
- Testing framework (Jest)

Remember to emphasize:
- The separation of concerns between layers
- The CQRS pattern implementation
- The clean architecture principles
- The infrastructure support for containerization
- The health check and monitoring capabilities

This will provide a clear understanding of both the high-level architecture and the specific implementation details of this NestJS boilerplate.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        CL[Client Applications]
    end

    subgraph Interface
        CO["Controllers"]
        DTO["DTOs"]
        EF["Exception Filters"]
        MW["Middlewares"]
    end

    subgraph Application
        QH["Query Handlers"]
        QO["Query Objects"]
        CM["Command Handlers"]:::future
    end

    subgraph Domain
        DS["Domain Services"]
        EU["Error Utils"]
    end

    subgraph Infrastructure
        CF["Configuration"]
        HC["Health Check Module"]
        MA["Main Application"]
        EP["Entry Point"]
    end

    %% Relationships
    CL --> CO
    CO --> QH
    CO --> CM
    QH --> QO
    QH --> DS
    CM --> DS
    DS --> EU
    MA --> CF
    MA --> HC
    MA --> CO
    EP --> MA

    %% Click Events
    click CO "https://github.com/agodin3z/nestjs-cqrs-boilerplate/blob/main/src/interface/controllers/app.controller.ts"
    click DTO "https://github.com/agodin3z/nestjs-cqrs-boilerplate/blob/main/src/interface/dtos/response.dto.ts"
    click EF "https://github.com/agodin3z/nestjs-cqrs-boilerplate/blob/main/src/interface/exceptions/http-exception.filter.ts"
    click MW "https://github.com/agodin3z/nestjs-cqrs-boilerplate/tree/main/src/interface/middlewares"
    click QH "https://github.com/agodin3z/nestjs-cqrs-boilerplate/blob/main/src/application/queries/handlers/hello.handler.ts"
    click QO "https://github.com/agodin3z/nestjs-cqrs-boilerplate/blob/main/src/application/queries/hello.query.ts"
    click DS "https://github.com/agodin3z/nestjs-cqrs-boilerplate/blob/main/src/domain/services/app.service.ts"
    click EU "https://github.com/agodin3z/nestjs-cqrs-boilerplate/blob/main/src/domain/utils/error.ts"
    click CF "https://github.com/agodin3z/nestjs-cqrs-boilerplate/tree/main/src/infraestructure/config"
    click HC "https://github.com/agodin3z/nestjs-cqrs-boilerplate/tree/main/src/infraestructure/health"
    click MA "https://github.com/agodin3z/nestjs-cqrs-boilerplate/blob/main/src/app.module.ts"
    click EP "https://github.com/agodin3z/nestjs-cqrs-boilerplate/blob/main/src/main.ts"

    %% Styles
    classDef external fill:#2196F3,stroke:#1976D2,color:white
    classDef interface fill:#4CAF50,stroke:#388E3C,color:white
    classDef application fill:#FFC107,stroke:#FFA000,color:black
    classDef domain fill:#FF5722,stroke:#E64A19,color:white
    classDef infrastructure fill:#9E9E9E,stroke:#616161,color:white
    classDef future fill:#E0E0E0,stroke:#9E9E9E,color:#616161

    class CL external
    class CO,DTO,EF,MW interface
    class QH,QO,CM application
    class DS,EU domain
    class CF,HC,MA,EP infrastructure

    %% Legend
    subgraph Legend
        L1[External Layer]:::external
        L2[Interface Layer]:::interface
        L3[Application Layer]:::application
        L4[Domain Layer]:::domain
        L5[Infrastructure Layer]:::infrastructure
        L6[Future Components]:::future
    end
```
