# ycarowr/uicard architecture

> Architecture diagram of the GitHub repository ycarowr/uicard, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ycarowr/uicard
- Repository: https://github.com/ycarowr/uicard

## Overview

##### Main System Components

The system should be represented as a layered architecture with the following main components:

a) UI Layer
- Card Prefabs and Visual Components
- Drop Zones (Hand and Battlefield)
- Player Hands (P1 and P2)
- Card Motion System

b) Core Systems
- State Machine
- Pooling System
- Event System
- Input Handler

##### Detailed Component Breakdown

Card Component System:
**UiCardComponent**
- Transform System
- Motion
- Rotation
- Scaling
- State Machine
- Idle
- Hover
- Drag
- Discard
- Disable
- Input Handler

##### Architectural Patterns to Emphasize

- Observer Pattern (DelegateObserver)
- State Pattern (Card States)
- Pooling Pattern (GenericPooler)
- Command Pattern
- Builder Pattern

##### Specific Implementation Details

Crucial elements:
**Card Management**
- PrefabPooler
- UiPlayerHand
- HandBender
- HandSorter
- HandUtils
- DropZones
- Battlefield
- Hand

##### Configuration System

Parameters system:
**UiCardParameters**
- Spacing
- Rotation
- Height
- Hover Properties
- Motion Speed

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef ui fill:#90EE90,stroke:#333,stroke-width:2px
    classDef core fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef input fill:#FFD700,stroke:#333,stroke-width:2px
    classDef config fill:#DDA0DD,stroke:#333,stroke-width:2px

    %% UI Layer
    subgraph UI
        CardPrefab["Card Prefab"]
        DropZones["Drop Zones System"]
        PlayerHands["Player Hands System"]
        CardTransform["Card Transform System"]
    end

    %% Core Systems
    subgraph Core
        StateMachine["State Machine"]
        PoolSystem["Pooling System"]
        EventSystem["Event System"]
        InputHandler["Input Handler"]
    end

    %% Card Component Breakdown
    subgraph CardComponent
        UiCard["UI Card Component"]
        TransformSystem["Transform System"]
        CardStates["Card States"]
    end

    %% Transform System Details
    subgraph TransformDetails
        Motion["Motion"]
        Rotation["Rotation"]
        Scaling["Scaling"]
    end

    %% State Machine States
    subgraph States
        Idle["Idle"]
        Hover["Hover"]
        Drag["Drag"]
        Draw["Draw"]
        Discard["Discard"]
        Disable["Disable"]
    end

    %% Hand Management
    subgraph HandSystem
        HandBender["Hand Bender"]
        HandSorter["Hand Sorter"]
        HandUtils["Hand Utils"]
    end

    %% Parameters
    subgraph Parameters
        CardParams["Card Parameters"]
    end

    %% Relationships
    UiCard --> TransformSystem
    UiCard --> CardStates
    UiCard --> InputHandler
    TransformSystem --> Motion & Rotation & Scaling
    StateMachine --> CardStates
    CardStates --> Idle & Hover & Drag & Draw & Discard & Disable
    PlayerHands --> HandBender & HandSorter & HandUtils
    PoolSystem --> CardPrefab
    EventSystem -.-> UiCard
    InputHandler -.-> UiCard
    CardParams --> UiCard

    %% Click Events
    click UiCard "https://github.com/ycarowr/UiCard/blob/master/Assets/Scripts/UICard/UiCardComponent/UiCardComponent.cs"
    click StateMachine "https://github.com/ycarowr/UiCard/blob/master/Assets/Scripts/Patterns/StateMachine/BaseStateMachine.cs"
    click CardStates "https://github.com/ycarowr/UiCard/tree/master/Assets/Scripts/UICard/UiCardComponent/UiCardStateMachine/States/"
    click PoolSystem "https://github.com/ycarowr/UiCard/blob/master/Assets/Scripts/Patterns/GenericPooler/GenericPooler.cs"
    click EventSystem "https://github.com/ycarowr/UiCard/blob/master/Assets/Scripts/Patterns/Observer/DelegateObserver.cs"
    click InputHandler "https://github.com/ycarowr/UiCard/blob/master/Assets/Scripts/Tools/Input/UiMouseInputProvider.cs"
    click TransformSystem "https://github.com/ycarowr/UiCard/blob/master/Assets/Scripts/UICard/UiCardTransform/UiMotionBaseCard.cs"
    click Motion "https://github.com/ycarowr/UiCard/blob/master/Assets/Scripts/UICard/UiCardTransform/UiMotionMovementCard.cs"
    click Rotation "https://github.com/ycarowr/UiCard/blob/master/Assets/Scripts/UICard/UiCardTransform/UiMotionRotationCard.cs"
    click Scaling "https://github.com/ycarowr/UiCard/blob/master/Assets/Scripts/UICard/UiCardTransform/UiMotionScaleCard.cs"
    click DropZones "https://github.com/ycarowr/UiCard/blob/master/Assets/Scripts/UICard/UiCardZones/UiBaseDropZone.cs"
    click PlayerHands "https://github.com/ycarowr/UiCard/blob/master/Assets/Scripts/UICard/UiPlayerHand/UiPlayerHand.cs"
    click HandBender "https://github.com/ycarowr/UiCard/blob/master/Assets/Scripts/UICard/UiPlayerHand/UiPlayerHandBender.cs"
    click HandSorter "https://github.com/ycarowr/UiCard/blob/master/Assets/Scripts/UICard/UiPlayerHand/UiPlayerHandSorter.cs"
    click CardParams "https://github.com/ycarowr/UiCard/blob/master/Assets/Scripts/UICard/UiCardParameters/UiCardParameters.cs"
    click CardPrefab "https://github.com/ycarowr/UiCard/blob/master/Assets/Prefabs/CardPrefabPure.prefab"

    %% Style Applications
    class CardPrefab,DropZones,PlayerHands,CardTransform ui
    class StateMachine,PoolSystem,EventSystem core
    class InputHandler input
    class CardParams config
```
