# rapphy243/catching-plagiarists architecture

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

- Interactive diagram: https://gitdiagram.com/rapphy243/catching-plagiarists
- Repository: https://github.com/rapphy243/catching-plagiarists

## Overview

The “Catching Plagiarists” project is a standalone Java application (designed to be used within BlueJ) that implements a solution to the “catching plagiarists” problem. It uses a terminal-based GUI to allow the user to select essays and then detect similarities between essay pairs. In short, the project performs file-based text analysis by reading essays _in situ_ from directories (“Large number of documents”, “Medium number of documents”, “Small number of documents”) and then processing them using several core model classes.

##### Main Components
- User Interface (UI): Represented by CatchingPlagiaristsGUI.java. This is the entry point for the user, handling input and displaying output through a terminal GUI.
- Controller / Orchestration Layer: Although the project is not a full-blown MVC framework, other classes like Parsing.java and Directories.java act as controllers or managers. They handle file system interactions and text parsing.
- Domain Models: The core data model classes include Essay.java, EssayPair.java, EssayGroup.java, and EssayGroupSet.java. These classes encapsulate essay data, represent pairs of essays for comparison, and group essays based on detected similarities.
- Document Repository: The directories “Large number of documents”, “Medium number of documents”, and “Small number of documents” serve as the source for input essays.
- Utility / Config Files: Files such as Directories.java (for file management), Parsing.java (for processing the texts), and even package.bluej (for BlueJ project configurations) support the main functions.

##### Relationships and Component Interactions
- The UI (CatchingPlagiaristsGUI.java) acts as the front end. It sends user commands to the controller layer.
- The controller (via Parsing.java and Directories.java) reads files from the document directories and creates Essay objects.
- The domain model takes these Essay objects and, through EssayPair and EssayGroup classes, performs the plagiarism detection by comparing essays.
- Data flows from the file system (document directories) into the model layer via file reading and parsing logic, then flows back to the UI as the output of analysis.
- Optionally, indicate that the testing class (EssayGroupTester.java) interacts with the core logic to verify correctness.

##### Architectural Patterns and Design Principles
- Model-View Separation: Although not a strict MVC framework, the responsibilities are clearly divided between the UI (view), processing logic (controller), and data models (model).
- Modularity: Each Java class is responsible for a specific piece of functionality (essay representation, file parsing, grouping, etc.), demonstrating good separation of concerns.
- File-Driven Workflow: The design incorporates direct file system access from multiple directories, which should be clearly depicted.

##### Relevant Technologies
- Java (primarily standard libraries for file I/O and terminal GUI)
- BlueJ (as the development environment specified in the README)
- Text file parsing (for the essay text files, with .shtml.txt extensions)

## Diagram (Mermaid)

```mermaid
graph TD
    %% Document Repositories
    subgraph "Document Repositories"
        LDO["Large number of documents"]:::repo
        MDO["Medium number of documents"]:::repo
        SDO["Small number of documents"]:::repo
    end

    %% Controller / Orchestration Layer
    subgraph "Controller / Orchestration"
        DIR["Directories.java"]:::controller
        PAR["Parsing.java"]:::controller
    end

    %% Domain Model Layer
    subgraph "Domain Models"
        E["Essay.java"]:::domain
        EP["EssayPair.java"]:::domain
        EG["EssayGroup.java"]:::domain
        EGS["EssayGroupSet.java"]:::domain
    end

    %% User Interface Layer
    subgraph "User Interface"
        GUI["CatchingPlagiaristsGUI.java"]:::ui
    end

    %% Testing Component
    subgraph "Testing"
        TEST["EssayGroupTester.java"]:::testing
    end

    %% Utility Component
    subgraph "Utilities"
        UBJ["package.bluej"]:::utility
    end

    %% Connections from Document Repositories to Controller Layer
    LDO -->|"reads"| DIR
    MDO -->|"reads"| DIR
    SDO -->|"reads"| DIR
    LDO -->|"provides"| PAR
    MDO -->|"provides"| PAR
    SDO -->|"provides"| PAR

    %% Controller processing to Domain Models
    DIR -->|"managesFiles"| E
    PAR -->|"parsesText"| E

    %% Domain Model interactions
    E -->|"formsPair"| EP
    E -->|"formsGroup"| EG
    EG -->|"aggregates"| EGS

    %% Output to User Interface
    EGS -->|"results"| GUI

    %% User input initiates processing
    GUI -->|"triggersParsing"| PAR
    GUI -->|"triggersFileManagement"| DIR

    %% Testing interaction with Domain Models
    TEST -->|"validatesGroup"| EG

    %% Styling Definitions
    classDef ui fill:#f9e79f,stroke:#cb6a17,stroke-width:2px;
    classDef controller fill:#aed6f1,stroke:#2e86c1,stroke-width:2px;
    classDef domain fill:#a9dfbf,stroke:#27ae60,stroke-width:2px;
    classDef repo fill:#f5b7b1,stroke:#c0392b,stroke-width:2px;
    classDef testing fill:#f9c7c7,stroke:#e74c3c,stroke-width:2px;
    classDef utility fill:#d7bde2,stroke:#8e44ad,stroke-width:2px;

    %% Click Events
    click GUI "https://github.com/rapphy243/catching-plagiarists/blob/main/CatchingPlagiaristsGUI.java"
    click PAR "https://github.com/rapphy243/catching-plagiarists/blob/main/Parsing.java"
    click DIR "https://github.com/rapphy243/catching-plagiarists/blob/main/Directories.java"
    click E "https://github.com/rapphy243/catching-plagiarists/blob/main/Essay.java"
    click EP "https://github.com/rapphy243/catching-plagiarists/blob/main/EssayPair.java"
    click EG "https://github.com/rapphy243/catching-plagiarists/blob/main/EssayGroup.java"
    click EGS "https://github.com/rapphy243/catching-plagiarists/blob/main/EssayGroupSet.java"
    click LDO "https://github.com/rapphy243/catching-plagiarists/tree/main/Large number of documents"
    click MDO "https://github.com/rapphy243/catching-plagiarists/tree/main/Medium number of documents"
    click SDO "https://github.com/rapphy243/catching-plagiarists/tree/main/Small number of documents"
    click TEST "https://github.com/rapphy243/catching-plagiarists/blob/main/EssayGroupTester.java"
    click UBJ "https://github.com/rapphy243/catching-plagiarists/blob/main/package.bluej"
```
