kt-event-marketing/design/backend/sequence/inner/event-이미지생성요청.puml
cherry2250 e15b7b42e5 이미지 생성 및 AI 추천 inner sequence 수정
주요 변경사항:
- event-이미지생성요청.puml: Kafka 제거, ContentService 내부 Job 관리로 변경
- event-이미지결과조회.puml: ContentService 패턴으로 업데이트
- event-AI추천요청.puml: Gateway 패턴 추가, 한글화

아키텍처 구분:
- AI 추천: Kafka 사용 (ai-job-topic)
- 이미지 생성: 내부 Job 관리 (Kafka 사용 안 함)

모든 파일:
- Gateway 패턴 적용
- 레이어 아키텍처 (<<API Layer>>, <<Business Layer>>)
- 한글 요청/응답
- Redis 키 패턴 표준화

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-23 16:31:36 +09:00

91 lines
2.9 KiB
Plaintext

@startuml event-이미지생성요청
!theme mono
title Content Service - 이미지 생성 요청 (UFR-CONT-010)
actor Client
participant "API Gateway" as Gateway
participant "ContentController" as Controller <<API Layer>>
participant "ContentService" as Service <<Business Layer>>
participant "JobManager" as JobMgr <<Component>>
participant "Redis Cache" as Cache <<E>>
note over Controller, Cache
**UFR-CONT-010: SNS 이미지 생성 요청**
- Kafka 사용 안 함 (내부 Job 관리)
- 백그라운드 워커가 비동기 처리
- Redis에서 AI 추천 데이터 읽기
- 3가지 스타일 이미지 생성 (심플, 화려한, 트렌디)
end note
Client -> Gateway: POST /api/content/images/{eventDraftId}/generate
activate Gateway
Gateway -> Controller: POST /api/content/images/{eventDraftId}/generate
activate Controller
Controller -> Controller: 요청 검증\n(eventDraftId 유효성)
Controller -> Service: generateImages(eventDraftId)
activate Service
== 1단계: Redis에서 AI 추천 데이터 확인 ==
Service -> Cache: AI 추천 데이터 조회\nKey: ai:event:{eventDraftId}
activate Cache
Cache --> Service: AI 추천 결과\n{선택된 추천안, 이벤트 정보}
deactivate Cache
alt AI 추천 데이터 없음
Service --> Controller: throw NotFoundException\n("AI 추천을 먼저 선택해주세요")
Controller --> Gateway: 404 Not Found\n{"code": "CONTENT_001",\n"message": "AI 추천을 먼저 선택해주세요"}
deactivate Service
deactivate Controller
Gateway --> Client: 404 Not Found
deactivate Gateway
else AI 추천 데이터 존재
== 2단계: Job 생성 ==
Service -> JobMgr: createJob(eventDraftId, imageGeneration)
activate JobMgr
JobMgr -> JobMgr: Job ID 생성 (UUID)
JobMgr -> Cache: Job 상태 저장\nKey: job:{jobId}\nValue: {status: PENDING,\neventDraftId, type: IMAGE_GEN,\ncreatedAt}\nTTL: 1시간
activate Cache
Cache --> JobMgr: 저장 완료
deactivate Cache
JobMgr --> Service: Job 생성 완료\n{jobId, status: PENDING}
deactivate JobMgr
== 3단계: 응답 반환 ==
Service --> Controller: JobResponse\n{jobId, status: PENDING}
deactivate Service
Controller --> Gateway: 202 Accepted\n{"jobId": "job-uuid-123",\n"status": "PENDING",\n"message": "이미지 생성 중입니다"}
deactivate Controller
Gateway --> Client: 202 Accepted\n이미지 생성 시작
deactivate Gateway
note over Service, Cache
**백그라운드 워커 처리**
- Redis 폴링 또는 스케줄러가 Job 감지
- content-이미지생성.puml 참조
- 외부 이미지 생성 API 호출 (병렬)
- Redis에 이미지 URL 저장
**상세 내용**
- 3가지 스타일 병렬 생성 (심플, 화려한, 트렌디)
- Circuit Breaker 적용 (Timeout: 5분)
- 결과: Redis Key: content:image:{eventDraftId}
- TTL: 7일
end note
end
@enduml