Why Clean Architecture

  • 시스템의 유연성과 유지보수성을 극대화하기 위해 클린 아키텍쳐 선택
  • 비즈니스 로직과 외부 의존성을 명확히 분리하여 각 레이어를 독립적으로 개발하고 테스트
  • 시스템의 확장성과 테스트 용이성을 높여서 지속 개발하기 위한 토대를 구축

1) 아키텍쳐 다이어그램 (Architecture Diagram)

Key Points

  • 전체 시스템 구조 확인
    • 시스템의 주요 레이어 확인 가능
    • UI/CLI/API, Application Layer, Domain Layer, Infrastructure Layer
  • 레이어 간 의존성 확인

Hidden Details

  • 각 레이어 내부의 세부 모듈
  • 데이터 흐름의 상세
    • 데이터가 각 레이어를 통과하면서 어떻게 변환되는지 상세히 표시하지 않음
graph TD
    A[UI/CLI/API] --> B[Application Layer]
    B -->|Use Cases| C[Domain Layer]
    C -->|Entities| D[Infrastructure Layer]

    subgraph Application Layer
        direction TB
        B1[Script Correction]
        B2[Subtitles Addition]
        B3[TTS Synthesis]
        B4[Visual Source Management]
        B5[Video Editing & Merging]
        B6[Final Video Generation]
        B7[YouTube Upload & Metadata]
        B8[Scheduling & Automation]
    end

    subgraph Domain Layer
        direction TB
        C1[Entities]
        C2[Providers]
    end

    subgraph Infrastructure Layer
        direction TB
        D1[Database]
        D2[External APIs]
        D3[Frameworks & Drivers]
        D4[File Handler]
        D5[Cloud Handler]
        D6[Logger]
    end

    B1 --> C1
    B2 --> C1
    B3 --> C1
    B4 --> C1
    B5 --> C1
    B6 --> C1
    B7 --> C1
    B8 --> C1

    C1 --> D1
    C1 --> D2
    C1 --> D3
    C1 --> D4
    C1 --> D5
    C1 --> D6

    C2 --> D2
    C2 --> D3

2) 데이터 흐름 설계 (Sequence Diagram)

Key Points

  • 프로세스 흐름
    • 사용자 입력에서 최종 출력까지의 데이터 흐름을 시각적으로 표현
  • 모듈 간 데이터 전달
    • 각 모듈 간에 데이터가 어떻게 이동하는지 명확히 확인 가능

Hidden Details

  • 데이터 형식
    • 데이터가 각 단계에서 어떤 형식으로 전달되는지 구체적인 설명 없음
  • 에러 처리
    • 각 단계에서 발생할 수 있는 에러와 처리 방법 표현하지 않음
sequenceDiagram
    participant User
    participant UI/CLI/API
    participant Application as Application Layer
    participant Domain as Domain Layer
    participant Infrastructure as Infrastructure Layer

    User ->> UI/CLI/API: Provide script for processing
    UI/CLI/API ->> Application: Start script processing
    Application ->> Domain: Process script (single-step)
    Domain ->> Infrastructure: Call LLM provider (e.g., OpenAI)
    Infrastructure ->> Domain: Return processed script
    Domain ->> Application: Return processed script
    Application ->> UI/CLI/API: Return processed script
    UI/CLI/API ->> User: Display processed script

    User ->> UI/CLI/API: Request TTS for processed script
    UI/CLI/API ->> Application: Start TTS generation
    Application ->> Domain: Synthesize speech
    Domain ->> Infrastructure: Call TTS provider
    Infrastructure ->> Domain: Return synthesized speech
    Domain ->> Application: Return synthesized speech
    Application ->> UI/CLI/API: Return synthesized speech
    UI/CLI/API ->> User: Provide synthesized speech

    User ->> UI/CLI/API: Request subtitles for synthesized speech
    UI/CLI/API ->> Application: Start subtitle generation
    Application ->> Domain: Generate subtitles
    Domain ->> Infrastructure: Call subtitle provider (e.g., AssemblyAI)
    Infrastructure ->> Domain: Return subtitles
    Domain ->> Application: Return subtitles
    Application ->> UI/CLI/API: Return subtitles
    UI/CLI/API ->> User: Provide subtitles

3) 통합 포인트 정의 다이어그램 (Integration Points Diagram)

Key Points

  • 모듈 간의 인터페이스
    • 각 모듈 간의 상호작용 지점을 명확히 확인 가능
  • 데이터 의존성
    • 어떤 모듈이 어떤 데이터를 필요로 하고, 어떤 데이터를 출력하는지 확인 가능

Hidden Details

  • 구체적인 인터페이스 구현
    • 각 인터페이스가 어떻게 구현되는지 (예: 함수 호출, API 형식 등) 구체적인 설명 없음
  • 비동기/동기 처리
    • 데이터 전달이 비동기적으로 이루어지는지 동기적으로 이루어지는지에 대한 설명 없음
graph TB

subgraph Application Layer

B1[Script Correction]

B2[Subtitles Addition]

B3[TTS Synthesis]

B4[Visual Source Management]

B5[Video Editing & Merging]

B6[Final Video Generation]

B7[YouTube Upload & Metadata]

B8[Scheduling & Automation]

end

subgraph Domain Layer

C1[Entities]

C2[Providers]

C1_1[Script Entity]

C1_2[Subtitle Entity]

C1_3[Audio Entity]

C1_4[Visual Source Entity]

C1_5[Video Entity]

C1_6[Schedule Entity]

end

subgraph Infrastructure Layer

D1[Database]

D2[External APIs]

D3[Frameworks & Drivers]

D4[File Handler]

D5[Cloud Handler]

D6[Logger]

D2_1[OpenAI API]

D2_2[AssemblyAI API]

D2_3[Other APIs]

end

  

B1 --> C1

B2 --> C1

B3 --> C1

B4 --> C1

B5 --> C1

B6 --> C1

B7 --> C1

B8 --> C1

  

C1_1 --> C1

C1_2 --> C1

C1_3 --> C1

C1_4 --> C1

C1_5 --> C1

C1_6 --> C1

  

C1 --> D1

C1 --> D2

C1 --> D3

C1 --> D4

C1 --> D5

C1 --> D6

  

D2 --> D2_1

D2 --> D2_2

D2 --> D2_3

C2 --> D2

C2 --> D3

4) 모듈 분할 다이어그램

업데이트 예정

graph TD
    A[Application Layer] --> B1[Script Correction]
    A --> B2[Subtitles Addition]
    A --> B3[TTS Synthesis]
    A --> B4[Visual Source Management]
    A --> B5[Video Editing & Merging]
    A --> B6[Final Video Generation]
    A --> B7[YouTube Upload & Metadata]
    A --> B8[Scheduling & Automation]

    B1 --> C[Domain Layer]
    B2 --> C
    B3 --> C
    B4 --> C
    B5 --> C
    B6 --> C
    B7 --> C
    B8 --> C
    
    C --> D[Infrastructure Layer]

5) Application Layer Diagram

6) Domain Layer Diagram

7) Infrastructure Layer Diagram

디렉토리 구조

주요 파일 설명

  • app/config.py: 설정 파일 로더 모듈
  • app/config.yaml: 설정 파일
  • app/presentation/: 사용자 인터페이스 및 API 모듈
  • app/application/: 주요 애플리케이션 로직 모듈
  • app/domain/: 도메인 엔티티 및 인터페이스 정의
  • app/infrastructure/: 인프라스트럭처 관련 모듈
  • tests/: 테스트 모듈
project-root/
├── app/
   ├── __init__.py
   ├── config.py
   ├── config.yaml
   ├── presentation/
   ├── __init__.py
   ├── api.py
   ├── cli.py
   └── ui.py
   ├── application/
   ├── __init__.py
   ├── final_video_generation.py
   ├── prompt_generator.py
   ├── scheduling_automation.py
   ├── script_correction.py
   ├── subtitles_addition.py
   ├── tts_synthesis.py
   ├── video_editing_merging.py
   ├── visual_source_management.py
   └── youtube_upload.py
   ├── domain/
   ├── __init__.py
   ├── entities/
   ├── __init__.py
   ├── audio.py
   ├── schedule.py
   ├── script.py
   ├── subtitle.py
   ├── video.py
   └── visual_source.py
   ├── providers/
       ├── __init__.py
       ├── llm_provider.py
       ├── subtitle_provider.py
       ├── tts_provider.py
   ├── infrastructure/
   ├── __init__.py
   ├── cloud_handler.py
   ├── database.py
   ├── external_apis/
   ├── __init__.py
   ├── assemblyai_subtitle_provider.py
   ├── llm_provider_selector.py
   ├── ollama_provider.py
   ├── openai_provider.py
   ├── openai_tts_provider.py
   ├── provider_selector.py
   ├── external_apis.py
   ├── file_handler.py
   ├── frameworks_drivers.py
   ├── logger.py
   ├── openai_handler.py
└── tests/
    ├── __init__.py
    ├── test_application/
   └── test_script_correction.py
    ├── test_domain/
    └── test_infrastructure/
        ├── __init__.py
        ├── test_cloud_handler.py
        ├── test_file_handler.py
        └── test_openai_handler.py
├── main.py

참고)

  • 아래의 mermaid.live 사이트 제공 웹 링크와 실제 markdown 중, publishing 하였을 때에 더 가독성이 좋은 방식 테스트 예정

연결 문서