# bajahaw/ollamapy-ocr architecture

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

- Interactive diagram: https://gitdiagram.com/bajahaw/ollamapy-ocr
- Repository: https://github.com/bajahaw/ollamapy-ocr

## Overview

##### Main Components
a. GUI Layer (Frontend) – Represented by the main Python entry point (main.py) that hosts the graphical user interface. This component is responsible for user interactions such as image selection and displaying processed text.
b. OCR Service Integration – Create a single, unified component labelled “External OCR Service” that abstracts away both the ollama API and groq service. Since the instruction is to merge these external OCR services, don't show them as separate components.
d. (Optional) Data Flow/Processing – You could indicate an “Image Preprocessor” step if there’s any image handling before sending data out; however, given the simplicity, this might simply be part of the business logic.

##### Relationships and Interactions
- The GUI component handles user input (image selection) and sends the image data to the Business Logic layer.
- Finally, the processed (extracted) textual information is returned from the External OCR Service back to the Business Logic and then rendered in the GUI.

##### Architectural Patterns and Design Principles
- Separation of Concerns: Clearly differentiate the UI from the processing/business logic.
- Abstraction: The external services (ollama and groq) are abstracted as a single “External OCR Service,” following your instruction to merge them.

##### Relevant Technologies
- Python is the primary technology.
- The GUI framework (if it’s a common one like Tkinter, PyQT, etc.) could be noted if known. Even if not explicitly stated, a general “Python GUI Library” might be labeled.
- The external OCR services (ollama API and groq) are abstracted into one component, so simply list “External OCR Service (ollama API/groq)” as one entity.

## Diagram (Mermaid)

```mermaid
flowchart TD 
    subgraph "Application Flow"
        UI["User Interface (GUI)"]:::gui
        BL["Business Logic / Controller"]:::logic
        OCR["External OCR Service (ollama API/groq)"]:::external
    end

    UI -->|"sendsImage"| BL
    BL -->|"requestsOCR"| OCR
    OCR -->|"returnsText"| BL
    BL -->|"updatesUI"| UI

    click UI "https://github.com/bajahaw/ollamapy-ocr/blob/master/main.py"
    click BL "https://github.com/bajahaw/ollamapy-ocr/blob/master/main.py"
    click OCR "https://github.com/bajahaw/ollamapy-ocr/blob/master/main.py"

    classDef gui fill:#E0F7FA,stroke:#006064,stroke-width:2px;
    classDef logic fill:#FFF9C4,stroke:#F57F17,stroke-width:2px;
    classDef external fill:#FFCDD2,stroke:#C62828,stroke-width:2px;
```
