Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Mineru98/bbadd4a9a911c98163232d77f139118e to your computer and use it in GitHub Desktop.
Save Mineru98/bbadd4a9a911c98163232d77f139118e to your computer and use it in GitHub Desktop.
sequenceDiagram
    autonumber
    participant Client as 클라이언트(브라우저)
    participant API as 백엔드 API 서버
    participant DB as 데이터베이스
    participant Storage as 미디어 스토리지
    
    rect rgba(150, 255, 255, 0.1)
        Note over Client, Storage: 콘텐츠 재생 프로세스
        Client->>Client: 재생 버튼 클릭
        
        alt 비로그인 상태
            Client->>Client: 로그인 페이지로 리다이렉트<br>(시청 불가 알림)
        else 로그인 상태
            Client->>API: 콘텐츠 재생 요청<br>(content_id, JWT 토큰)
            
            API->>API: JWT 토큰 검증
            
            alt 토큰 유효
                API->>DB: 콘텐츠 정보 조회<br>(Content 테이블)
                DB-->>API: 콘텐츠 정보 반환<br>(video_url)
                
                API->>DB: 이전 시청 기록 조회<br>(ViewingHistories 테이블)
                DB-->>API: 마지막 시청 위치 반환<br>(last_position)
                
                API-->>Client: 200 OK<br>(스트리밍 URL, 마지막 시청 위치)
                
                Client->>Storage: 비디오 스트림 요청<br>(JWT 토큰 포함)
                Storage-->>Client: 비디오 스트림
                
                Client->>Client: 비디오 플레이어 초기화<br>(마지막 시청 위치부터 재생)
                
                loop 주기적으로 재생 위치 저장 (30초마다)
                    Client->>API: 재생 위치 업데이트<br>(content_id, current_position, JWT 토큰)
                    API->>DB: ViewingHistories 테이블 업데이트/생성<br>(user_id, content_id, last_position, watch_duration)
                    DB-->>API: 업데이트 결과
                    API-->>Client: 200 OK
                end
                
                Client->>Client: 재생 종료<br>(일시정지, 창 닫기 등)
                
                Client->>API: 최종 재생 위치 저장<br>(content_id, final_position, watch_duration, is_completed, JWT 토큰)
                API->>DB: ViewingHistories 테이블 업데이트<br>(last_position, watch_duration, is_completed)
                DB-->>API: 업데이트 결과
                API-->>Client: 200 OK
            else 토큰 무효
                API-->>Client: 401 Unauthorized
                Client->>Client: 로그인 페이지로 리다이렉트
            end
        end
    end
Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment