# nuix/ocr-candidates architecture

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

- Interactive diagram: https://gitdiagram.com/nuix/ocr-candidates
- Repository: https://github.com/nuix/ocr-candidates

## Overview

##### Project type and purpose
- This is not a multi‐tier web app but a single Ruby script that plugs into the Nuix forensics/review platform. Its sole purpose is to identify “OCR candidates” within a Nuix case—documents that may need OCR—based on word counts, image sizes, and empty pages.

##### File structure
- Top-level:
- .gitignore, LICENSE-2.0.txt, README.md – standard repo files
- Ruby/
– OCR Processing (OCR Candidate identification).rb – the only functional component, a Nuix script.
- There are no separate “frontend” or “backend” folders; this is a single plugin module.

##### README for insights
- Confirms the script runs inside Nuix 8.8+
- Describes UI invocation (“Scripts → OCR Processing”)
- Outlines output: a tag hierarchy for various thresholds (image size, page word-counts, “must” empty docs)

##### Main components and their interactions
a. Components:
1. Nuix Application Host (Nuix Desktop/Engine)
2. Ruby Script Plugin (“OCR Processing”)
3. Nuix API / SDK
4. Data Source (Nuix Case with documents)
5. UI Dialog (parameter collection)
6. Tag Store / Metadata Repository (within the case)
b. Relationships & data flow:
– User launches Nuix → selects the “OCR Processing” script.
– The script presents a UI dialog to gather thresholds.
– After confirmation, the script calls Nuix APIs to iterate over case items, measuring word counts per page, image sizes, or empty pages.
– Based on configured boundaries, the script writes tags back into the case’s metadata store.
c. Architectural patterns
– Plugin architecture: the Ruby script is dynamically loaded into the Nuix host.
– Event‐driven UI: user action triggers processing.
– Layering:
- UI layer (dialog parameters)
- Processing layer (metrics computation)
- Persistence layer (tagging via API)
d. Key technologies
– Ruby language
– Nuix Scripting API/SDK
– Nuix case file system and metadata tagging

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Users and Environment
    User["User"]:::external
    subgraph "Nuix Host (Nuix Desktop/Engine)" 
        style NuixHost fill:#cce5ff,stroke:#333,stroke-width:1px
        subgraph "OCR Processing Plugin" 
            style Plugin fill:#fff2cc,stroke:#333,stroke-width:1px
            UI["UI Layer\n(parameter dialog)"]:::plugin
            Proc["Processing Layer\n(word-count & image-size)"]:::process
            Persist["Persistence Layer\n(tag writing via API)"]:::plugin
        end
    end

    %% Data Storage
    Case["Nuix Case (Documents)"]:::storage
    Tags["Tag Store\n(metadata repository)"]:::storage

    %% Documentation
    subgraph "Project Documentation & Config"
        README["README.md"]:::docs
        LICENSE["LICENSE-2.0.txt"]:::docs
        GITIGNORE[".gitignore"]:::docs
    end

    %% Connections
    User -->|"launches script"| UI
    UI -->|"collect thresholds"| Proc
    Proc -->|"read items via Nuix API"| Case
    Proc -->|"compute metrics"| Proc
    Proc -->|"write tags via Nuix API"| Tags

    %% Click Events
    click UI "https://github.com/nuix/ocr-candidates/blob/master/Ruby/OCR Processing (OCR Candidate identification).rb"
    click Proc "https://github.com/nuix/ocr-candidates/blob/master/Ruby/OCR Processing (OCR Candidate identification).rb"
    click Persist "https://github.com/nuix/ocr-candidates/blob/master/Ruby/OCR Processing (OCR Candidate identification).rb"
    click README "https://github.com/nuix/ocr-candidates/blob/master/README.md"
    click LICENSE "https://github.com/nuix/ocr-candidates/blob/master/LICENSE-2.0.txt"
    click GITIGNORE "https://github.com/nuix/ocr-candidates/blob/master/.gitignore"

    %% Styles
    classDef external fill:#ffffff,stroke:#000,stroke-width:1px
    classDef host fill:#cce5ff
    classDef plugin fill:#fff2cc,stroke:#333,stroke-width:1px
    classDef process fill:#d4edda,stroke:#333,stroke-width:1px
    classDef storage fill:#e0e0e0,stroke:#666
    classDef docs fill:#f0f0f0,stroke:#999,stroke-dasharray: 2 2
```
