Nest · DDD

NestJS 모듈 안의 DDD 계층 매핑

Nest 모듈 안에서 Controller, Application Service, Domain, Repository, Infrastructure 책임을 분리해 연결합니다.

DDD 계층 연결

ddd

Controller

HTTP 요청을 애플리케이션 명령으로 바꿉니다.

Application Service

유스케이스 흐름과 트랜잭션을 조율합니다.

Domain Model

비즈니스 규칙과 불변식을 보관합니다.

Repository Port

도메인이 저장소 구현을 직접 몰라도 되게 합니다.

Infrastructure

TypeORM, 외부 API 같은 실제 구현을 맡습니다.

controller application domain repository infrastructure

NestJS 모듈 안의 DDD 계층 매핑 정리

Nest에서 DDD를 적용한다는 것은 폴더를 나누는 일이 아니라 변경 이유가 다른 책임을 계층별로 분리하는 일입니다.