# simonbuxx/linkuit-studio architecture

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

- Interactive diagram: https://gitdiagram.com/simonbuxx/linkuit-studio
- Repository: https://github.com/simonbuxx/linkuit-studio

## Overview

##### Main Components
- User Interface (GUI): Represented by the Gui folder (MainWindow, dialogs, pie menus, and other UI elements). Emphasize how the UI facilitates user interaction, such as zooming, panning, and editing the logic circuits.
- Simulation Core: The core engine that interprets and processes the logic circuit definitions. This includes files like CoreLogic.cpp/h and CircuitFileParser.cpp/h as well as RuntimeConfigParser.cpp/h. It’s vital to show how these modules read circuit files/ configurations and hand data off for simulation.
- Component Library: This is a substantial part of the project, with subdirectories for Components segmented by type:
- Complex Logic Components (e.g., DFlipFlop, Counter, JKFlipFlop, and their associated LogicCells subcomponents)
- Gate Components (e.g., AndGate, NotGate, OrGate, along with their LogicCells subclasses)
- Inputs and Outputs (e.g., LogicButton, LogicClock, LogicConstant for inputs; and LogicOutput for outputs)
- Additional miscellaneous components such as ConPoint, LogicWire and TextLabel which visually represent or connect circuit items.
- Undo Module: This module (under the Undo folder) handles the undo/redo functionality that preserves user modifications.
- Helper and Utility Functions: Modules like HelperFunctions.h, HelperStructures.h, and perhaps the style/ and images/ folders that support additional application features.

##### Relationships and Interactions
- Component Interactions: Include connections between the overarching core simulation engine and the specialized component libraries. Illustrate how different component types (gates, inputs, complex logic devices) are integrated into the simulation.
- Undo/Redo Flow: Indicate how changes in the GUI or simulation are tracked by the Undo module, ensuring user actions can be reversed.
- File/Runtime Configuration: Show that CircuitFileParser and RuntimeConfigParser feed configuration data into the simulator, maintaining the state of the circuit and its simulation settings.

##### Architectural Patterns and Design Principles
- Modular Design: The file structure reflects clean separation into domains (GUI, Components, Core Logic, Undo, etc.). Highlight this modularity, which allows independent updates and maintenance.
- MVC-like Separation: Although not strictly following a Model-View-Controller model, the separation between the User Interface (View) and the CoreLogic and Component libraries (Model/Controller) is evident.
- Extensibility: With folders dedicated to different component types and even sub-folders for “LogicCells”, the design supports adding and extending functional elements of logic simulation.
- Qt Framework Integration: Since the project uses Qt (with multiple Qt-related files like .pro and .ui), it is key to mention how Qt underpins both the UI and some backend logic (event handling, resource management).

##### Final Elements
- Every node (component or module) has a clear label.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "User Interface Layer"
        UI["User Interface (GUI)"]:::gui
    end

    subgraph "Simulation Core"
        C["Core Logic Engine"]:::core
        CFP["Circuit File Parser"]:::core
        RCP["Runtime Config Parser"]:::core
    end

    subgraph "Component Library"
        CL["Complex Logic Components"]:::components
        GG["Gate Components"]:::components
        INS["Inputs Components"]:::components
        OUT["Outputs Components"]:::components
        subgraph "Additional Components"
            CP["ConPoint"]:::components
            LW["LogicWire"]:::components
            TL["TextLabel"]:::components
        end
    end

    subgraph "Undo Module"
        UNDO["Undo Module"]:::undo
    end

    subgraph "Helpers & Utilities"
        HF["Helper Functions & Structures"]:::utility
        ST["Style Resources"]:::utility
        IM["Image Resources"]:::utility
    end

    subgraph "QtAwesome Integration"
        QA["QtAwesome Integration"]:::qtawesome
    end

    %% Data Flow Connections
    UI -->|"triggers"| C
    CFP -->|"configData"| C
    RCP -->|"runtimeConfig"| C

    %% Simulation Core invoking Component Library
    C -->|"invokes"| CL
    C -->|"invokes"| GG
    C -->|"invokes"| INS
    C -->|"invokes"| OUT
    C -->|"invokes"| CP
    C -->|"invokes"| LW
    C -->|"invokes"| TL

    %% Undo Flow: capturing UI actions and simulation changes
    UI -->|"userActions"| UNDO
    C -->|"notifies"| UNDO

    %% QtAwesome Integration for UI icons
    UI -->|"usesIcons"| QA

    %% Helper & Utility support (dotted lines)
    HF -.-> UI
    HF -.-> C
    HF -.-> CL
    HF -.-> GG
    HF -.-> INS
    HF -.-> OUT
    ST -.-> HF
    IM -.-> HF

    %% Click Events
    click UI "https://github.com/simonbuxx/linkuit-studio/blob/master/Gui/MainWindow.cpp"
    click C "https://github.com/simonbuxx/linkuit-studio/blob/master/CoreLogic.cpp"
    click CFP "https://github.com/simonbuxx/linkuit-studio/blob/master/CircuitFileParser.cpp"
    click RCP "https://github.com/simonbuxx/linkuit-studio/blob/master/RuntimeConfigParser.cpp"
    click CL "https://github.com/simonbuxx/linkuit-studio/tree/master/Components/ComplexLogic/"
    click GG "https://github.com/simonbuxx/linkuit-studio/tree/master/Components/Gates/"
    click INS "https://github.com/simonbuxx/linkuit-studio/tree/master/Components/Inputs/"
    click OUT "https://github.com/simonbuxx/linkuit-studio/tree/master/Components/Outputs/"
    click CP "https://github.com/simonbuxx/linkuit-studio/blob/master/Components/ConPoint.cpp"
    click LW "https://github.com/simonbuxx/linkuit-studio/blob/master/Components/LogicWire.cpp"
    click TL "https://github.com/simonbuxx/linkuit-studio/blob/master/Components/TextLabel.cpp"
    click UNDO "https://github.com/simonbuxx/linkuit-studio/tree/master/Undo/"
    click HF "https://github.com/simonbuxx/linkuit-studio/blob/master/HelperFunctions.h"
    click ST "https://github.com/simonbuxx/linkuit-studio/tree/master/style/"
    click IM "https://github.com/simonbuxx/linkuit-studio/tree/master/images/"
    click QA "https://github.com/simonbuxx/linkuit-studio/tree/master/QtAwesome/"

    %% Styles
    classDef gui fill:#a2d9f7,stroke:#333,stroke-width:2px;
    classDef core fill:#82e0aa,stroke:#333,stroke-width:2px;
    classDef components fill:#f9e79f,stroke:#333,stroke-width:2px;
    classDef undo fill:#f7dc6f,stroke:#333,stroke-width:2px;
    classDef utility fill:#f5b7b1,stroke:#333,stroke-width:2px;
    classDef qtawesome fill:#c39bd3,stroke:#333,stroke-width:2px;
```
