@startuml event-AI추천요청 !theme mono title Event Service - AI 추천 요청 (Kafka Job 발행) (UFR-EVENT-030) participant "EventController" as Controller <> participant "EventService" as Service <> participant "JobService" as JobSvc <> participant "EventRepository" as Repo <> participant "Redis Cache" as Cache <> database "Event DB" as DB <> participant "Kafka Producer" as Kafka <> note over Controller: POST /api/events/{id}/ai-recommendations Controller -> Service: requestAIRecommendation(eventDraftId, userId) activate Service Service -> Repo: findById(eventDraftId) activate Repo Repo -> DB: 이벤트 초안 조회\n(초안ID와 사용자ID로 조회) activate DB DB --> Repo: EventDraft deactivate DB Repo --> Service: EventDraft entity deactivate Repo Service -> Service: validateOwnership(userId, eventDraft) note right: 사용자 권한 검증 Service -> JobSvc: createAIJob(eventDraft) activate JobSvc JobSvc -> JobSvc: generateJobId() note right: UUID 생성 JobSvc -> Cache: set("job:" + jobId,\n{status: PENDING, createdAt}, TTL=1시간) activate Cache Cache --> JobSvc: OK deactivate Cache JobSvc -> Kafka: publish(ai-job,\n{jobId, eventDraftId, objective,\nindustry, region, storeInfo}) activate Kafka note right: Kafka Job Topic:\nai-job-topic Kafka --> JobSvc: ACK deactivate Kafka JobSvc --> Service: JobResponse\n{jobId, status: PENDING} deactivate JobSvc Service --> Controller: JobResponse\n{jobId, status: PENDING} deactivate Service Controller --> Client: 202 Accepted\n{jobId, status: PENDING} note over Controller, Kafka: AI Service는 백그라운드에서\nKafka ai-job 토픽을 구독하여\n비동기로 처리 @enduml