# imdarkshadow/universityproject architecture

> Architecture diagram of the GitHub repository imdarkshadow/universityproject, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/imdarkshadow/universityproject
- Repository: https://github.com/imdarkshadow/universityproject

## Overview

##### Project Type and Purpose
- The project is a command-line Python tool that automates the process of translating comic chapters. The user copies a comic chapter in zip format into the “files/raw” directory and then runs the main program, which processes the input (via OCR and translation), cleans and post-processes text, and finally produces an output zip.

##### Analyzing the File Structure
- Entry Point:
– main.py: Acts as the primary orchestrator tying together the different processing phases.
- Modular Functionalities:
– ocr.py: Central module that likely manages the OCR process.
– ocrengines/ocr_tesseract.py and ocrengines/ocr_paddle.py: Provide support for multiple OCR engines.
– translation.py and mariantrans.py: Handle text translation, potentially with different translation engines or methods.
– cleanRawText.py: Responsible for cleaning the raw text extracted from comics.
– dominantColor.py: Likely extracts dominant image information, perhaps for background analysis or visual enhancements.
– print.py and printRegional.py: Manage “printing” or formatting tasks tailored to different regional settings or layouts.
– utils.py: Contains supporting utility functions used throughout the project.
- Documentation:
– The “docs” directory contains the Sphinx files (*.rst, conf.py, Makefiles) that document the project’s modules and usage.
- Additional Files:
– requirements.txt, LICENSE, .gitignore, and other config files help define the project’s environment and legal info.

- Main Components (each represented by a clearly labeled module/block):
– Input Handler: Represents the “files/raw” folder where the input zip (comic chapter) is placed.
– Main Orchestrator: The “main.py” module that drives the overall workflow.
– OCR Processing Module: Comprising “ocr.py” and the “ocrengines” directory with both OCR engines (Tesseract and Paddle OCR).
– Text Cleaning Module: Represented by “cleanRawText.py”.
– Translation Module: Formed by “translation.py” and “mariantrans.py”.
– Image/Post-Processing Module: “dominantColor.py” for image analysis.
– Print/Formatting Module: “print.py” and “printRegional.py” for output formatting.
– Utility/Supporting Modules: “utils.py” providing helper functionality.
– Documentation and Configuration: “docs” directory and configuration files (shown as ancillary components for developers).

- Relationships and Interaction Flow:
– The process begins with the Input Handler (comic zip file) and flows to main.py.
– From there, the orchestrator delegates to the OCR Processing Module. Here, the user’s choice (or default selection) between ocr_tesseract and ocr_paddle determines which OCR engine is used.
– The output from OCR is then passed to the Text Cleaning Module (cleanRawText.py) to remove artifacts.
– Cleaned text is routed to the Translation Module which uses either a general translation mechanism (translation.py) or specific Marian translation via mariantrans.py.
– In parallel or subsequently, image properties might be processed through the Image/Post-Processing Module (dominantColor.py) for aesthetic or analysis purposes.
– Finally, the Print/Formatting Module (print.py and printRegional.py) consolidates the data to create the final formatted output.
– End result is packaged (as indicated in the README) into an output zip file.

- Architectural Patterns and Principles:
– The design follows a modular pipeline architecture: discrete modules in charge of individual processing stages.
– The system supports extensibility (e.g., support for multiple OCR and translation engines) by segregating engine-specific logic into separate modules.
– There’s an emphasis on separation of concerns – each Python script/module handles a specific part of the comic translation process.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Nodes
    InputHandler["Input Handler (files/raw)"]:::input
    Main["Main Orchestrator (main.py)"]:::orchestrator
    OCR["OCR Module (ocr.py)"]:::processing
    Tesseract["Tesseract OCR (ocr_tesseract.py)"]:::engine
    Paddle["Paddle OCR (ocr_paddle.py)"]:::engine
    Clean["Clean Text Module (cleanRawText.py)"]:::processing
    Translation["Translation (translation.py)"]:::processing
    Marian["Marian Translation (mariantrans.py)"]:::processing
    ImageAnalysis["Image Analysis Module (dominantColor.py)"]:::processing
    PrintModule["Print/Format Module (print.py & printRegional.py)"]:::processing
    Utils["Utility Module (utils.py)"]:::utility
    Docs["Documentation (docs)"]:::doc

    %% Flow Connections
    InputHandler -->|"ComicZip"| Main
    Main -->|"TriggerOCR"| OCR
    OCR -->|"OCROutput"| Clean
    OCR -->|"UseTesseract"| Tesseract
    OCR -->|"UsePaddle"| Paddle
    Clean -->|"CleanedText"| Translation
    Clean -->|"CleanedText"| Marian
    Translation -->|"TranslatedText"| PrintModule
    Marian -->|"MarianText"| PrintModule
    Main -->|"ExtractImageData"| ImageAnalysis
    ImageAnalysis -->|"ImageFeatures"| PrintModule

    %% Utility (dashed arrows)
    Utils -.-> Main
    Utils -.-> OCR
    Utils -.-> Clean
    Utils -.-> Translation
    Utils -.-> Marian
    Utils -.-> ImageAnalysis
    Utils -.-> PrintModule

    %% Styles
    classDef input fill:#a2d9ce,stroke:#1abc9c,stroke-width:2px;
    classDef orchestrator fill:#f7dc6f,stroke:#f1c40f,stroke-width:2px;
    classDef processing fill:#aed6f1,stroke:#3498db,stroke-width:2px;
    classDef engine fill:#d7bde2,stroke:#9b59b6,stroke-width:2px;
    classDef utility fill:#f9e79f,stroke:#f4d03f,stroke-width:2px;
    classDef doc fill:#d5f5e3,stroke:#28b463,stroke-width:2px;

    %% Click Events
    click InputHandler "https://github.com/imdarkshadow/universityproject/tree/main/files/raw"
    click Main "https://github.com/imdarkshadow/universityproject/blob/main/main.py"
    click OCR "https://github.com/imdarkshadow/universityproject/blob/main/ocr.py"
    click Tesseract "https://github.com/imdarkshadow/universityproject/blob/main/ocrengines/ocr_tesseract.py"
    click Paddle "https://github.com/imdarkshadow/universityproject/blob/main/ocrengines/ocr_paddle.py"
    click Clean "https://github.com/imdarkshadow/universityproject/blob/main/cleanRawText.py"
    click Translation "https://github.com/imdarkshadow/universityproject/blob/main/translation.py"
    click Marian "https://github.com/imdarkshadow/universityproject/blob/main/mariantrans.py"
    click ImageAnalysis "https://github.com/imdarkshadow/universityproject/blob/main/dominantColor.py"
    click PrintModule "https://github.com/imdarkshadow/universityproject/blob/main/print.py"
    click Utils "https://github.com/imdarkshadow/universityproject/blob/main/utils.py"
    click Docs "https://github.com/imdarkshadow/universityproject/tree/main/docs"
```
