docs: 중복 코드 제거 원칙 및 utils 네이밍 규칙 추가

This commit is contained in:
Claude-51124 2025-12-16 14:52:35 +09:00
parent 875fa46f0d
commit 8f8ef1d0c0
2 changed files with 15 additions and 0 deletions

View File

@ -64,6 +64,11 @@
- `database.py`: 통합 DB 접근
- `{도메인}_repository.py`: 도메인별 CRUD 캡슐화
### utils/
- `{기능}_extractor.py`: 데이터 추출 (json_extractor.py)
- `{기능}_helper.py`: 도우미 함수
- 명확하고 구체적인 이름 사용
### models/
- `{도메인}_model.py`: ORM 모델 (예: user_model.py, emotion_model.py)
@ -93,6 +98,13 @@ utils
## 5. 코드 작성 원칙
### 중복 코드 제거 우선
- 동일한 로직이 2개 이상의 위치에 반복되면 `utils/`에 유틸리티 함수로 추출
- 한 곳만 수정하여 전체 반영 가능하도록 설계
- 범용적이고 재사용 가능한 함수로 구현
**참고**: `DOCS/book/300_architecture/guidelines/utility_functions.md`
### LangGraph 워크플로우
- **복잡한 다단계 처리**: LangGraph 적극 활용
- **프로덕션 핵심 워크플로우**: PostgresSaver로 체크포인트 구현 (권장)
@ -165,6 +177,7 @@ utils
- [ ] 비즈니스 로직이 router에 있지 않은가?
- [ ] 순환 import 가능성은 없는가?
- [ ] 핵심 파일은 300줄 이하로 유지할 수 있는가?
- [ ] 중복 코드는 utils/로 추출할 수 있는가?
- [ ] DB 스키마 변경 시 ORM/DDL/Repository 동시 수정 확인
- [ ] LLM 호출 횟수 계산 및 최적화 검토
- [ ] 원칙 문서 확인 완료 (`311_FastAPI_구조_원칙.md`, `312_문서_작성_원칙.md`)

View File

@ -11,6 +11,7 @@
- **router**: `{기능}_endpoint.py` (예: `message_endpoint.py`)
- **service**: `{도메인}_{기능}.py` (예: `coldmail_filter.py`)
- **state**: `{도메인}_repository.py` (예: `conversation_repository.py`)
- **utils**: `{기능}_extractor.py`, `{기능}_helper.py` (예: `json_extractor.py`)
**참고**: `DOCS/book/300_architecture/311_FastAPI_구조_원칙.md:53-63`
@ -18,6 +19,7 @@
- `router/`: HTTP 엔드포인트
- `services/`: 비즈니스 로직
- `state/`: DB 접근 (Repository 패턴)
- `utils/`: 공통 유틸리티 함수
- `models/`: ORM 모델
- `schemas/`: Pydantic 모델