# league-of-dae-legends/squadforger architecture

> Architecture diagram of the GitHub repository league-of-dae-legends/squadforger, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/league-of-dae-legends/squadforger
- Repository: https://github.com/league-of-dae-legends/squadforger

## Overview

##### Project Type and Purpose
- This is a C#-based WPF desktop application following the MVVM (Model-View-ViewModel) pattern.
- Purpose: take two ARAM teams as input (manually or via CSV), generate a pool of champions for each team (either from a local JSON or via Riot’s Data Dragon API), and optionally post the results to Discord via a webhook.

##### File Structure Analysis
- Top-level:
├── SquadForger (WPF project folder)
│   ├── App.xaml(.cs): application entrypoint
│   ├── MainWindow.xaml(.cs): host window
│   ├── View/: WPF XAML UIs (DiscordView, SquadView)
│   ├── ViewModel/: VM classes (MainVM, SquadVM, DiscordVM)
│   ├── Model/: domain entities (Champions, Team, LeagueVersion)
│   ├── Repository/: parsing & champion-selection abstractions (ITeamNamesRepository, IRandomPicker) and implementations (CSVTeamsParser, DefaultChampionPicker)
│   ├── Services/: infrastructure (ServiceLocator, EventAggregator, event classes, DiscordService)
│   ├── Converter/: WPF converters (TextToVisibilityConverter)
│   ├── Resources/: champion.json (local data)
│   ├── Theme/: UI styling
│   └── App.config, FodyWeavers.xml: config & IL-weaving
- packages.config: NuGet dependencies
- SquadForger.sln/.csproj: solution & project definitions

##### Architectural Patterns & Design Principles
- MVVM separation: View ↔ ViewModel ↔ Model
- Dependency lookup via a ServiceLocator (similar to DI)
- Event-driven communication between components via EventAggregator
- Repository pattern for input sources and champion-picker strategies
- Fody weaving to inject boilerplate (e.g., INotifyPropertyChanged)

##### Main Components & Their Interactions
- Presentation Layer
- Views (XAML) + Converters + Themes
- ViewModels handle user actions (e.g., “Generate Safe”, “Generate Custom”, “Send to Discord”)
- Domain Layer
- Model classes hold Teams, Champions data structures
- Repository Layer
- ITeamNamesRepository: abstracts input (manual vs CSV)
- IRandomPicker: abstracts pool generation logic (local vs remote)
- Data Sources
- Local: Resources/champion.json
- Remote: Riot’s Data Dragon HTTP API
- Services & Infrastructure
- ServiceLocator: resolves IRepository, IRandomPicker, DiscordService, EventAggregator
- EventAggregator: decoupled messaging between VMs & services
- DiscordService: builds payload and issues HTTP POST to Discord webhook
- External Dependencies
- HTTP Client to Riot and Discord
- Newtonsoft.Json (or Fody-weaved JSON serializers)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        AppEntry["App.xaml / App.xaml.cs"]:::frontend
        MainWindow["MainWindow.xaml / MainWindow.xaml.cs"]:::frontend
        SquadView["SquadView.xaml / SquadView.xaml.cs"]:::frontend
        DiscordView["DiscordView.xaml / DiscordView.xaml.cs"]:::frontend
        Converter["TextToVisibilityConverter"]:::frontend
        ThemeMenu["MenuButtonTheme.xaml"]:::frontend
        ThemeText["TextBoxTheme.xaml"]:::frontend
    end

    %% Presentation-Logic Layer
    subgraph "Presentation-Logic Layer"
        direction TB
        MainVM["MainVM"]:::logic
        SquadVM["SquadVM"]:::logic
        DiscordVM["DiscordVM"]:::logic
        ServiceLocator["ServiceLocator"]:::logic
        EventAggregator["EventAggregator"]:::logic
        DiscordService["DiscordService"]:::logic
    end

    %% Domain & Data Layer
    subgraph "Domain & Data Layer"
        direction TB
        ChampionModel["Champions.cs"]:::domain
        TeamModel["Team.cs"]:::domain
        VersionModel["LeagueVersion.cs"]:::domain
        ITeamRepo["ITeamNamesRepository"]:::domain
        IRandomPicker["IRandomPicker"]:::domain
        CSVParser["CSVTeamsParser"]:::domain
        DefaultPicker["DefaultChampionPicker"]:::domain
        LocalJSON["champion.json"]:::external
    end

    %% External APIs
    subgraph "External APIs"
        direction TB
        RiotAPI["Riot Data Dragon API"]:::external
        DiscordAPI["Discord Webhook"]:::external
    end

    %% Connections
    AppEntry --> MainWindow
    MainWindow --> SquadView
    MainWindow --> DiscordView
    SquadView --> SquadVM
    DiscordView --> DiscordVM
    SquadView --> Converter
    DiscordView --> Converter
    SquadView --> ThemeMenu
    SquadView --> ThemeText
    DiscordView --> ThemeMenu
    DiscordView --> ThemeText

    SquadVM --> ServiceLocator
    MainVM --> ServiceLocator
    DiscordVM --> ServiceLocator

    ServiceLocator --> ITeamRepo
    ServiceLocator --> IRandomPicker
    ServiceLocator --> DiscordService
    ServiceLocator --> EventAggregator

    ITeamRepo --> CSVParser
    CSVParser --> TeamModel

    IRandomPicker --> DefaultPicker
    DefaultPicker --> ChampionModel
    DefaultPicker --> VersionModel
    DefaultPicker --> LocalJSON
    DefaultPicker --> RiotAPI

    SquadVM -->|updates| TeamModel
    DefaultPicker -->|populates| TeamModel

    SquadVM -->|publishes| EventAggregator
    DiscordVM -->|publishes| EventAggregator
    EventAggregator -.->|updates| SquadView
    EventAggregator -.->|updates| DiscordView

    DiscordVM --> DiscordService
    DiscordService --> DiscordAPI

    %% Click Events
    click AppEntry "https://github.com/league-of-dae-legends/squadforger/blob/main/SquadForger/App.xaml"
    click AppEntry "https://github.com/league-of-dae-legends/squadforger/blob/main/SquadForger/App.xaml.cs"
    click MainWindow "https://github.com/league-of-dae-legends/squadforger/blob/main/SquadForger/MainWindow.xaml"
    click MainWindow "https://github.com/league-of-dae-legends/squadforger/blob/main/SquadForger/MainWindow.xaml.cs"
    click SquadView "https://github.com/league-of-dae-legends/squadforger/blob/main/SquadForger/View/SquadView.xaml"
    click SquadView "https://github.com/league-of-dae-legends/squadforger/blob/main/SquadForger/View/SquadView.xaml.cs"
    click DiscordView "https://github.com/league-of-dae-legends/squadforger/blob/main/SquadForger/View/DiscordView.xaml"
    click DiscordView "https://github.com/league-of-dae-legends/squadforger/blob/main/SquadForger/View/DiscordView.xaml.cs"
    click MainVM "https://github.com/league-of-dae-legends/squadforger/blob/main/SquadForger/ViewModel/MainVM.cs"
    click SquadVM "https://github.com/league-of-dae-legends/squadforger/blob/main/SquadForger/ViewModel/SquadVM.cs"
    click DiscordVM "https://github.com/league-of-dae-legends/squadforger/blob/main/SquadForger/ViewModel/DiscordVM.cs"
    click ChampionModel "https://github.com/league-of-dae-legends/squadforger/blob/main/SquadForger/Model/Champions.cs"
    click TeamModel "https://github.com/league-of-dae-legends/squadforger/blob/main/SquadForger/Model/Team.cs"
    click VersionModel "https://github.com/league-of-dae-legends/squadforger/blob/main/SquadForger/Model/LeagueVersion.cs"
    click ITeamRepo "https://github.com/league-of-dae-legends/squadforger/blob/main/SquadForger/Repository/ITeamNamesRepository.cs"
    click IRandomPicker "https://github.com/league-of-dae-legends/squadforger/blob/main/SquadForger/Repository/IRandomPicker.cs"
    click CSVParser "https://github.com/league-of-dae-legends/squadforger/blob/main/SquadForger/Repository/CSVTeamsParser.cs"
    click DefaultPicker "https://github.com/league-of-dae-legends/squadforger/blob/main/SquadForger/Repository/DefaultChampionPicker.cs"
    click ServiceLocator "https://github.com/league-of-dae-legends/squadforger/blob/main/SquadForger/Services/ServiceLocator.cs"
    click EventAggregator "https://github.com/league-of-dae-legends/squadforger/blob/main/SquadForger/Services/EventAggregator.cs"
    click EventAggregator "https://github.com/league-of-dae-legends/squadforger/blob/main/SquadForger/Services/TeamsUpdatedEvent.cs"
    click Converter "https://github.com/league-of-dae-legends/squadforger/blob/main/SquadForger/Converter/TextToVisibilityConverter.cs"
    click LocalJSON "https://github.com/league-of-dae-legends/squadforger/blob/main/SquadForger/Resources/champion.json"
    click ThemeMenu "https://github.com/league-of-dae-legends/squadforger/blob/main/SquadForger/Theme/MenuButtonTheme.xaml"
    click ThemeText "https://github.com/league-of-dae-legends/squadforger/blob/main/SquadForger/Theme/TextBoxTheme.xaml"
    click AppEntry "https://github.com/league-of-dae-legends/squadforger/blob/main/SquadForger/App.config"
    click AppEntry "https://github.com/league-of-dae-legends/squadforger/blob/main/SquadForger/FodyWeavers.xml"
    click AppEntry "https://github.com/league-of-dae-legends/squadforger/blob/main/SquadForger/FodyWeavers.xsd"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef logic fill:#90EE90,stroke:#000,stroke-width:1px
    classDef domain fill:#FFFFE0,stroke:#000,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#000,stroke-width:1px
```
