# iansan5653/open-mcr architecture

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

- Interactive diagram: https://gitdiagram.com/iansan5653/open-mcr
- Repository: https://github.com/iansan5653/open-mcr

## Overview

- User Interface Layer – Since there are separate entry points for both CLI (src/main.py) and GUI (src/main_gui.py), this should be depicted as a single “User Interface” layer with branches for CLI and GUI.
- Utility Modules – Modules including file_handling.py, list_utils.py, str_utils.py, geometry_utils.py, and data_exporting.py provide essential utilities and helper functions. Represent these as a “Utility Library” that supports the Core Processing.
- Assets and Resources – The assets folder (with the multiple choice sheets and manual) and test directories (with various test cases simulating multiple exam variants) should be shown as data sources and testing frameworks that validate the system during development.
- External Dependencies – Include external libraries (e.g., OpenCV for image manipulation, Tkinter for the GUI, and possibly NumPy) and represent them as blocks illustrating integration points with the core modules.

##### Out Relationships and Data Flows
- Processing Flow – Show a pipeline where input data (such as scanned exam sheets) is received, preprocessed (using image_utils.py, grid_reading.py, etc.), then processed (corner_finding.py, math_utils.py, scoring.py, etc.), and finally output is generated or exported (data_exporting.py, file_handling.py).

##### Architectural Patterns and Design Principles
- Modular Design – Highlight that the project is split into several modular components (each module in the src directory handles a dedicated responsibility).
- Separation of Concerns – Emphasize the clear separation between user interface concerns, core processing logic, and utility functions.
- Test-Driven/Integration Approach – Indicate that there is an extensive setup for end-to-end tests (as seen in the test/end-to-end directory) which validates various scenarios (e.g., 150q, 75q variants, low resolution, rotation, etc.).

##### Additional Details
- If desired, add notes on how installation and deployment flow (like Windows executable installation vs. Running from Source) affect the usage scenario of the system.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interface Layer
    subgraph "User Interface Layer"
        CLI["CLI (Command Line Interface)"]
        GUI["GUI (Graphical User Interface)"]
    end

    %% UI Support Module
    subgraph "UI Support Module"
        UIS["UI Support Module"]
    end

    %% Core Processing Modules
    subgraph "Core Processing Modules"
        P1["Process Input"]
        P2["Image Processing"]
        P3["Grid Reading"]
        P4["Corner Finding"]
        P5["Math Utilities"]
        P6["Scoring"]
        P7["Additional Processing"]
    end

    %% Utility Library
    subgraph "Utility Library"
        U1["File Handling"]
        U2["List Utilities"]
        U3["String Utilities"]
        U4["Geometry Utilities"]
        U5["Data Exporting"]
    end

    %% Assets & Resources
    subgraph "Assets & Resources"
        A1["Assets & Exam Sheets"]
        A2["Test Suite"]
    end

    %% External Dependencies
    Ext["External Libraries (OpenCV, Tkinter, NumPy)"]

    %% Connections from UI to Core Processing and UI Support
    CLI -->|"invokes"| P1
    GUI -->|"invokes"| P1
    CLI -->|"supports"| UIS
    GUI -->|"supports"| UIS

    %% Core Processing Pipeline
    P1 -->|"preprocesses"| P2
    P2 -->|"analyzes"| P3
    P3 -->|"detects"| P4
    P4 -->|"computes"| P5
    P5 -->|"scores"| P6
    P1 -->|"parallel"| P7
    P7 -->|"integrates"| P6

    %% Core Modules Using Utility Library
    P1 -->|"uses"| U1
    P3 -->|"processes"| U2
    P5 -->|"formats"| U3
    P4 -->|"calculates"| U4
    P6 -->|"exports"| U5

    %% External Dependencies
    GUI -->|"uses"| Ext
    P2 -->|"leverages"| Ext
    P3 -->|"leverages"| Ext
    P4 -->|"leverages"| Ext
    P5 -->|"leverages"| Ext
    P6 -->|"leverages"| Ext

    %% Assets & Resources feeding into Core Processing
    A1 -->|"providesData"| P1
    A2 -->|"validates"| P1

    %% Styles
    classDef ui fill:#f9c74f,stroke:#333,stroke-width:2px;
    classDef uiSupport fill:#9d4edd,stroke:#333,stroke-width:2px;
    classDef core fill:#90be6d,stroke:#333,stroke-width:2px;
    classDef util fill:#f94144,stroke:#333,stroke-width:2px;
    classDef assets fill:#f3722c,stroke:#333,stroke-width:2px;
    classDef ext fill:#277da1,stroke:#333,stroke-width:2px;

    class CLI,GUI ui;
    class UIS uiSupport;
    class P1,P2,P3,P4,P5,P6,P7 core;
    class U1,U2,U3,U4,U5 util;
    class A1,A2 assets;
    class Ext ext;

    %% Click Events for Component Mapping
    click CLI "https://github.com/iansan5653/open-mcr/blob/master/src/main.py"
    click GUI "https://github.com/iansan5653/open-mcr/blob/master/src/main_gui.py"
    click P1 "https://github.com/iansan5653/open-mcr/blob/master/src/process_input.py"
    click P2 "https://github.com/iansan5653/open-mcr/blob/master/src/image_utils.py"
    click P3 "https://github.com/iansan5653/open-mcr/blob/master/src/grid_reading.py"
    click P4 "https://github.com/iansan5653/open-mcr/blob/master/src/corner_finding.py"
    click P5 "https://github.com/iansan5653/open-mcr/blob/master/src/math_utils.py"
    click P6 "https://github.com/iansan5653/open-mcr/blob/master/src/scoring.py"
    click P7 "https://github.com/iansan5653/open-mcr/blob/master/src/mcta_processing.py"
    click U1 "https://github.com/iansan5653/open-mcr/blob/master/src/file_handling.py"
    click U2 "https://github.com/iansan5653/open-mcr/blob/master/src/list_utils.py"
    click U3 "https://github.com/iansan5653/open-mcr/blob/master/src/str_utils.py"
    click U4 "https://github.com/iansan5653/open-mcr/blob/master/src/geometry_utils.py"
    click U5 "https://github.com/iansan5653/open-mcr/blob/master/src/data_exporting.py"
    click A1 "https://github.com/iansan5653/open-mcr/tree/master/src/assets/"
    click A2 "https://github.com/iansan5653/open-mcr/tree/master/test/end-to-end/"
    click UIS "https://github.com/iansan5653/open-mcr/blob/master/src/user_interface.py"
```
