# lexteamz/linjector architecture

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

- Interactive diagram: https://gitdiagram.com/lexteamz/linjector
- Repository: https://github.com/lexteamz/linjector

## Overview

##### Project Type & Purpose
- LInjector is an open-source Lua script executor and editor built for developers.
- It uses the Windows Presentation Foundation (WPF) for its UI, written in C# with .NET Framework 4.8.
- The project integrates a robust code editor (using the Monaco editor), and includes multiple functionalities for script execution, notifications, configuration management, and DLL interfacing.
- Its purpose is to provide a secure, modular, and customizable Lua script execution environment, emphasizing transparency and ease of development.

##### Analyzing the File Structure
- The root includes solution files (LInjector.sln) and common Git and license artifacts.
- Inside the LInjector folder:
– Subdirectories like Classes, Pages, Windows, and Resources indicate a layered structure.
– The Classes folder contains core backend components like:
▪ ConfigHandler.cs – for configuration management.
▪ DLLInterface.cs – handling DLL integrations.
▪ MonacoInterfacer.cs – likely facilitating interaction with the Monaco code editor.
▪ RPCManager.cs, WebSocket.cs – indicating internal/external communication channels.
▪ Additional utility features such as notifications, theme management, and updater functionalities.
– The Pages and Popups directories represent the view layer with WPF XAML files that manage UI components.
– The Windows folder contains primary window definitions (MainWindow, SplashScreen) that are central to the WPF application.
- The Redistributables folder provides pre-built scripts and modules that the application might load or reference at runtime.

##### Main Components & Their Relationships
- Presentation/UI Layer:
▪ Windows: MainWindow, SplashScreen — serve as the primary UI containers.
▪ Pages & Popups: These include dynamic interface elements like the MainView and context menus, highlighting user interactions.
▪ Monaco Editor Integration: Via MonacoInterfacer.cs, this component embeds a powerful code editor (using the Monaco Editor library).
- Business Logic/Functional Layer:
▪ Core Classes: ConfigHandler, DLLInterface, FunctionWatch, Themes, Updater – which handle configuration, DLL interactions, monitoring functionalities, appearance, and update processes.
▪ Communication Modules: RPCManager and WebSocket classes indicate mechanisms for data exchange, perhaps for remote control or real-time updates.
▪ Notification and Console Management: These classes manage user feedback, logging, and interactive messages.
- Resource Management:
▪ Redistributables: Include modules, pinned scripts, and additional Lua resources required for execution.

##### Architectural Patterns & Design Principles
- Separation of concerns: Interface (UI components), business logic (classes handling operations), and resource/configuration management are all well separated.
- Modular design: Each class and directory encapsulates related functionality (for instance, all configuration-related logic is grouped in ConfigHandler.cs).
- Extensibility: The design allows updates (via Updater.cs) and integration with external libraries (DLLInterface, Monaco Editor) while exposing extension points.
- Use of declarative UI: WPF with separate XAML files supports MVVM-like (or at least layered) design patterns.

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% UI Layer
    subgraph "UI Layer"
        UI1["MainWindow (UI)"]:::ui
        UI2["SplashScreen (UI)"]:::ui
        UI3["MainView (UI)"]:::ui
        UI4["TabSystem (UI)"]:::ui
        UI5["InputText (UI)"]:::ui
        UI6["LIContextMenuStrip (UI)"]:::ui
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        BL1["ConfigHandler (Logic)"]:::logic
        BL2["DLLInterface (Logic)"]:::logic
        BL3["MonacoInterfacer (Editor)"]:::logic
        BL4["FunctionWatch (Logic)"]:::logic
        BL5["Themes (Logic)"]:::logic
        BL6["Updater (Logic)"]:::logic
    end

    %% Communication Modules
    subgraph "Communication Modules"
        CM1["RPCManager (Comm)"]:::comm
        CM2["WebSocket (Comm)"]:::comm
    end

    %% Notification & Console Management
    subgraph "Notification & Console Management"
        NC1["Notifications (Logic)"]:::logic
        NC2["ConsoleManager (Logic)"]:::logic
    end

    %% Resource Management
    subgraph "Resource Management"
        RM1["Icons (Resource)"]:::resource
        RM2["Init.lua (Resource)"]:::resource
        RM3["Pinned_Scripts.json (Resource)"]:::resource
    end

    %% Relationships: UI to UI Navigation
    UI2 -->|"transitions"| UI1
    UI1 -->|"opens"| UI3

    %% Relationships: UI to Business Logic
    UI3 -->|"sendsRequest"| BL1
    UI4 -->|"integrates"| BL3
    UI5 -->|"triggers"| NC1
    UI6 -->|"logsTo"| NC2
    UI1 -->|"loadsIcons"| RM1

    %% Relationships: Business Logic Internal
    BL1 -->|"configures"| BL2
    BL1 -->|"appliesTheme"| BL5
    BL2 -->|"interfacesWith"| CM1
    BL2 -->|"triggersWatch"| BL4
    BL3 -->|"syncsWith"| CM1
    BL3 -->|"loadsScript"| RM2
    BL4 -->|"monitors"| NC1
    BL4 -->|"monitors"| NC2
    BL6 -->|"updatesAssets"| RM3

    %% Relationships: Communication Flow
    CM1 -->|"communicates"| CM2

    %% Click Events for UI Components (Windows)
    click UI1 "https://github.com/lexteamz/linjector/blob/main/LInjector/LInjector/Windows/MainWindow.xaml"
    click UI2 "https://github.com/lexteamz/linjector/blob/main/LInjector/LInjector/Windows/SplashScreen.xaml"

    %% Click Events for UI Components (Pages & Popups)
    click UI3 "https://github.com/lexteamz/linjector/blob/main/LInjector/LInjector/Pages/MainView.xaml"
    click UI4 "https://github.com/lexteamz/linjector/blob/main/LInjector/LInjector/Pages/TabSystem.xaml"
    click UI5 "https://github.com/lexteamz/linjector/blob/main/LInjector/LInjector/Pages/Popups/InputText.xaml"
    click UI6 "https://github.com/lexteamz/linjector/blob/main/LInjector/LInjector/Pages/Popups/LIContextMenuStrip.xaml"

    %% Click Events for Business Logic Components
    click BL1 "https://github.com/lexteamz/linjector/blob/main/LInjector/LInjector/Classes/ConfigHandler.cs"
    click BL2 "https://github.com/lexteamz/linjector/blob/main/LInjector/LInjector/Classes/DLLInterface.cs"
    click BL3 "https://github.com/lexteamz/linjector/blob/main/LInjector/LInjector/Classes/MonacoInterfacer.cs"
    click BL4 "https://github.com/lexteamz/linjector/blob/main/LInjector/LInjector/Classes/FunctionWatch.cs"
    click BL5 "https://github.com/lexteamz/linjector/blob/main/LInjector/LInjector/Classes/Themes.cs"
    click BL6 "https://github.com/lexteamz/linjector/blob/main/LInjector/LInjector/Classes/Updater.cs"

    %% Click Events for Communication Modules
    click CM1 "https://github.com/lexteamz/linjector/blob/main/LInjector/LInjector/Classes/RPCManager.cs"
    click CM2 "https://github.com/lexteamz/linjector/blob/main/LInjector/LInjector/Classes/WebSocket.cs"

    %% Click Events for Notification & Console Management
    click NC1 "https://github.com/lexteamz/linjector/blob/main/LInjector/LInjector/Classes/Notifications.cs"
    click NC2 "https://github.com/lexteamz/linjector/blob/main/LInjector/LInjector/Classes/ConsoleManager.cs"

    %% Click Events for Resource Management
    click RM1 "https://github.com/lexteamz/linjector/tree/main/LInjector/LInjector/Resources/Icons"
    click RM2 "https://github.com/lexteamz/linjector/blob/main/LInjector/LInjector/Resources/Internal/Init.lua"
    click RM3 "https://github.com/lexteamz/linjector/blob/main/Redistributables/Lua Scripts and Redistributables/Pinned_Scripts.json"

    %% Styles
    classDef ui fill:#AED6F1,stroke:#1A5276,stroke-width:2px;
    classDef logic fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef comm fill:#D5F5E3,stroke:#27AE60,stroke-width:2px;
    classDef resource fill:#FADBD8,stroke:#C0392B,stroke-width:2px;
```
