docs: main.py 엔드포인트 라우터 이동 문서 원칙 준수 수정
This commit is contained in:
parent
5be00aa3d5
commit
8cf25e7ec5
@ -1,45 +1,32 @@
|
||||
# main.py 엔드포인트 라우터 이동
|
||||
|
||||
**작성일**: 2025-12-23
|
||||
**문제**: main.py에 16개 엔드포인트가 직접 정의되어 원칙 위반
|
||||
**해결**: 모든 엔드포인트를 `app/router/`로 이동
|
||||
**날짜**: 2025-12-23
|
||||
**작성자**: happybell80
|
||||
**관련 파일**: `main.py`, `app/router/*_endpoint.py`
|
||||
|
||||
## 문제
|
||||
## 문제 상황
|
||||
|
||||
main.py에 `@app.post()`, `@app.get()` 데코레이터로 직접 정의된 엔드포인트 16개 존재.
|
||||
원칙 문서(`311_FastAPI_구조_원칙.md`)에 따르면 `main.py`는 "앱 실행, 라우터 등록만" 담당해야 함.
|
||||
- main.py에 `@app.post()`, `@app.get()` 데코레이터로 직접 정의된 엔드포인트 16개 존재
|
||||
- 계층 분리 원칙 위반: `main.py`는 "앱 실행, 라우터 등록만" 담당해야 함 (`311_FastAPI_구조_원칙.md`)
|
||||
|
||||
## 해결
|
||||
## 해결 방안
|
||||
|
||||
### 이동 계획
|
||||
- `feedback_endpoint.py` 생성: `main.py:89-110` → `app/router/feedback_endpoint.py`
|
||||
- `llm_endpoint.py` 확장: `main.py:473-568` → `app/router/llm_endpoint.py:129-217` (`/api/llm/extract` 추가)
|
||||
- `llm_complete_endpoint.py` 생성: `main.py:113-148` → `app/router/llm_complete_endpoint.py` (`/complete` 별도 파일)
|
||||
- `slack_endpoint.py` 확장: `main.py:241-245` → `app/router/slack_endpoint.py:117-121` (`/interactive` 추가)
|
||||
- `system_endpoint.py` 생성: `main.py:287-317,324-361,438-444` → `app/router/system_endpoint.py`
|
||||
- `schedule_endpoint.py` 생성: `main.py:259-295` → `app/router/schedule_endpoint.py`
|
||||
- `dm_endpoint.py` 확장: `main.py:364-435` → `app/router/dm_endpoint.py` (`/send-email-summary` 추가, JWT 인증 추가)
|
||||
- `history_endpoint.py` 생성: `main.py:447-522` → `app/router/history_endpoint.py`
|
||||
- 의존성 주입: `system_endpoint.py:18-21` (`set_router_instance`), `schedule_endpoint.py:18-21` (`set_scheduler`)
|
||||
- TDD 진행: 각 엔드포인트별 테스트 파일 작성 후 구현
|
||||
|
||||
1. **feedback_endpoint.py** (신규): `/api/feedback/chat`
|
||||
2. **llm_endpoint.py** (확장): `/api/llm/extract` 추가
|
||||
3. **llm_complete_endpoint.py** (신규): `/complete` (skill-slack 호환성)
|
||||
4. **slack_endpoint.py** (확장): `/api/slack/interactive` 추가
|
||||
5. **system_endpoint.py** (신규): `/health`, `/stats`, `/api/config`
|
||||
6. **schedule_endpoint.py** (신규): `/api/schedule/*`
|
||||
7. **dm_endpoint.py** (확장): `/send-email-summary` 추가, JWT 인증 추가
|
||||
8. **history_endpoint.py** (신규): `/api/history`
|
||||
|
||||
### 의존성 주입 패턴
|
||||
|
||||
- `system_endpoint.py`: `set_router_instance()`로 router 인스턴스 주입
|
||||
- `schedule_endpoint.py`: `set_scheduler()`로 scheduler 인스턴스 주입
|
||||
|
||||
### 작업 방식
|
||||
|
||||
TDD로 진행:
|
||||
1. 각 엔드포인트별 테스트 파일 작성
|
||||
2. router 파일 생성/확장
|
||||
3. main.py에서 엔드포인트 제거 및 라우터 등록
|
||||
|
||||
## 결과
|
||||
## 구현 완료
|
||||
|
||||
- 모든 엔드포인트 router로 이동 완료
|
||||
- main.py에 남은 `@app.` 데코레이터는 `@app.on_event()`만 남음 (이벤트 핸들러)
|
||||
- 모든 엔드포인트가 router로 분리 완료
|
||||
- e2e 테스트 통과 확인
|
||||
- 기존 기능 정상 동작 확인
|
||||
|
||||
## 교훈
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user