19일 차 TIL
Clean Architecture와 DDD에 대해서 공부했다.
이번 1차 프로젝트에서는 Clean Architecture 베이스의 DDD를 입힌 도메인 중심 아키텍처를 사용할 예정이다.
Clean Architecture vs DDD 구조 비교
도메인 중심 아키텍처 패키지 구조 예시)
src/main/java/com/nextdaydeliverry
│
├── global
│ └── infrastructure
│ ├── config
│ │ ├── security
│ │ │ └── SecurityConfig.java
│ │ └── schedule
│ │ └── ScheduleConfig.java
│ └── presentation
│ └── advice
│ └── GlobalExceptionHandler.java
│
├── article
│ ├── application
│ │ └── service
│ │ └── ArticleService.java
│ │
│ ├── domain
│ │ ├── entity
│ │ │ └── ArticleEntity.java
│ │ └── repository
│ │ └── ArticleRepository.java
│ │
│ ├── infrastructure
│ │ ├── api
│ │ │ └── gemini
│ │ │ ├── dto
│ │ │ │ └── response
│ │ │ │ └── ResPostGeminiGenerateContentDto.java
│ │ │ └── client
│ │ │ └── GeminiClient.java
│ │ ├── repository
│ │ │ └── ArticleRepositoryImpl.java (생략가능)
│ │ └── schedule
│ │ └── articleScheduler.java
│ │
│ └── presentation
│ ├── controller
│ │ └── ArticleController.java
│ └── dto
│ ├── request
│ │ └── ReqGetArticleByIdDto.java
│ └── response
│ └── ResGetArticleByIdDto.java
│
├── user
│ ├── application
│ │ └── service
│ │ └── UserService.java
│ │
│ ├── domain
│ │ ├── entity
│ │ │ └── UserEntity.java
│ │ └── repository
│ │ └── UserRepository.java
│ │
│ ├── infrastructure
│ │ └── repository
│ │ └── UserRepositoryImpl.java (생략가능)
│ │
│ └── presentation
│ ├── controller
│ │ └── UserController.java
│ ├── docs
│ │ └── UserApiDocs.java
│ └── dto
│ ├── request
│ │ └── ReqGetUserByIdDto.java
│ └── response
│ └── ResGetUserByIdDto.java
│
└── NextDayDeliveryApplication.java
Entities (원래 최안단) → domain/entity
원칙: 비즈니스 핵심 규칙을 담은 순수한 객체
현재 구조:
ArticleEntity, UserEntity가 이 역할을 합니다.
DB 프레임워크(JPA 등)에 의존하긴 하지만, 프로젝트의 심장부 역할을 수행합니다.
Use Cases (그다음 원) → application/service
원칙: 시스템이 무엇을 하는지 정의하는 로직 (예: 주문하기, 가입하기)
현재 구조:
ArticleService, UserService가 이 계층입니다.
domain 객체를 가져와서 실제 비즈니스 흐름을 완성합니다.
Interface Adapters → presentation & infrastructure/repository
원칙: 데이터를 외부(웹, DB) 형식에서 도메인 형식으로 변환
현재 구조:
Inbound: presentation/controller (HTTP → Application)
Outbound: infrastructure/repository (Application → Database)
Frameworks & Drivers (최외곽) → global & infrastructure
원칙: 도구들 (Spring, Liquibase, Redis, Security)
현재 구조:
global/infrastructure, docker-compose, Liquibase 설정 등이 이에 해당합니다.
의존성의 흐름은 다음과 같습니다.
- Presentation → Application → Domain ← Infrastructure
'내배캠' 카테고리의 다른 글
| [내일배움캠프] 21일 차 TIL QueryDSL 적용 방법 (0) | 2026.03.02 |
|---|---|
| [내일배움캠프] 20일 차 TIL Github Rules, Code Convention (0) | 2026.03.01 |
| [내일배움캠프] 18일 차 TIL 동시성문제 해결방법들 (0) | 2026.02.27 |
| [내일배움캠프 본캠프] 17일 차 TIL ERD 설계 시 트레이드-오프 고려 (0) | 2026.02.26 |
| [내일배움캠프 본캠프] 16일 차 TIL 도커 (0) | 2026.02.25 |
