웹 계층에서는 요청을 받아서 도메인 혹은 비즈니스 계층에 있는 서비스로 요청을 보낸다.
서비스에서 필요한 비즈니스 로직을 수행하고, 도메인 엔티티의 현재 상태롤 조회하거나 변경하기 위해 영속성 계층의 컴포넌트를 호출한다.
DB 주도 설계를 유도 (웹 계층은 도메인 계층에 의존하고, 도메인 계층은 영속성 계층에 의존하기 때문에 자연스럽게 DB 의존하게 된다.)
하지만 우리가 만드는 앱은 보통 상태가 아니라 행동 중심으로 모델링한다.
비즈니스 관점에서는 도메인 로직이 DB 구조보다 우선이 된다.
in - from web(client)
out - to database(server)
BuckPal 코드 구성 예제
payment
ㄴ web
ㄴ AccountController
ㄴ domain
ㄴ Account
ㄴ Activity
ㄴ AccountRepository
ㄴ AccountService
ㄴ persistence
ㄴ AccountRepositoryIml
payment
ㄴ account
ㄴ Account
ㄴ Activity
ㄴ AccountRepository
ㄴ AccountRepositoryIml
ㄴ SendMoneyService
ㄴ AccountController
ㄴ user
ㄴ User
ㄴ UserRepository
ㄴ UserRepositoryIml
ㄴ UserRegistrationService
ㄴ UserController
payment
ㄴ account
ㄴ adapter
ㄴ in
ㄴ web
ㄴ AccountController
ㄴ out
ㄴ persistence
ㄴ AccountPersistenceAdapter
ㄴ SpringDataAccountRepository
ㄴ domain
ㄴ Account
ㄴ Activity
ㄴ application (서비스 계층)
ㄴ SendMoneyService
ㄴ port
ㄴ in
ㄴ SendMoneyUseCase
ㄴ out
ㄴ LoadAccountPort
ㄴ UpdateAccountStatePort
ㄴ user
ㄴ adapter
ㄴ domain
ㄴ application
payment
PaymentApplication.java
PaymentConfiguration.java
PaymentConfigurationProperties.java
ㄴ account
ㄴ adapter
web (controller/facade)
ㄴ AccountController
ㄴ AccountControllerTest
persistence (DAO, Implement Port, JPA Entity)
ㄴ AccountPersistenceAdapter (SpringDataAccountRepositoryImpl)
ㄴ SpringDataAccountRepository
ㄴ domain (entity)
model (DTO)
ㄴ AccountDTO
ㄴ ActivityDTO
ㄴ Account
ㄴ Activity
ㄴ application (service)
exception (error handling)
ㄴ LocalErrorHandling.java
utility (domain specific utils)
ㄴ Util.java
service (service logic)
ㄴ SendMoneyServicePortInImpl
ㄴ MoneyTransferProperties (props required in service)
ㄴ ExceptionHandler.java
port (interface)
ㄴ SendMoneyServicePortIn(SendMoneyUseCase)
ㄴ CreateAccountPortOut
ㄴ ReadAccountPortOut (RepositoryInterface) (LoadAccountPortInterface)
ㄴ UpdateAccountStatePortOut
ㄴ DeleteAccountPortOut
ㄴ user
ㄴ adapter
ㄴ domain
ㄴ application
ㄴ common
ㄴ PersistenceAdapter
ㄴ SelfValidating
ㄴ UseCase
ㄴ WebAdapter
만들면서 배우는 클릭 아키텍쳐 - 톰 홈버그
https://github.com/wikibook/clean-architecture
https://reflectoring.io/spring-hexagonal/
https://edykim.com/ko/post/ports-and-adapters-architecture-in-php/