# babyhamsta/aimmy architecture

> Architecture diagram of the GitHub repository babyhamsta/aimmy, 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/babyhamsta/aimmy
- Repository: https://github.com/babyhamsta/aimmy

## Overview

##### Project Type and Purpose
- Aimmy is a Windows application built with C# using .NET 8 and WPF. It is an AI-based aim alignment mechanism that leverages DirectML, ONNX, and YOLOv8 to assist gamers, particularly those facing physical or visual challenges.
- Its purpose is to provide real-time player detection and adjust the user's mouse position based on AI recognition, plus additional functionalities like configurable anti-recoil, ESP (visual highlighting), and model switching.
- The project also integrates support for training and contributing new AI models.

##### Analyzing the File Structure
- The top-level has the solution file (AimmyWPF.sln) and the main project folder (AimmyWPF) which contains most of the application code.
– Application configuration files (App.config, App.xaml, etc.) that establish the WPF application.
– A collection of C# source files representing models, UI components, animation controllers, and managers (e.g., AIModel.cs, PredictionManager.cs, InputBindingManager.cs, etc.).
– Directories such as “UserController”, “SecondaryWindows”, and “Visualization” that indicate distinct UI modules and components.
- There are additional folders for external resources:
– “configs” for different game configuration files.
– “models” and “Universalv3_web_model” holding ONNX models and binary shards, which support the AI detection mechanism.
- Other assets include fonts, FodyWeavers configuration (indicating use of weaving for aspects), and GitHub CI/CD files.

##### Using README for Architectural Details
- The README clearly explains the overall workflow – from screen grabbing to using YOLOv8 (via DirectML and ONNX) for detection, decisions based on adjustments, and finally triggering the mouse cursor update.
- It mentions the UI’s features (full-fledged UI, customization menus, model store) and clarifies the integration of gameplay adjustability.

a. Main Components:
- User Interface (WPF front-end): Consisting of main windows (MainWindow.xaml, OverlayWindow.xaml), secondary UI modules (under SecondaryWindows and UserController), and visualization components.
- Core AI Processing: The detection module which utilizes DirectML, ONNX, and YOLOv8 (AIModel.cs, PredictionManager.cs).
- Input/Output Management: Screen grabbing functionality, InputBindingManager.cs, and the “triggering functionality” that reads game events to capture screen data.
- Decision Engine: Logic for processing AI outputs with additional adjustments (e.g., anti-recoil, FOV, X+Y adjustments) contained in components like RequirementsManager.cs and PredictionManager.cs.
- Config & Models Management: Handling of configuration files (from the “configs” folder) and model selection/caching (using folders “models” and “Universalv3_web_model”).
- External Services: Integration points for model downloading and community contributions (described in the README regarding pull requests and downloadable models).

b. Out Relationships and Interactions:
- Data flow should be shown from the game system to the screenshot capture module.
- This image data is then passed to the AI recognition module (illustrated with components like YOLOv8 detection).
- Detection results feed into the decision engine where adjustments (FOV, X+Y corrections) are applied.
- The final computed output controls the movement of the mouse cursor.
- The UI layer constantly feeds user-defined settings and customizations into the decision engine.
- The configuration management subsystem should be depicted as a repository that supplies models and game-specific configurations.

c. Important Architectural Patterns/Design Principles:
- Separation of Concerns:
– Present UI versus business logic (detection, decision making) versus configuration management.
- Modularity:
– Group different UI components into modules (windows and controllers) and clearly separate the AI model management.
- Extensibility:
– The design supports hot-swappable models and configurations, so include a component for “Model & Config Store” that interfaces with remote repositories.

d. Relevant Technologies:
- .NET (C#) and WPF for the user interface.
- DirectML, ONNX, and YOLOv8 as the core AI libraries.
- Use of Fody for aspect-oriented enhancements.
- Integration of external resources (game configuration files and downloadable models).

## Diagram (Mermaid)

```mermaid
graph TD
    %% External Source
    E["Game System"]:::external

    %% User Interface (WPF Front-end)
    subgraph "User Interface (WPF Front-end)"
        UIM["Main Window (WPF)"]:::ui
        UIMCS["Main Window Code-behind"]:::ui
        UIO["Overlay Window (WPF)"]:::ui
        UIOCS["Overlay Window Code-behind"]:::ui
        UIS["Secondary UI Modules"]:::ui
        UIC["User Controller"]:::ui
        UIV["Player Detection Window"]:::ui
        UIVCS["Player Detection Code-behind"]:::ui
    end

    %% Input/Output Management
    subgraph "Input/Output Management"
        IO["Screen Capture & Input Binding"]:::io
    end

    %% Core AI Processing
    subgraph "Core AI Processing"
        AI["AI Detection (YOLOv8/ONNX/DirectML)"]:::core
        AIP["Prediction Manager"]:::core
    end

    %% Decision Engine
    subgraph "Decision Engine"
        DEC["Decision & Adjustment Logic"]:::decision
        MC["Mouse Cursor Control"]:::decision
    end

    %% Configuration & Models Management
    subgraph "Configuration & Models Management"
        CONF["Configuration Repository"]:::config
        MOD["Model Repository"]:::config
        MUNI["Universalv3 Model"]:::config
    end

    %% Data Flow Connections
    E -->|"sends_screen_data"| IO
    IO -->|"for_image_analysis"| AI
    AI -->|"detection_results"| DEC
    AIP -->|"supports_processing"| AI
    DEC -->|"adjusted_commands"| MC
    UIM -->|"user_settings"| DEC
    UIO -->|"UI_feedback"| DEC
    UIS -->|"UI_inputs"| DEC
    UIC -->|"controller_inputs"| DEC
    DEC -->|"visual_feedback"| UIV

    CONF -->|"supplies_configs"| AI
    CONF -->|"supplies_configs"| DEC
    MOD -->|"supplies_models"| AI
    MOD -->|"supplies_models"| DEC
    MUNI -->|"supplies_models"| AI
    MUNI -->|"supplies_models"| DEC

    %% Click Events for UI Components
    click UIM "https://github.com/babyhamsta/aimmy/blob/Aimmy-V1/AimmyWPF/MainWindow.xaml"
    click UIMCS "https://github.com/babyhamsta/aimmy/blob/Aimmy-V1/AimmyWPF/MainWindow.xaml.cs"
    click UIO "https://github.com/babyhamsta/aimmy/blob/Aimmy-V1/AimmyWPF/OverlayWindow.xaml"
    click UIOCS "https://github.com/babyhamsta/aimmy/blob/Aimmy-V1/AimmyWPF/OverlayWindow.xaml.cs"
    click UIS "https://github.com/babyhamsta/aimmy/tree/Aimmy-V1/AimmyWPF/SecondaryWindows"
    click UIC "https://github.com/babyhamsta/aimmy/tree/Aimmy-V1/AimmyWPF/UserController"
    click UIV "https://github.com/babyhamsta/aimmy/blob/Aimmy-V1/AimmyWPF/Visualization/PlayerDetectionWindow.xaml"
    click UIVCS "https://github.com/babyhamsta/aimmy/blob/Aimmy-V1/AimmyWPF/Visualization/PlayerDetectionWindow.xaml.cs"

    %% Click Events for Core AI Processing
    click AI "https://github.com/babyhamsta/aimmy/blob/Aimmy-V1/AimmyWPF/AIModel.cs"
    click AIP "https://github.com/babyhamsta/aimmy/blob/Aimmy-V1/AimmyWPF/PredictionManager.cs"

    %% Click Event for Input/Output Management
    click IO "https://github.com/babyhamsta/aimmy/blob/Aimmy-V1/AimmyWPF/InputBindingManager.cs"

    %% Click Event for Decision Engine
    click DEC "https://github.com/babyhamsta/aimmy/blob/Aimmy-V1/AimmyWPF/RequirementsManager.cs"

    %% Click Events for Configuration & Models Management
    click CONF "https://github.com/babyhamsta/aimmy/tree/Aimmy-V1/configs"
    click MOD "https://github.com/babyhamsta/aimmy/tree/Aimmy-V1/models"
    click MUNI "https://github.com/babyhamsta/aimmy/tree/Aimmy-V1/Universalv3_web_model"

    %% Styles
    classDef ui fill:#A2D9CE,stroke:#1ABC9C,stroke-width:2px;
    classDef core fill:#F9E79F,stroke:#F1C40F,stroke-width:2px;
    classDef decision fill:#AED6F1,stroke:#5DADE2,stroke-width:2px;
    classDef io fill:#F5B7B1,stroke:#EC7063,stroke-width:2px;
    classDef config fill:#D7BDE2,stroke:#AF7AC5,stroke-width:2px;
    classDef external fill:#FAD7A0,stroke:#F39C12,stroke-width:2px;
```
