# hsn723/anime-quiz architecture

> Architecture diagram of the GitHub repository hsn723/anime-quiz, 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/hsn723/anime-quiz
- Repository: https://github.com/hsn723/anime-quiz

## Overview

This project is a desktop-based quiz application (specifically targeting the McGill Students Anime Club) built using C# and WPF. Its primary purpose is to allow a Game Master to administer and control quiz games (including managing question sets, teams, and scoring) while providing a separate interface for players. The system is split into several visual components with supporting logic and a file-based database (animequiz.s3db).

##### Main Components
- UI Layers:
- Game Master UI: Windows such as GameMasterWindow, GameStartPage, BuzzerSetupWindow, HelpWindow, QuestionSetEditor, SettingsWindow, and TeamEditor.
- Player UI: PlayerWindow, QuestionPage, and QuestionSetPage.
- Scoring UI: IndividualScores and TeamScoresView.
- Domain/Business Logic:
- Core classes managing quiz state (CurrentQuestion, CurrentQuestionSet, CurrentTeam) which are found in the Classes folder.
- Controls for quiz interactions (e.g., AbstractQuestionControl, BluetoothBuzzer, MusicControl, Score, ScoringControl, etc.), found under the Controls folder.
- Data Layer:
- Database interface connected via GameDB* files and the animequiz.s3db file representing a SQLite database structure.
- Resources and Config:
- Resources folder providing audio files.
- Configuration and settings files such as app.config and the Properties folder files which include AssemblyInfo, resource settings, etc.

##### Relationships and Interactions
- UI Components communicate with the underlying business logic to load, process, and display questions, answers, scores, and team data.
- The Game Master UI has controls for starting games, loading question sets (which are created or modified in the Question Set Editor) and configuring game settings.
- The Player UI receives data streamed from the Game Master (e.g., when a question is selected and then revealed).
- Both UIs update and retrieve data from the local database (animequiz.s3db) for persisting scores, teams, and question sets.
- Bluetooth functionality for buzzers is implemented via specific controls (BluetoothBuzzer) which may interact with hardware APIs.

##### Architectural Patterns and Key Design Principles
- Separation of Concerns: There is a clear division of responsibilities between the UI presentation layer, business logic (classes in the “Classes” directory), and data access layer (database files).
- MVVM (Model-View-ViewModel) or code-behind approach: Given the WPF XAML windows and controls, even if not explicitly MVVM, there is a separation between layout (XAML) and code-behind (.cs files).
- Modular design: The project separates different functional areas (Game Master vs. Player, and their respective editors) into distinct folders.
- Extensibility: The README mentions the potential for additional features (like testing for Bluetooth serial or playback options), so the architecture must be designed keeping extensibility in mind.

##### Putting It All Together
– Do not forget to note additional interactions such as the Bluetooth buzzer control’s communications with external hardware.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Anime Quiz Application"
        %% UI Layer
        subgraph "UI Layer"
            subgraph "Game Master UI"
                GMW["Game Master Window"]:::ui
                GSP["Game Start Page"]:::ui
                BZW["Buzzer Setup Window"]:::ui
                HW["Help Window"]:::ui
                QSE["Question Set Editor"]:::ui
                SW["Settings Window"]:::ui
                TE["Team Editor"]:::ui
            end
            subgraph "Player UI"
                PW["Player Window"]:::ui
                QP["Question Page"]:::ui
                QSP2["Question Set Page"]:::ui
            end
            subgraph "Scoring UI"
                IS["Individual Scores"]:::ui
                TS["Team Scores View"]:::ui
            end
        end

        %% Business Logic Layer
        subgraph "Business Logic Layer"
            subgraph "Domain Model"
                CQ["Current Question"]:::logic
                CQS["Current Question Set"]:::logic
                CT["Current Team"]:::logic
            end
            subgraph "Control Logic"
                AQC["Abstract Question Control"]:::control
                BB["Bluetooth Buzzer"]:::control
                MC["Music Control"]:::control
                QC["Question Control"]:::control
                SC["Score"]:::control
                SC2["Scoring Control"]:::control
            end
        end

        %% Data & Configuration
        subgraph "Data & Configuration"
            subgraph "Data Access"
                GDB["GameDB Interface"]:::database
                DB["SQLite DB: animequiz.s3db"]:::database
            end
            subgraph "Resources & Config"
                RA["Resources Audio"]:::config
                CFG["Configuration"]:::config
            end
        end

        %% Connections between UI and Business Logic
        GMW -->|"loadQuestionSet"| CQ
        QSE -->|"editQuestions"| CQS
        TE -->|"updateTeams"| CT

        PW -->|"displayQuestion"| CQ
        QP -->|"questionFlow"| CQ
        QSP2 -->|"loadSet"| CQS

        %% Business Logic to Scoring UI
        CQ -->|"updateScore"| IS
        CT -->|"updateTeamScore"| TS

        %% UI to Control Logic interactions
        BZW -->|"activateBuzzer"| BB
        HW -->|"helpRequest"| AQC
        GMW -->|"initiateGame"| MC

        %% Business Logic to Data Access
        CQ -->|"read/write"| GDB
        CQS -->|"read/write"| GDB
        CT -->|"read/write"| GDB
        GDB -->|"CRUDoperations"| DB

        %% Control Logic internal flow
        AQC -->|"triggerQuestion"| QC
        QC -->|"scoreUpdate"| SC
        SC -->|"aggregateScore"| SC2

        %% Communication from Game Master UI to Player UI
        GMW -->|"broadcast"| PW
    end

click GMW "https://github.com/hsn723/anime-quiz/blob/master/GameMaster/GameMasterWindow.xaml"
click GSP "https://github.com/hsn723/anime-quiz/blob/master/GameMaster/GameStartPage.xaml"
click BZW "https://github.com/hsn723/anime-quiz/blob/master/GameMaster/BuzzerSetupWindow.xaml"
click HW "https://github.com/hsn723/anime-quiz/blob/master/GameMaster/HelpWindow.xaml"
click QSE "https://github.com/hsn723/anime-quiz/blob/master/GameMaster/QuestionSetEditor.xaml"
click SW "https://github.com/hsn723/anime-quiz/blob/master/GameMaster/SettingsWindow.xaml"
click TE "https://github.com/hsn723/anime-quiz/blob/master/GameMaster/TeamEditor.xaml"

click PW "https://github.com/hsn723/anime-quiz/blob/master/Player/PlayerWindow.xaml"
click QP "https://github.com/hsn723/anime-quiz/blob/master/Player/QuestionPage.xaml"
click QSP2 "https://github.com/hsn723/anime-quiz/blob/master/Player/QuestionSetPage.xaml"

click IS "https://github.com/hsn723/anime-quiz/blob/master/Scoring/IndividualScores.xaml"
click TS "https://github.com/hsn723/anime-quiz/blob/master/Scoring/TeamScoresView.xaml"

click CQ "https://github.com/hsn723/anime-quiz/blob/master/Classes/CurrentQuestion.cs"
click CQS "https://github.com/hsn723/anime-quiz/blob/master/Classes/CurrentQuestionSet.cs"
click CT "https://github.com/hsn723/anime-quiz/blob/master/Classes/CurrentTeam.cs"

click AQC "https://github.com/hsn723/anime-quiz/blob/master/Controls/AbstractQuestionControl.xaml"
click BB "https://github.com/hsn723/anime-quiz/blob/master/Controls/BluetoothBuzzer.xaml"
click MC "https://github.com/hsn723/anime-quiz/blob/master/Controls/MusicControl.cs"
click QC "https://github.com/hsn723/anime-quiz/blob/master/Controls/QuestionControl.cs"
click SC "https://github.com/hsn723/anime-quiz/blob/master/Controls/Score.xaml"
click SC2 "https://github.com/hsn723/anime-quiz/blob/master/Controls/ScoringControl.xaml"

click GDB "https://github.com/hsn723/anime-quiz/blob/master/GameDB.Designer.cs"
click DB "https://github.com/hsn723/anime-quiz/blob/master/animequiz.s3db"

click RA "https://github.com/hsn723/anime-quiz/tree/master/Resources"
click CFG "https://github.com/hsn723/anime-quiz/blob/master/app.config"

classDef ui fill:#ADD8E6,stroke:#000,stroke-width:1px;
classDef logic fill:#90EE90,stroke:#000,stroke-width:1px;
classDef control fill:#8FBC8F,stroke:#000,stroke-width:1px;
classDef database fill:#FFDAB9,stroke:#000,stroke-width:1px;
classDef config fill:#DDA0DD,stroke:#000,stroke-width:1px;
```
