# pavelzaichyk/flutter_joystick architecture

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

- Interactive diagram: https://gitdiagram.com/pavelzaichyk/flutter_joystick
- Repository: https://github.com/pavelzaichyk/flutter_joystick

## Overview

##### Project type and purpose
- This is an open-source Flutter plugin (library) called “flutter_joystick.” Its purpose is to provide reusable virtual joystick UI components for Flutter apps.
- The README describes interactive joystick and joystick-area widgets, customization options (base, stick, offset calculators, snapping).

##### File structure
- At top level:
- lib/ (plugin source)
- example/ (multi-platform demo apps: android/, ios/, web/)
- pubspec.yaml & pubspec.lock (package manifest)
- GitHub CI workflows (.github/workflows/)
- Under lib/src/:
- joystick.dart, joystick_area.dart (public widgets)
- joystick_base.dart, joystick_stick.dart, joystick_arrow.dart (UI primitives)
- joystick_controller.dart (state & event propagation)
- joystick_stick_offset_calculator.dart + utils.dart (calculations & snapping)
- The example directory contains platform-specific Flutter project scaffolds demonstrating usage.

##### README for additional insights
- The plugin declares no backend or database, it runs entirely in Flutter on multiple platforms.
- It lists customizable building blocks and snapping feature with circular/rectangular offset calculators.

##### Elements
- Clear labels for each component (e.g., JoystickController)
- Touch events → Widgets → Controller → Calculator → Listener callback
- Green for public API (Joystick, JoystickArea)
- Blue for internal modules (controller, calculators)
- Yellow for external dependencies (Flutter SDK, platform channels if any)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Example Application Consumer
    subgraph "Example Application (Consumer)"
        App["Flutter Application"]:::external
    end

    %% Plugin Package
    subgraph "Plugin Package"
        PluginEntry["Plugin Entry\nflutter_joystick.dart"]:::internal
        subgraph "Public API Layer"
            Joystick["Joystick"]:::publicAPI
            JoystickArea["JoystickArea"]:::publicAPI
        end
        subgraph "UI Primitives"
            Base["JoystickBase"]:::internal
            Stick["JoystickStick"]:::internal
            Arrow["JoystickArrow"]:::internal
        end
        subgraph "Internal Engine"
            Controller["JoystickController"]:::internal
            Calculators["Offset Calculators\n(Circle & Rectangle)"]:::internal
            Utils["Utility Functions"]:::internal
        end
    end

    %% External Dependency
    SDK["Flutter SDK"]:::external

    %% Connections
    App -->|imports plugin| SDK
    App -->|uses| Joystick
    App -->|uses| JoystickArea
    SDK -->|provides framework| Joystick
    SDK -->|provides framework| JoystickArea
    PluginEntry -->|exposes API| Joystick
    PluginEntry -->|exposes API| JoystickArea
    Joystick -->|composes| Base
    Joystick -->|composes| Stick
    Joystick -->|composes| Arrow
    JoystickArea -->|composes| Base
    JoystickArea -->|composes| Stick
    JoystickArea -->|composes| Arrow
    Base -->|captures gestures| Controller
    Stick -->|captures gestures| Controller
    Arrow -->|captures gestures| Controller
    Controller -->|calculates offset| Calculators
    Calculators -->|uses| Utils
    Controller -->|invokes listener callback| App

    %% Click Events
    click App "https://github.com/pavelzaichyk/flutter_joystick/blob/master/example/lib/main.dart"
    click PluginEntry "https://github.com/pavelzaichyk/flutter_joystick/blob/master/lib/flutter_joystick.dart"
    click Joystick "https://github.com/pavelzaichyk/flutter_joystick/blob/master/lib/src/joystick.dart"
    click JoystickArea "https://github.com/pavelzaichyk/flutter_joystick/blob/master/lib/src/joystick_area.dart"
    click Base "https://github.com/pavelzaichyk/flutter_joystick/blob/master/lib/src/joystick_base.dart"
    click Stick "https://github.com/pavelzaichyk/flutter_joystick/blob/master/lib/src/joystick_stick.dart"
    click Arrow "https://github.com/pavelzaichyk/flutter_joystick/blob/master/lib/src/joystick_arrow.dart"
    click Controller "https://github.com/pavelzaichyk/flutter_joystick/blob/master/lib/src/joystick_controller.dart"
    click Calculators "https://github.com/pavelzaichyk/flutter_joystick/blob/master/lib/src/joystick_stick_offset_calculator.dart"
    click Utils "https://github.com/pavelzaichyk/flutter_joystick/blob/master/lib/src/utils.dart"

    %% Styles
    classDef publicAPI fill:#9f6,stroke:#333,stroke-width:2px
    classDef internal fill:#6cf,stroke:#333,stroke-width:2px
    classDef external fill:#fc6,stroke:#333,stroke-width:2px
```
