# thelegendseb/xapps architecture

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

- Interactive diagram: https://gitdiagram.com/thelegendseb/xapps
- Repository: https://github.com/thelegendseb/xapps

## Overview

##### Project Type and Purpose
- XApps is a .NET extension framework (delivered as a DLL) that abstracts a WinForms application into a dynamic, tick-driven graphics and input system.

##### Key Architectural Components
a. Host Application (WinForms)
- Provides UI surface (Form) and event loop.
- Instantiates and drives XApp.
b. Core Framework (src/Base + src/BaseExtensions)
- XApp – entry point, ties into WinForms Form, spawns XSession.
- XBase – base class for any managed object (renderers, physics, UI elements).
c. Graphics Subsystem (src/Graphics)
- Animation & AnimationCollection – timeline‐based motion helpers.
- ControlExtensions (e.g., Slider) – prebuilt UI widgets rendered on the graphics surface.
d. SideClasses Modules (src/SideClasses)
– Networking: XNetServer, XNetNode, XNetTransmitter for building networked applications.
– Other helpers: XInput, XMath, APIManager, Vector – general utilities for any .NET project.

##### Interactions and Data Flow
- The Host Application (Form) → creates an instance of XApp → passes itself (the Form) to XApp constructor.
- The user adds XBase subclasses (e.g., TimeDisplay, custom renderers) to XSession.
- XSession’s game loop (on each tick) → iterates over active XBase instances →
- calls Update(session) if Update flag is set
- SideClasses modules can be injected into XBase subclasses for 3D computations or for network messaging.

##### Architectural Patterns and Principles
- Component-Based Design: XBase acts as a component that can be extended or composed into larger objects.
- Modularity: Core framework is decoupled from SideClasses modules; both are consumer–provider boundaries via interfaces/base classes.

- Rectangle: Host WinForms Form (entry point)
- Rectangle: XApp → XSession
- SideClasses (3D, Networking, Extensions) in another (e.g., green)
- Host Application and external services in neutral gray
d. Labels and Notations:
- Tick rate (e.g., 60 fps) on the XSession loop
- Optional extension points (SetSpeed, SetClearColor, AddObj, QueueRelease)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Host Application
    subgraph "Host Application" 
        direction TB
        Form["WinForms Form"]:::host
        Solution["XApps.sln"]:::host
        Project["XApps.vbproj"]:::host
    end

    %% Core Framework
    subgraph "Core Framework" 
        direction TB
        XApp["XApp"]:::core
        XSession["XSession"]:::core
        XBase["XBase"]:::core
        subgraph "BaseExtensions" 
            direction TB
            Shapes["Shapes"]:::core
            XArt["XArt"]:::core
            XControl["XControl"]:::core
        end
    end

    %% Graphics Subsystem
    subgraph "Graphics Subsystem"
        direction TB
        XWindow["XWindow"]:::graphics
        Animation["Animation"]:::graphics
        AnimCollection["AnimationCollection"]:::graphics
        Slider["ControlExtensions/Slider"]:::graphics
    end

    %% SideClasses Modules
    subgraph "SideClasses"
        direction TB
        subgraph "3D Module"
            direction TB
            DefaultShapes["DefaultShapes"]:::side
            Delaunay["DelaunayTriangulation"]:::side
            Face["Face"]:::side
            Math3D["Math3D"]:::side
            Transform["Transform"]:::side
        end
        subgraph "Networking Module"
            direction TB
            NetNode["XNetNode"]:::side
            NetServer["XNetServer"]:::side
            NetTrans["XNetTransmitter"]:::side
        end
        subgraph "Utilities"
            direction TB
            APIManager["APIManager"]:::side
            XInput["XInput"]:::side
            XMath["XMath"]:::side
            Vector["Vector"]:::side
        end
    end

    %% External Services
    CloudNet("Network Service"):::external

    %% Connections
    Form -->|"init()"| XApp
    XApp -->|"StartLoop()"| XSession
    XSession -->|loop 60fps| XSession
    XSession -->|"Update()/Draw()"| XBase
    XSession -->|"Draw()"| XWindow
    XWindow -->|"Render on"| Form
    XBase -->|"uses 3D APIs"| DefaultShapes
    XBase -->|"uses networking"| NetNode
    XBase -->|"uses utilities"| APIManager
    NetNode -->|"connects to"| CloudNet

    %% Click Events
    click Solution "https://github.com/thelegendseb/xapps/blob/master/XApps.sln"
    click Project "https://github.com/thelegendseb/xapps/blob/master/XApps.vbproj"
    click XApp "https://github.com/thelegendseb/xapps/blob/master/src/Base/XApp.vb"
    click XSession "https://github.com/thelegendseb/xapps/blob/master/src/Base/XSession.vb"
    click XBase "https://github.com/thelegendseb/xapps/blob/master/src/Base/XBase.vb"
    click Shapes "https://github.com/thelegendseb/xapps/blob/master/src/BaseExtensions/Shapes.vb"
    click XArt "https://github.com/thelegendseb/xapps/blob/master/src/BaseExtensions/XArt.vb"
    click XControl "https://github.com/thelegendseb/xapps/blob/master/src/BaseExtensions/XControl.vb"
    click XWindow "https://github.com/thelegendseb/xapps/blob/master/src/Graphics/XWindow.vb"
    click Animation "https://github.com/thelegendseb/xapps/blob/master/src/Graphics/Animation.vb"
    click AnimCollection "https://github.com/thelegendseb/xapps/blob/master/src/Graphics/AnimationCollection.vb"
    click Slider "https://github.com/thelegendseb/xapps/blob/master/src/Graphics/ControlExtensions/Slider.vb"
    click DefaultShapes "https://github.com/thelegendseb/xapps/blob/master/src/SideClasses/3D/DefualtShapes.vb"
    click Delaunay "https://github.com/thelegendseb/xapps/blob/master/src/SideClasses/3D/DelaunayTriangulation.vb"
    click Face "https://github.com/thelegendseb/xapps/blob/master/src/SideClasses/3D/Face.vb"
    click Math3D "https://github.com/thelegendseb/xapps/blob/master/src/SideClasses/3D/Math3D.vb"
    click Transform "https://github.com/thelegendseb/xapps/blob/master/src/SideClasses/3D/Transform.vb"
    click NetNode "https://github.com/thelegendseb/xapps/blob/master/src/SideClasses/Networking/XNetNode.vb"
    click NetServer "https://github.com/thelegendseb/xapps/blob/master/src/SideClasses/Networking/XNetServer.vb"
    click NetTrans "https://github.com/thelegendseb/xapps/blob/master/src/SideClasses/Networking/XNetTransmitter.vb"
    click APIManager "https://github.com/thelegendseb/xapps/blob/master/src/SideClasses/APIManager.vb"
    click XInput "https://github.com/thelegendseb/xapps/blob/master/src/SideClasses/XInput.vb"
    click XMath "https://github.com/thelegendseb/xapps/blob/master/src/SideClasses/XMath.vb"
    click Vector "https://github.com/thelegendseb/xapps/blob/master/src/SideClasses/Vector.vb"

    %% Styles
    classDef host fill:#dddddd,stroke:#888;
    classDef core fill:#a2caff,stroke:#0366d6;
    classDef graphics fill:#ffe599,stroke:#d87f00;
    classDef side fill:#c4e1c1,stroke:#2f7d32;
    classDef external fill:#d3d3d3,stroke:#999999,stroke-dasharray: 4 2;
```
