@startuml !theme mono title Distribution Service ERD ' Entity 정의 entity "distribution_status" as ds { * id : BIGSERIAL <> -- * event_id : VARCHAR(36) <> * overall_status : VARCHAR(20) * started_at : TIMESTAMP completed_at : TIMESTAMP * created_at : TIMESTAMP * updated_at : TIMESTAMP } entity "channel_status" as cs { * id : BIGSERIAL <> -- * distribution_status_id : BIGINT <> * channel : VARCHAR(20) * status : VARCHAR(20) progress : INTEGER distribution_id : VARCHAR(100) estimated_views : INTEGER * update_timestamp : TIMESTAMP * event_id : VARCHAR(36) impression_schedule : TEXT post_url : VARCHAR(500) post_id : VARCHAR(100) message_id : VARCHAR(100) completed_at : TIMESTAMP error_message : TEXT retries : INTEGER last_retry_at : TIMESTAMP * created_at : TIMESTAMP * updated_at : TIMESTAMP } ' 관계 정의 ds ||--o{ cs : "has" ' 제약 조건 노트 note right of ds **제약 조건** - UK: event_id (이벤트당 하나의 배포) - CHECK: overall_status IN ('IN_PROGRESS', 'COMPLETED', 'FAILED', 'PARTIAL_SUCCESS') **인덱스** - PRIMARY: id - UNIQUE: event_id end note note right of cs **제약 조건** - FK: distribution_status_id REFERENCES distribution_status(id) ON DELETE CASCADE - UK: (distribution_status_id, channel) - CHECK: channel IN ('URIDONGNETV', 'RINGOBIZ', 'GINITV', 'INSTAGRAM', 'NAVER', 'KAKAO') - CHECK: status IN ('PENDING', 'IN_PROGRESS', 'SUCCESS', 'FAILED') - CHECK: progress BETWEEN 0 AND 100 **인덱스** - PRIMARY: id - UNIQUE: (distribution_status_id, channel) - INDEX: event_id - INDEX: (event_id, channel) - INDEX: status end note ' 데이터 설명 note top of ds **배포 상태 테이블** 이벤트별 배포 전체 상태 관리 - 배포 시작/완료 시간 추적 - 전체 배포 성공/실패 상태 end note note top of cs **채널 배포 상태 테이블** 채널별 세부 배포 상태 및 성과 추적 - 6개 채널 독립적 상태 관리 - 진행률, 도달률, 에러 정보 저장 - 재시도 정보 및 외부 시스템 ID 추적 end note ' Redis 캐시 정보 note bottom of ds **Redis 캐시** Key: event:{eventId}:distribution TTL: 1시간 - 배포 상태 실시간 조회 최적화 - DB 부하 감소 end note note bottom of cs **Redis 캐시** Key: distribution:channel:{eventId}:{channel} TTL: 30분 - 채널별 상태 실시간 모니터링 - 진행률 추적 및 업데이트 end note @enduml