# vagabond-k/vegraris architecture

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

- Interactive diagram: https://gitdiagram.com/vagabond-k/vegraris
- Repository: https://github.com/vagabond-k/vegraris

## Overview

##### Core Architecture Components

- Vegraris.Core (Game Logic Layer)
- Vegraris.Wpf (WPF Client)
- Vegraris.Wasm (Blazor WASM Client)

##### Detailed Component Breakdown

a) Core Layer (Vegraris.Core):
- Game Logic (Game.cs, Grid.cs, GridEditor.cs)
- Piece Management (Piece.cs, ActivePiece.cs, LockedPiece.cs, StaticPiece.cs)
- Drawing System (Drawing/ folder)
- Palette System (Palettes/ folder)
- Tracing System (Tracing/ folder)
- Input Management (PlayerInputDispatcher.cs)
- Scoring System (IScoring.cs, DefaultScoring.cs)

b) Client Implementations:

WPF Client (Vegraris.Wpf):
- MVVM Architecture components
- Theme System (Themes/ folder)
- Converters
- Sound System
- WPF-specific Drawing Implementation

Blazor Client (Vegraris.Wasm):
- Razor Components
- JavaScript Interop
- WASM-specific Drawing Implementation
- State Management

##### Interaction Flows

- Data flow between Core and Clients
- Event propagation
- Drawing instruction flow
- Input handling flow

##### Platform-Specific Implementations

- The separation between core game logic and platform-specific implementations
- The vector graphics drawing system's architecture
- How themes are implemented across platforms
- The event system for game state changes
- Platform-specific optimizations

Remember to:
- Keep the core game logic (Vegraris.Core) completely platform-independent
- How the drawing system abstracts vector graphics operations
- How different themes are implemented and switched
- Demonstrate the input handling flow from user interaction to game state changes

This architecture should clearly show how the project maintains platform independence while allowing for platform-specific optimizations in both WPF and Blazor WASM implementations.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Core["Vegraris.Core"]
        GameLogic["Game Logic"]:::core
        Grid["Grid Management"]:::core
        PieceSystem["Piece Management System"]:::core
        DrawingSystem["Drawing System"]:::core
        PaletteSystem["Palette System"]:::core
        TracingSystem["Tracing System"]:::core
        InputMgmt["Input Management"]:::core
        ScoringSystem["Scoring System"]:::core
        
        GameLogic --> Grid
        GameLogic --> PieceSystem
        GameLogic --> ScoringSystem
        InputMgmt --> GameLogic
        DrawingSystem --> PaletteSystem
        DrawingSystem --> TracingSystem
    end

    subgraph WPF["Vegraris.Wpf Client"]
        MVVM["MVVM Components"]:::wpf
        WPFThemes["Theme System"]:::wpf
        WPFConverters["Converters"]:::wpf
        WPFSound["Sound System"]:::wpf
        WPFDrawing["WPF Drawing Implementation"]:::wpf

        MVVM --> WPFDrawing
        MVVM --> WPFThemes
        MVVM --> WPFConverters
        MVVM --> WPFSound
    end

    subgraph Blazor["Vegraris.Wasm Client"]
        RazorComps["Razor Components"]:::blazor
        JSInterop["JavaScript Interop"]:::blazor
        StateManagement["State Management"]:::blazor
        WASMDrawing["WASM Drawing Implementation"]:::blazor

        RazorComps --> JSInterop
        RazorComps --> StateManagement
        RazorComps --> WASMDrawing
    end

    WPF --> Core
    Blazor --> Core

    %% Click events for component mapping
    click GameLogic "https://github.com/Vagabond-K/VEGRARIS/blob/master/Vegraris.Core/Game.cs"
    click Grid "https://github.com/Vagabond-K/VEGRARIS/blob/master/Vegraris.Core/Grid.cs"
    click PieceSystem "https://github.com/Vagabond-K/VEGRARIS/blob/master/Vegraris.Core/Piece.cs"
    click DrawingSystem "https://github.com/Vagabond-K/VEGRARIS/tree/master/Vegraris.Core/Drawing/"
    click PaletteSystem "https://github.com/Vagabond-K/VEGRARIS/tree/master/Vegraris.Core/Palettes/"
    click TracingSystem "https://github.com/Vagabond-K/VEGRARIS/tree/master/Vegraris.Core/Tracing/"
    click InputMgmt "https://github.com/Vagabond-K/VEGRARIS/blob/master/Vegraris.Core/PlayerInputDispatcher.cs"
    click ScoringSystem "https://github.com/Vagabond-K/VEGRARIS/blob/master/Vegraris.Core/IScoring.cs"
    click MVVM "https://github.com/Vagabond-K/VEGRARIS/blob/master/Vegraris.Wpf/MainViewModel.cs"
    click WPFThemes "https://github.com/Vagabond-K/VEGRARIS/tree/master/Vegraris.Wpf/Themes/"
    click WPFConverters "https://github.com/Vagabond-K/VEGRARIS/tree/master/Vegraris.Wpf/Converters/"
    click WPFSound "https://github.com/Vagabond-K/VEGRARIS/blob/master/Vegraris.Wpf/SoundEffectPlayer.cs"
    click RazorComps "https://github.com/Vagabond-K/VEGRARIS/tree/master/Vegraris.Wasm/Components/"
    click JSInterop "https://github.com/Vagabond-K/VEGRARIS/blob/master/Vegraris.Wasm/Pages/Index.razor.js"
    click StateManagement "https://github.com/Vagabond-K/VEGRARIS/blob/master/Vegraris.Wasm/StateMonitor.cs"
    click WASMDrawing "https://github.com/Vagabond-K/VEGRARIS/blob/master/Vegraris.Wasm/DrawingContext.cs"

    %% Styling
    classDef core fill:#a8d1f0,stroke:#333,stroke-width:2px
    classDef wpf fill:#f9d6a8,stroke:#333,stroke-width:2px
    classDef blazor fill:#c8e6c9,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        CoreLegend["Core Component"]:::core
        WPFLegend["WPF Component"]:::wpf
        BlazorLegend["Blazor Component"]:::blazor
    end
```
