@startuml meeting-회의종료 !theme mono title Meeting Service - 회의종료 내부 시퀀스 participant "MeetingController" as Controller participant "MeetingService" as Service participant "SessionService" as SessionService participant "MeetingRepository" as MeetingRepo participant "SessionRepository" as SessionRepo participant "StatisticsService" as StatService database "Meeting DB<>" as DB database "Redis Cache<>" as Cache queue "Azure Event Hubs<>" as EventHub [-> Controller: POST /meetings/{meetingId}/end activate Controller note over Controller 경로 변수: meetingId 사용자 정보: userId, userName, email end note Controller -> Controller: meetingId 유효성 검증 Controller -> Service: endMeeting(meetingId, userId) activate Service ' 회의 정보 조회 Service -> MeetingRepo: findById(meetingId) activate MeetingRepo MeetingRepo -> DB: SELECT * FROM meetings WHERE id = ? activate DB DB --> MeetingRepo: 회의 정보 deactivate DB MeetingRepo --> Service: Meeting deactivate MeetingRepo note over Service 비즈니스 규칙 검증: - 회의가 존재하는지 확인 - 회의 종료 권한 확인 (생성자만) - 회의 상태 확인 (IN_PROGRESS만 종료 가능) end note Service -> Service: 권한 검증\n(생성자만 종료 가능) Service -> Service: 회의 상태 확인 alt 회의가 진행 중이 아님 Service --> Controller: 409 Conflict\n진행 중인 회의가 아님 return 409 Conflict else 종료 가능 ' 세션 정보 조회 Service -> SessionRepo: findActiveSession(meetingId) activate SessionRepo SessionRepo -> DB: SELECT * FROM meeting_sessions\nWHERE meetingId = ?\nAND status = 'ACTIVE' activate DB DB --> SessionRepo: 세션 정보 deactivate DB SessionRepo --> Service: Session deactivate SessionRepo ' 세션 종료 Service -> SessionRepo: endSession(sessionId) activate SessionRepo SessionRepo -> DB: UPDATE meeting_sessions\nSET status = 'ENDED',\n endedAt = NOW()\nWHERE id = ? activate DB DB --> SessionRepo: 업데이트 완료 deactivate DB SessionRepo --> Service: 종료 성공 deactivate SessionRepo ' 회의 상태 업데이트 Service -> MeetingRepo: updateStatus(meetingId, "ENDED") activate MeetingRepo MeetingRepo -> DB: UPDATE meetings\nSET status = 'ENDED',\n actualEndTime = NOW()\nWHERE id = ? activate DB DB --> MeetingRepo: 업데이트 완료 deactivate DB MeetingRepo --> Service: 업데이트 성공 deactivate MeetingRepo note over Service 회의 통계 생성: - 회의 총 시간 - 참석자 수 - 발언 횟수 (STT 데이터 기반) - 주요 키워드 end note ' 회의 통계 생성 Service -> StatService: generateMeetingStatistics(sessionId) activate StatService StatService -> DB: SELECT\n COUNT(DISTINCT speakerId) as speakerCount,\n COUNT(*) as utteranceCount,\n TIMESTAMPDIFF(MINUTE, startedAt, endedAt) as duration\nFROM transcripts WHERE sessionId = ? activate DB DB --> StatService: 통계 데이터 deactivate DB StatService -> DB: INSERT INTO meeting_statistics\n(meetingId, sessionId, duration,\nparticipantCount, utteranceCount, createdAt) activate DB DB --> StatService: 통계 저장 완료 deactivate DB StatService --> Service: Statistics deactivate StatService ' 회의록 상태 업데이트 Service -> MeetingRepo: updateMinutesStatus(meetingId, "DRAFT") activate MeetingRepo MeetingRepo -> DB: UPDATE minutes\nSET status = 'DRAFT',\n endedAt = NOW()\nWHERE meetingId = ?\nAND status = 'IN_PROGRESS' activate DB DB --> MeetingRepo: 업데이트 완료 deactivate DB MeetingRepo --> Service: 업데이트 성공 deactivate MeetingRepo ' 캐시 무효화 Service -> Cache: DELETE meeting:info:{meetingId} activate Cache Cache --> Service: 삭제 완료 deactivate Cache note over Service 비동기 이벤트 발행: - STT 서비스에 녹음 중지 요청 - AI 서비스에 최종 회의록 생성 요청 - 참석자에게 회의 종료 알림 end note ' 이벤트 발행 Service -> EventHub: publish(MeetingEnded)\n{\n meetingId, sessionId,\n endedAt, statistics,\n minutesId\n} activate EventHub EventHub --> Service: 발행 완료 deactivate EventHub Service --> Controller: MeetingEndResponse deactivate Service note over Controller 응답 데이터: { "meetingId": "uuid", "sessionId": "uuid", "status": "ENDED", "endedAt": "2025-01-23T15:00:00", "statistics": { "duration": 60, "participantCount": 5, "utteranceCount": 120 }, "minutesId": "uuid" } end note return 200 OK\nMeetingEndResponse end deactivate Controller @enduml