# ogkalu2/comic-translate architecture

> Architecture diagram of the GitHub repository ogkalu2/comic-translate, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ogkalu2/comic-translate
- Repository: https://github.com/ogkalu2/comic-translate

## Overview

##### Component Relationships

- Data flow between pipeline components
- API calls to external services
- File system interactions for input/output
- User interaction flows

##### Specific Implementation Details

Technical annotations for:
- AI Models used (YOLOv8, LAMA, etc.)
- Supported languages
- File format handling
- Threading model (thread_worker.py)

##### Key Elements to Highlight

a) Input Processing:
- Comic file handling (CBR, image files)
- Multi-language support
- Image preprocessing

b) Processing Pipeline:
- Speech bubble detection
- Text segmentation
- OCR processing
- Text cleaning/inpainting
- Translation processing
- Text rendering

c) Output Generation:
- Rendered text placement
- Image export
- Preview functionality

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph UI["Frontend Layer"]
        MW["Main Window"]
        CC["Canvas Components"]
        SI["Settings Interface"]
        UW["UI Widgets"]
    end

    subgraph CTRL["Controller Layer"]
        MC["Main Controller"]
        TW["Thread Worker"]
    end

    subgraph PIPE["Core Processing Pipeline"]
        direction TB
        TD["Text Detection"]
        OCR["OCR Processing"]
        INP["Inpainting"]
        TR["Translation"]
        RND["Text Rendering"]
        TD --> OCR
        OCR --> INP
        INP --> TR
        TR --> RND
    end

    subgraph PM["Project Management"]
        PS["Project State"]
        PAR["Parsers"]
    end

    subgraph UTIL["Utility Components"]
        FH["File Handler"]
        AM["Archive Manager"]
        PU["Pipeline Utils"]
        TB["Text Block Processing"]
        TU["Translation Utils"]
    end

    subgraph EXT["External Services"]
        GPT["OpenAI GPT"]
        GCV["Google Cloud Vision"]
        AZV["Microsoft Azure Vision"]
        DPL["DeepL"]
    end

    subgraph STORE["Model Storage"]
        DM["Detection Models"]
        IM["Inpainting Models"]
        OM["OCR Models"]
    end

    UI --> CTRL
    CTRL --> PIPE
    CTRL --> PM
    PIPE --> UTIL
    PIPE --> EXT
    PIPE --> STORE

    %% Click Events
    click MW "https://github.com/ogkalu2/comic-translate/blob/main/app/ui/main_window.py"
    click CC "https://github.com/ogkalu2/comic-translate/tree/main/app/ui/canvas/"
    click SI "https://github.com/ogkalu2/comic-translate/tree/main/app/ui/settings/"
    click UW "https://github.com/ogkalu2/comic-translate/tree/main/app/ui/dayu_widgets/"
    click MC "https://github.com/ogkalu2/comic-translate/blob/main/controller.py"
    click TW "https://github.com/ogkalu2/comic-translate/blob/main/app/thread_worker.py"
    click TD "https://github.com/ogkalu2/comic-translate/blob/main/modules/detection.py"
    click OCR "https://github.com/ogkalu2/comic-translate/tree/main/modules/ocr/"
    click INP "https://github.com/ogkalu2/comic-translate/tree/main/modules/inpainting/"
    click TR "https://github.com/ogkalu2/comic-translate/blob/main/modules/translator.py"
    click RND "https://github.com/ogkalu2/comic-translate/tree/main/modules/rendering/"
    click PS "https://github.com/ogkalu2/comic-translate/blob/main/app/projects/project_state.py"
    click PAR "https://github.com/ogkalu2/comic-translate/blob/main/app/projects/parsers.py"
    click FH "https://github.com/ogkalu2/comic-translate/blob/main/modules/utils/file_handler.py"
    click AM "https://github.com/ogkalu2/comic-translate/blob/main/modules/utils/archives.py"
    click PU "https://github.com/ogkalu2/comic-translate/blob/main/modules/utils/pipeline_utils.py"
    click TB "https://github.com/ogkalu2/comic-translate/blob/main/modules/utils/textblock.py"
    click TU "https://github.com/ogkalu2/comic-translate/blob/main/modules/utils/translator_utils.py"
    click DM "https://github.com/ogkalu2/comic-translate/tree/main/models/detection/"
    click IM "https://github.com/ogkalu2/comic-translate/tree/main/models/inpainting/"
    click OM "https://github.com/ogkalu2/comic-translate/tree/main/models/ocr/"

    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef controller fill:#2ecc71,stroke:#27ae60,color:white
    classDef pipeline fill:#e74c3c,stroke:#c0392b,color:white
    classDef external fill:#f1c40f,stroke:#f39c12,color:black
    classDef storage fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef utils fill:#9b59b6,stroke:#8e44ad,color:white
    classDef project fill:#1abc9c,stroke:#16a085,color:white

    class MW,CC,SI,UW frontend
    class MC,TW controller
    class TD,OCR,INP,TR,RND pipeline
    class GPT,GCV,AZV,DPL external
    class DM,IM,OM storage
    class FH,AM,PU,TB,TU utils
    class PS,PAR project
```
