Skip to content

Conversation

@apaals2
Copy link
Contributor

@apaals2 apaals2 commented Aug 12, 2025

JIRA Task 🔖

  • Ticket: BAK-51
  • Branch : feature/list-ai-chat-tab

참고 사항

  1. chat_message 서비스와 API 분리 여부

현재 repository는 chat_tab과 chat_message로 분리되어 있으나, 라우터는 계층형으로 되어있습니다.
역할과 책임을 명확히 하기 위해 서비스/라우터도 리소스 단위로 분리하는 것이 좋을지 고민 중입니다.

# 리소스 단위로 분리
/api/chatTabs                -> 모든 채팅 탭 조회
/api/chatTabs/{tabId}        -> 특정 채팅 탭 조회
/api/chatTabs               -> 채팅 탭 생성
/api/chatTabs/{tabId}        -> 채팅 탭 수정
/api/chatTabs/{tabId}        -> 채팅 탭 삭제

/api/chatMessages/{tabId}    -> 특정 채팅 탭의 메시지 전체 조회
/api/chatMessages/{tabId}    -> 특정 채팅 탭에 메시지 전송
#계층형 구조로 묶기
/api/chatTabs                -> 채팅 탭 목록 조회
/api/chatTabs/{tabId}        -> 특정 채팅 탭 조회/수정/삭제
/api/chatTabs/{tabId}/messages -> 해당 탭의 메시지 목록 조회
/api/chatTabs/{tabId}/messages -> 해당 탭에 메시지 전송

분리한다면 채팅 질의 브랜치에서 분리 예정입니다.

  1. 특정 chat_tab의 모든 데이터를 한꺼번에 조회하는 부분에서, 성능 최적화를 위해 캐싱이나 페이지네이션 도입이 필요할지 검토하고 있습니다.
  2. 리팩토링 작업은 추후 진행할 예정입니다.
  3. 채팅 기능 개발도 곧 시작할 계획입니다.
  4. black . ruff format . 으로 인한 코드 포맷이 있습니다.

@apaals2 apaals2 self-assigned this Aug 12, 2025
Copy link
Member

@nahyeongjin1 nahyeongjin1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

페이지네이션을 도입한다면 created_at만 인덱스로 설정하거나 chat_tab_id와 같이 복합 인덱스로 설정하는게 좋을 것 같습니다.

수고하셨습니다!

Comment on lines +19 to +22
cursor.execute(
"SELECT * FROM chat_message WHERE chat_tab_id = ? ORDER BY created_at ASC",
(id,),
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(chat_tab_id, created_at)으로 복합 인덱스를 생성하면 이 부분에 아래와 같은 페이지네이션 관련 변경이 생길 때 탐색과 정렬 작업이 사라져 성능 향상을 기대할 수 있을 것 같습니다.

...
WHERE chat_tab_id = ? ORDER BY created_at ASC LIMIT 20 OFFSET 40

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

의견 감사합니다. 해당 부분은 사용자 질의 기능 개발에서 반영하겠습니다.

@apaals2 apaals2 merged commit 3aca1ce into develop Aug 14, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants