-
Notifications
You must be signed in to change notification settings - Fork 0
refactor: four_pillar 모듈 구조 개선 #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR refactors the four_pillars module to improve code organization and maintainability by separating concerns into distinct layers. The monolithic 568-line FourPillarsCalculator class has been split into focused components following domain-driven design principles.
Key Changes
- Responsibility separation: Split calculation, data loading, and analysis logic into dedicated classes (
FourPillarsDataLoader,FiveElementsAnalyzer,TenGodsAnalyzer) - Simplified architecture: Removed unnecessary application layer abstraction, consolidating functionality into a single
FourPillarsCalculatorwith optional description generation via dependency injection - Improved modularity: Moved entities and enums into a proper domain structure with clearer import paths
Reviewed changes
Copilot reviewed 14 out of 19 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
src/four_pillars/__init__.py |
Added module-level exports for cleaner imports |
src/four_pillars/domain/constants.py |
Extracted constants (JIKKAN, JYUNISHI, BASE_YEAR) for better organization |
src/four_pillars/domain/entities/enums.py |
Moved enums to domain layer with updated import path |
src/four_pillars/domain/entities/schemas.py |
Moved schemas to domain layer, removed unused List import |
src/four_pillars/domain/services/calculator.py |
New main calculator with optional description generator injection |
src/four_pillars/domain/services/data_loader.py |
Extracted data loading logic (kanshi and setsuiri data) |
src/four_pillars/domain/services/analyzer.py |
Extracted five elements and ten gods analysis logic |
src/four_pillars/infrastructure/description_generator.py |
Isolated HCX API integration for description generation |
src/four_pillars/common/calculator.py |
Deleted monolithic 568-line class, split into focused components |
src/users/application/service.py |
Updated to use new import path and inject description generator |
src/users/domain/interfaces.py |
Updated FourPillarDetail import path |
src/users/infrastructure/repository.py |
Updated FourPillarDetail import path |
src/users/api/schemas.py |
Updated FourPillarDetail import path |
src/users/api/router.py |
Updated FourPillarDetail import path |
src/lotto/api/schemas.py |
Updated FiveElements import path |
Comments suppressed due to low confidence (1)
src/four_pillars/domain/services/data_loader.py:2
- Import of 'Dict' is not used.
from typing import Dict, Tuple
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
📍 작업 배경 #
four_pillars 모듈 구조 개선
✨ 주요 개선 사항
FourPillarsCalculator하나로 통합description_generator를 선택적으로 주입하여 설명 생성 기능 제공📁 새로운 구조
🔄 변경된 파일
삭제된 파일
common/calculator.py(568줄 → 분리됨)entities/enums.py(도메인으로 이동)entities/schemas.py(도메인으로 이동)application/폴더 (불필요한 추상화 제거)생성된 파일
domain/constants.py- 상수 정의domain/services/calculator.py- 메인 계산 클래스domain/services/data_loader.py- 데이터 로딩domain/services/analyzer.py- 오행/십신 분석infrastructure/description_generator.py- HCX API 호출수정된 파일
__init__.py- export 업데이트users/application/service.py- 새로운 구조 사용📝 사용 방법
기본 사용 (설명 없이)
설명 포함 사용
🎯 핵심 변경사항
이전 구조
FourPillarsCalculator(도메인)FourPillarsService(애플리케이션, 단순 조합)개선된 구조
FourPillarsCalculator하나로 통합description_generator를 선택적으로 주입💬 코멘트 #