# mgear-dev/mgear architecture

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

- Interactive diagram: https://gitdiagram.com/mgear-dev/mgear
- Repository: https://github.com/mgear-dev/mgear

## Overview

##### Project Type and Purpose
- mGear is a modular rigging and animation framework developed for Autodesk Maya.
- Its purpose is to provide a set of modules, tools, and C++ solvers to streamline the development of rigging and animation tools.
- The system integrates Python-based modules (for UI, tools, and higher-level rig functionality) with performance-critical C++ plugins (solvers, custom nodes, etc.) to work within Maya.

##### Main Components
a. Autodesk Maya Environment:
- Maya as the host environment where mGear is loaded as plugins and scripts.
- Connection between Maya’s API and the mGear components.

b. mGear Framework – Python Modules:
- mGear Core: Includes utilities, attribute management, logging, callbacks, and other general-purpose functionalities (contents found in release/scripts/mgear/core and similar folders).

c. C++ Plugins (Solvers and Performance-critical Nodes):
- “src” directory components, which contain various C++ source files for plugins (solver nodes, constraint nodes, etc.).
- That these components are built with CMake (driven by CMakeLists.txt and associated cmake scripts) and loaded into Maya as custom plugins.
- That they interact with the mGear framework by providing computation-heavy operations (e.g., spring solvers, matrix operations).

d. Build, Deployment, and Versioning:
- Integration of GitHub workflows, CMake build scripts, and release packaging.
- How the CI/CD components (located in .github/workflows and build scripts) feed into building, testing, and deploying both Python scripts and C++ plugins.

##### Relationships and Interactions
- Link the mGear Python modules to the underlying C++ plugins, illustrating that some functions (e.g., solvers, custom nodes) are implemented in C++ to enhance performance.
- Documentation and test suites as support layers interfacing with the core modules.

##### Highlighting Architectural Patterns and Design Principles
- Modular structure: each rigging module (e.g., Shifter, Rigbits, Anim Picker) is separated but interconnected through shared utilities found in mGear Core.
- Separation between the user interface layer (Python UI scripts and corresponding Maya commands) and the computational layer (C++ solvers).
- Stress the plugin-based design that allows mGear to be extensible and future-proof for upcoming Maya versions.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Infrastructure Nodes
    Build["Build & CI/CD"]:::infra
    DocTest["Documentation & Testing"]:::infra

    %% Core Environment
    Maya["Autodesk Maya Environment"]:::maya

    %% mGear Python Modules Subgraph
    subgraph "mGear Python Modules"
        MGCore["mGear Core"]:::python
        AnimPicker["Anim Picker"]:::python
        Animbits["Animbits"]:::python
        CFX["cfxbits"]:::python
        Crank["Crank"]:::python
        Flex["Flex"]:::python
        Shifter["Shifter"]:::python
        Rigbits["Rigbits"]:::python
        SimpleRig["SimpleRig"]:::python
        Synoptic["Synoptic"]:::python
    end

    %% C++ Plugins Subgraph
    subgraph "C++ Plugins / Solvers"
        CppSolvers["C++ Solvers"]:::cpp
    end

    %% Relationships
    %% Maya triggers mGear Python Modules
    Maya -->|"initiates"| MGCore

    %% Chain of Python Modules (vertical layout)
    MGCore -->|"uses"| AnimPicker
    AnimPicker -->|"uses"| Animbits
    Animbits -->|"uses"| CFX
    CFX -->|"uses"| Crank
    Crank -->|"uses"| Flex
    Flex -->|"uses"| Shifter
    Shifter -->|"uses"| Rigbits
    Rigbits -->|"uses"| SimpleRig
    SimpleRig -->|"uses"| Synoptic

    %% mGear Python Modules call C++ Plugins
    MGCore -->|"calls"| CppSolvers

    %% Build system supports both Python and C++ components
    Build ---|"builds"| MGCore
    Build ---|"builds"| CppSolvers

    %% Documentation & Testing supports mGear Core
    DocTest ---|"validates"| MGCore

    %% Click Events
    click Maya "https://github.com/mgear-dev/mgear/tree/master/release/platforms"
    click MGCore "https://github.com/mgear-dev/mgear/tree/master/release/scripts/mgear/core"
    click AnimPicker "https://github.com/mgear-dev/mgear/tree/master/release/scripts/mgear/anim_picker"
    click Animbits "https://github.com/mgear-dev/mgear/tree/master/release/scripts/mgear/animbits"
    click CFX "https://github.com/mgear-dev/mgear/tree/master/release/scripts/mgear/cfxbits"
    click Crank "https://github.com/mgear-dev/mgear/tree/master/release/scripts/mgear/crank"
    click Flex "https://github.com/mgear-dev/mgear/tree/master/release/scripts/mgear/flex"
    click Shifter "https://github.com/mgear-dev/mgear/tree/master/release/scripts/mgear/shifter"
    click Rigbits "https://github.com/mgear-dev/mgear/tree/master/release/scripts/mgear/rigbits"
    click SimpleRig "https://github.com/mgear-dev/mgear/tree/master/release/scripts/mgear/simpleRig"
    click Synoptic "https://github.com/mgear-dev/mgear/blob/master/docs/source/mgear/mgear.synoptic.rst"
    click CppSolvers "https://github.com/mgear-dev/mgear/tree/master/src"
    click Build "https://github.com/mgear-dev/mgear/tree/master/.github/workflows"
    click DocTest "https://github.com/mgear-dev/mgear/tree/master/docs"

    %% Styles
    classDef maya fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef python fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef cpp fill:#FFB6C1,stroke:#000,stroke-width:2px;
    classDef infra fill:#FFFF99,stroke:#000,stroke-width:2px;
```
