Conversation
Contributor
There was a problem hiding this comment.
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 <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📍 작업 배경 #
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를 선택적으로 주입💬 코멘트 #