@startuml
!theme mono

title Participation Service 클래스 다이어그램 (요약)

package "com.kt.event.participation" {

    package "presentation.controller" {
        class ParticipationController
        class WinnerController
        class DebugController
    }

    package "application" {
        package "service" {
            class ParticipationService
            class WinnerDrawService
        }

        package "dto" {
            class ParticipationRequest
            class ParticipationResponse
            class DrawWinnersRequest
            class DrawWinnersResponse
        }
    }

    package "domain" {
        package "participant" {
            class Participant
            interface ParticipantRepository
        }

        package "draw" {
            class DrawLog
            interface DrawLogRepository
        }
    }

    package "exception" {
        class ParticipationException
        class DuplicateParticipationException
        class EventNotFoundException
        class EventNotActiveException
        class ParticipantNotFoundException
        class AlreadyDrawnException
        class InsufficientParticipantsException
        class NoWinnersYetException
    }

    package "infrastructure" {
        package "kafka" {
            class KafkaProducerService
            class ParticipantRegisteredEvent
        }

        package "config" {
            class SecurityConfig
        }
    }
}

package "com.kt.event.common" {
    abstract class BaseTimeEntity
    class "ApiResponse<T>"
    class "PageResponse<T>"
    interface ErrorCode
    class BusinessException
}

' Presentation → Application
ParticipationController --> ParticipationService
WinnerController --> WinnerDrawService

' Application → Domain
ParticipationService --> ParticipantRepository
ParticipationService --> KafkaProducerService
WinnerDrawService --> ParticipantRepository
WinnerDrawService --> DrawLogRepository

' Domain
Participant --|> BaseTimeEntity
DrawLog --|> BaseTimeEntity
ParticipantRepository --> Participant
DrawLogRepository --> DrawLog

' Exception
ParticipationException --|> BusinessException
DuplicateParticipationException --|> ParticipationException
EventNotFoundException --|> ParticipationException
EventNotActiveException --|> ParticipationException
ParticipantNotFoundException --|> ParticipationException
AlreadyDrawnException --|> ParticipationException
InsufficientParticipantsException --|> ParticipationException
NoWinnersYetException --|> ParticipationException

' Infrastructure
KafkaProducerService --> ParticipantRegisteredEvent

note right of ParticipationController
**API 매핑**
participate: POST /events/{eventId}/participate 이벤트 참여
getParticipants: GET /events/{eventId}/participants 참여자 목록 조회
getParticipant: GET /events/{eventId}/participants/{participantId} 참여자 상세 조회
end note

note right of WinnerController
**API 매핑**
drawWinners: POST /events/{eventId}/draw-winners 당첨자 추첨
getWinners: GET /events/{eventId}/winners 당첨자 목록 조회
end note

note right of DebugController
**API 매핑**
health: GET /health 헬스체크
end note

note bottom of ParticipationService
**핵심 비즈니스 로직**
- 이벤트 참여 처리
- 중복 참여 체크
- 참여자 ID 생성
- Kafka 이벤트 발행
- 참여자 목록/상세 조회
end note

note bottom of WinnerDrawService
**핵심 비즈니스 로직**
- 당첨자 추첨 실행
- 가중치 추첨 풀 생성
- 추첨 로그 저장
- 당첨자 목록 조회
end note

note bottom of Participant
**도메인 엔티티**
- 참여자 정보 관리
- 중복 방지 (eventId + phoneNumber)
- 매장 방문 보너스 (5배 응모권)
- 당첨자 상태 관리
end note

note bottom of DrawLog
**도메인 엔티티**
- 추첨 이력 관리
- 재추첨 방지
- 추첨 알고리즘 기록
end note

@enduml
