# 1chooo/uml-editor architecture

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

- Interactive diagram: https://gitdiagram.com/1chooo/uml-editor
- Repository: https://github.com/1chooo/uml-editor

## Overview

##### Project Type and Purpose
- The project is a GUI-based UML editor.

##### Analysis of the File Structure
- Top-level directories:
- "src" contains all the source code including the entry point (Main.java).
- "scripts" are for automation (clean, run), and the ".github" folder handles CI workflows.
- Within src:
- "components" (Canvas.java, MenuBar.java, SidePanel.java) form the primary UI elements.
- "views" (UMLEditor.java) likely brings the components together in a main editing window.
- "listener" (MenuBarListener.java) manages UI events.
- "modes" (CreateLineMode, CreateShapeMode, SelectMode, etc.) indicate support for varied interaction modes.
- "utils" includes configuration and helper classes, which likely provide shared services and constants (like configuration settings, warnings, renaming objects, etc.).

##### Architectural Breakdown
a. Core Application Entry:
- Main.java starts the application.
- UMLEditor (in src/views) composes the UI.
b. Presentation/UI Components:
- Canvas, MenuBar, and SidePanel (from src/components) represent the view layer.
- These components are arranged and managed by UMLEditor.
c. Interaction and Event Handling:
- The MenuBarListener (from src/listener) captures UI events (menu actions) and dispatches them to the appropriate mode.
d. Modes and Operations:
- Different modes (SelectMode, CreateLineMode, CreateShapeMode) represent distinct user interactions.
- They determine how user inputs translate into modifications on the canvas.
f. Utility and Configuration:
- Utility classes (in src/utils) provide shared constants, helper functions, and configuration settings that support the other modules.

##### Relationships and Interactions
- The Main.java file initializes the system by launching the UMLEditor.
- UMLEditor composes the UI by creating and organizing components (Canvas, MenuBar, SidePanel).
- User actions in the UI trigger events captured by MenuBarListener; these events then switch the application mode.
- Util classes provide fallback services like configuration settings and error/warning handling throughout the application's interactions.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Application Entry
    subgraph "Application Entry"
        Main["Main.java"]:::entry
    end

    %% User Interface (UI)
    subgraph "User Interface (UI)"
        UMLEd["UMLEditor"]:::ui
        Canvas["Canvas"]:::ui
        MenuBar["MenuBar"]:::ui
        SidePanel["SidePanel"]:::ui
    end

    %% Event Handling
    subgraph "Event Handling"
        MBL["MenuBarListener"]:::event
    end

    %% Modes and Operations
    subgraph "Modes"
        ModeInt["Mode Interface"]:::mode
        SelectM["SelectMode"]:::mode
        CreateShapeM["CreateShapeMode"]:::mode
        CreateLineM["CreateLineMode"]:::mode
    end

    %% Domain Model (UML Shapes)
    subgraph "Domain Model (UML Shapes)"
        Basic["BasicObject"]:::domain
        ClassObj["ClassObject"]:::domain
        UseCaseObj["UseCaseObject"]:::domain
        Assoc["AssociationLine"]:::domain
        Comp["CompositionLine"]:::domain
        Gen["GeneralizationLine"]:::domain
        Lnode["Line"]:::domain
        PortNode["Port"]:::domain
        ShapeNode["Shape"]:::domain
        GroupNode["Group"]:::domain
    end

    %% Utilities and Configuration
    subgraph "Utilities/Config"
        Config["CONFIG"]:::utils
        Helper["HELPER"]:::utils
        ModesUtil["MODES"]:::utils
        RenameObj["RenameObject"]:::utils
        WarningUtil["Warning"]:::utils
    end

    %% Connections between layers
    Main -->|"launches"| UMLEd
    UMLEd -->|"contains"| Canvas
    UMLEd -->|"contains"| MenuBar
    UMLEd -->|"contains"| SidePanel
    MenuBar -->|"triggers"| MBL
    MBL -->|"selects"| ModeInt
    ModeInt -->|"implements"| SelectM
    ModeInt -->|"implements"| CreateShapeM
    ModeInt -->|"implements"| CreateLineM

    %% Modes interacting with Domain Model
    SelectM -->|"updates"| ClassObj
    CreateShapeM -->|"creates"| Basic
    CreateLineM -->|"draws"| Assoc
    %% Additional domain updates
    SelectM -->|"manages"| UseCaseObj
    CreateLineM -->|"draws"| Gen

    %% Domain Model renders on UI
    Basic -->|"renders on"| Canvas
    ClassObj -->|"renders on"| Canvas
    UseCaseObj -->|"renders on"| Canvas
    Assoc -->|"renders on"| Canvas
    Comp -->|"renders on"| Canvas
    Gen -->|"renders on"| Canvas
    Lnode -->|"renders on"| Canvas
    PortNode -->|"renders on"| Canvas
    ShapeNode -->|"renders on"| Canvas
    GroupNode -->|"renders on"| Canvas

    %% Utilities supporting Modes and Domain
    Config -->|"configures"| CreateShapeM
    Helper -->|"assists"| SelectM
    ModesUtil -->|"defines"| ModeInt
    RenameObj -->|"renames"| ClassObj
    WarningUtil -->|"alerts"| SelectM

    %% Styles
    classDef entry fill:#87CEFA,stroke:#000,stroke-width:1px;
    classDef ui fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef event fill:#90EE90,stroke:#000,stroke-width:1px;
    classDef mode fill:#DDA0DD,stroke:#000,stroke-width:1px;
    classDef domain fill:#FFA500,stroke:#000,stroke-width:1px;
    classDef utils fill:#D3D3D3,stroke:#000,stroke-width:1px;

    %% Click Events
    click Main "https://github.com/1chooo/uml-editor/blob/main/src/Main.java"
    click UMLEd "https://github.com/1chooo/uml-editor/blob/main/src/views/UMLEditor.java"
    click Canvas "https://github.com/1chooo/uml-editor/blob/main/src/components/Canvas.java"
    click MenuBar "https://github.com/1chooo/uml-editor/blob/main/src/components/MenuBar.java"
    click SidePanel "https://github.com/1chooo/uml-editor/blob/main/src/components/SidePanel.java"
    click MBL "https://github.com/1chooo/uml-editor/blob/main/src/listener/MenuBarListener.java"
    click ModeInt "https://github.com/1chooo/uml-editor/blob/main/src/modes/Mode.java"
    click SelectM "https://github.com/1chooo/uml-editor/blob/main/src/modes/SelectMode.java"
    click CreateShapeM "https://github.com/1chooo/uml-editor/blob/main/src/modes/CreateShapeMode.java"
    click CreateLineM "https://github.com/1chooo/uml-editor/blob/main/src/modes/CreateLineMode.java"
    click Basic "https://github.com/1chooo/uml-editor/blob/main/src/shapes/BasicObject.java"
    click ClassObj "https://github.com/1chooo/uml-editor/blob/main/src/shapes/ClassObject.java"
    click UseCaseObj "https://github.com/1chooo/uml-editor/blob/main/src/shapes/UseCaseObject.java"
    click Assoc "https://github.com/1chooo/uml-editor/blob/main/src/shapes/AssociationLine.java"
    click Comp "https://github.com/1chooo/uml-editor/blob/main/src/shapes/CompositionLine.java"
    click Gen "https://github.com/1chooo/uml-editor/blob/main/src/shapes/GeneralizationLine.java"
    click Lnode "https://github.com/1chooo/uml-editor/blob/main/src/shapes/Line.java"
    click PortNode "https://github.com/1chooo/uml-editor/blob/main/src/shapes/Port.java"
    click ShapeNode "https://github.com/1chooo/uml-editor/blob/main/src/shapes/Shape.java"
    click GroupNode "https://github.com/1chooo/uml-editor/blob/main/src/shapes/Group.java"
    click Config "https://github.com/1chooo/uml-editor/blob/main/src/utils/CONFIG.java"
    click Helper "https://github.com/1chooo/uml-editor/blob/main/src/utils/HELPER.java"
    click ModesUtil "https://github.com/1chooo/uml-editor/blob/main/src/utils/MODES.java"
    click RenameObj "https://github.com/1chooo/uml-editor/blob/main/src/utils/RenameObject.java"
    click WarningUtil "https://github.com/1chooo/uml-editor/blob/main/src/utils/Warning.java"
```
