IPAM 서비스의 각 DDD 레이어(domain/application/infrastructure/interface) 내부에서 도메인 개념별 분리가 없어 거대한 단일 파일들이 존재합니다:
services/ipam/src/ipam/
├─ main.py # FastAPI app
├─ routers.py # 중앙 라우터 registry
├─ graphql/
├─ prefix/
│ ├─ domain/ (aggregate, events, value_objects, repository interface)
│ ├─ command/ (commands.py, handlers.py)
│ ├─ query/ (queries.py, handlers.py, dto.py)
│ ├─ router/ (router.py, schemas.py)
│ └─ infra/ (models.py, repository.py, projector.py)
├─ ip_address/ # 동일 구조
├─ vrf/
├─ vlan/
├─ vlan_group/
├─ ip_range/
├─ rir/
├─ asn/
├─ fhrp_group/
├─ route_target/
├─ service_entity/
└─ shared/ # cross-cutting (saved_filter, search, import_export, services, config)
배경
IPAM 서비스의 각 DDD 레이어(domain/application/infrastructure/interface) 내부에서 도메인 개념별 분리가 없어 거대한 단일 파일들이 존재합니다:
command_handlers.py(2341줄),read_model_repository.py(1113줄),query_handlers.py(687줄) 등목표
Aggregate별 독립 폴더 + 내부 CQRS 레이어 (vertical slice) 구조로 리팩토링
목표 구조
작업 체크리스트
Phase 1: Domain 이동
Phase 2: Application 이동
{agg}/command/commands.py{agg}/command/handlers.py{agg}/query/Phase 3: Infrastructure 이동
{agg}/infra/models.py{agg}/infra/repository.py{agg}/infra/projector.pyPhase 4: Interface 이동
{agg}/router/router.py{agg}/router/schemas.py설계 결정
routers.py)ipam/최상위