kt-event-marketing/design/backend/sequence/inner/event-목적선택.puml
2025-10-22 20:13:56 +09:00

52 lines
1.8 KiB
Plaintext

@startuml event-목적선택
!theme mono
title Event Service - 이벤트 목적 선택 및 저장 (UFR-EVENT-020)
participant "EventController" as Controller <<C>>
participant "EventService" as Service <<S>>
participant "EventRepository" as Repo <<R>>
participant "Redis Cache" as Cache <<E>>
database "Event DB" as DB <<E>>
participant "Kafka Producer" as Kafka <<E>>
note over Controller: POST /api/events/purposes
Controller -> Service: createEventDraft(userId, objective, storeInfo)
activate Service
Service -> Cache: get("purpose:" + userId)
activate Cache
Cache --> Service: null (캐시 미스)
deactivate Cache
Service -> Service: validate(objective, storeInfo)
note right: 목적 유효성 검증\n- 신규 고객 유치\n- 재방문 유도\n- 매출 증대\n- 인지도 향상
Service -> Repo: save(eventDraft)
activate Repo
Repo -> DB: 이벤트 초안 저장\n(사용자ID, 목적, 매장정보,\n상태를 저장)
activate DB
DB --> Repo: eventDraftId
deactivate DB
Repo --> Service: EventDraft entity
deactivate Repo
Service -> Cache: set("purpose:" + userId, eventDraft, TTL=30분)
activate Cache
Cache --> Service: OK
deactivate Cache
Service -> Kafka: publish(EventDraftCreated,\n{eventDraftId, userId, objective, createdAt})
activate Kafka
note right: Kafka Event Topic:\nevent-topic\n\nEvent: EventDraftCreated\n(목적 선택 시 발행)\n\n※ EventCreated는\n최종 승인 시 발행
Kafka --> Service: ACK
deactivate Kafka
Service --> Controller: EventDraftResponse\n{eventDraftId, objective, status}
deactivate Service
Controller --> Client: 200 OK\n{eventDraftId}
note over Controller, Kafka: 캐시 히트 시:\n1. Redis에서 조회 → 즉시 반환\n2. DB 조회 생략\n\n※ EventDraftCreated 이벤트는\nAnalytics Service가 선택적으로 구독\n(통계 초기화는 EventCreated 시)
@enduml