Skip to content

Architecture and Database

최건희 edited this page Aug 13, 2026 · 1 revision

Architecture & Database

패키지 구조

DisplayU Backend는 도메인 단위의 계층형 구조를 사용합니다.

domain/{domainName}
├── presentation
├── application
├── domain
└── infrastructure
계층 책임
Presentation Controller, Request/Response, HTTP Mapper, Swagger
Application UseCase 흐름, Transaction, Command/Query/Result
Domain Aggregate, Entity, Value Object, Policy, Repository Port
Infrastructure JPA Adapter, Spring Data Repository, 외부 Client

핵심 원칙

  • Controller에 비즈니스 규칙을 넣지 않습니다.
  • Application Service는 흐름 조율과 트랜잭션 경계에 집중합니다.
  • Aggregate가 내부 Entity와 Value Object의 상태 변경을 통제합니다.
  • Domain은 HTTP, JPA 구현체, 외부 Client를 직접 의존하지 않습니다.
  • 단순 CRUD에 불필요한 추상화를 추가하지 않고 주변 코드의 기존 패턴을 따릅니다.

전체 기준은 Project Architecture Guide를 확인합니다.

Database Migration

스키마 변경은 Flyway로 관리합니다.

src/main/resources/db/migration

파일명은 다음 형식을 사용합니다.

V{timestamp}__{description}.sql

예시:

V20260813000300__add_display_status_index.sql

Migration 규칙

  • 이미 공유 환경에 적용된 Migration 파일은 수정하거나 삭제하지 않습니다.
  • 새로운 스키마 변경은 항상 다음 버전의 SQL 파일로 추가합니다.
  • local, dev의 Hibernate 설정은 ddl-auto: validate를 유지합니다.
  • 테이블·컬럼 변경과 데이터 보정이 함께 필요하면 배포 순서를 고려합니다.
  • PR 전에 Test와 Migration 검증을 실행합니다.

상세 문서:

Clone this wiki locally