# nulluo/chirinulluo.mahjong architecture

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

- Interactive diagram: https://gitdiagram.com/nulluo/chirinulluo.mahjong
- Repository: https://github.com/nulluo/chirinulluo.mahjong

## Overview

##### Major Components
- Game Core (ChiriNulluo.Mahjong.Core)
- Contains fundamental classes for game management such as MatchManager, RoundManager, Tiles, Hand, Yaku, and various player implementations (Human and COM).
- Represents the core domain model and game logic.
- Extension Modules (ChiriNulluo.Mahjong.Precure)
- Provides extra features or themed versions of game logic (e.g., specialized hand checking, XML configuration for game rules, and constants).
- User Interface (ChiriNulluo.Mahjong.WinFormApplication)
- Implements the graphical user interface using Windows Forms.
- Contains components for displaying game elements: Views, Forms, Controls (tile displays, replay forms, score panels, etc.), and multimedia objects (sounds, images).
- Starter/Launcher (ChiriNulluo.Mahjong.Starter)
- Likely responsible for initializing and starting the game.
- Testing (ChiriNulluo.Mahjong.Test)
- Contains unit tests for the core game logic and extensions.
- Tools (ChiriNulluo.Mahjong.Tools)
- Provides utilities such as release XML creation, tile displays, and probably management tools for debugging or updates.
- Online Updater (ChiriNulluo.OnlineUpdater)
- Manages software update tasks, including download, version comparison, and release notes display.
- Additional small projects (TestProgram, various .asta files) that could serve as demos, test beds, or legacy projects.

##### Relationships and Data Flow
- The Game Core is the backbone; it provides services to the UI layer.
- The Precure module and its related players, hand checkers, and data access layers extend or modify the core functionality. Illustrate these as a separate module that “plugs into” the game core.
- Tools may interact both with the core (for, say, examining release data or debugging game rules) and with external systems (like build or release management). Represent these interactions accordingly.

##### Architectural Patterns and Design Principles
- The code is organized into loose modules following separation of concerns.
- Domain logic (players, tiles, game round, yaku) is nicely separated from presentation (views/forms in the WinFormApplication).
- The use of factory methods (e.g., COMPlayerFactory, PrecureCOMHandFactory) and facades (like RoundFacade) indicate common design patterns.
- There is an abstraction for COM player algorithms, hinting at extensibility for AI/COM strategies.

##### Technologies and Dependencies
- The project is written in Visual Basic (.vbproj files) and uses Windows Forms for UI.
- It utilizes external libraries like NLog for logging—a component present in multiple modules.
- NUnit is used for testing, as evidenced by the NUnit packages.
- XML is used for configuration in various parts (for example, CureJongConfig.xml, NLog.config, UpdateLog.xml).

##### Elements
- Labels for each major module: “Game Core”, “Precure Module”, “WinForm UI”, “Online Updater”, “Tools”, “Testing”.
- UI interactions with the Facade and Core.
- Data flow from the Core (game state and tile management) to the UI.
- External dependencies such as logging (NLog) and XML configurations.
- Frontend vs. backend.
- Core domain logic vs. supporting tooling.
- In-house modules vs. external system dependencies.

##### Summary of Steps for the Principal Software Engineer
- On the design patterns: indicate where factories, facades, and abstraction layers exist.
- Clearly label every component and interaction, specifying technology notes (e.g., “Uses NLog for logging”, “XML-driven configuration in Precure modules”).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Application Layer"
        Starter("Starter/Launcher"):::app
        UI("WinForm UI"):::app
    end

    subgraph "Core Layer"
        Core("Game Core"):::core
        Precure("Precure Module"):::core
    end

    subgraph "Utility Layer"
        Tools("Tools/Utility"):::util
        Updater("Online Updater"):::util
        XMLLogging("XML & Logging (NLog,XML)"):::util
    end

    Testing("Testing"):::test

    %% Connections
    Starter -->|"initiates"| UI
    UI -->|"callsFacade"| Core
    UI -->|"receivesUpdates"| Updater
    Core <-->|"extendedBy"| Precure
    Testing -->|"testsCore"| Core
    Testing -->|"testsPrecure"| Precure
    Tools -->|"assists"| Core
    Updater -->|"integratesWith"| Tools
    XMLLogging --- Core
    XMLLogging --- Precure
    XMLLogging --- Tools

    %% Click Events
    click Core "https://github.com/nulluo/chirinulluo.mahjong/blob/master/ChiriNulluo.Mahjong.Core"
    click Precure "https://github.com/nulluo/chirinulluo.mahjong/blob/master/ChiriNulluo.Mahjong.Precure"
    click UI "https://github.com/nulluo/chirinulluo.mahjong/blob/master/ChiriNulluo.Mahjong.WinFormApplication"
    click Starter "https://github.com/nulluo/chirinulluo.mahjong/blob/master/ChiriNulluo.Mahjong.Starter"
    click Testing "https://github.com/nulluo/chirinulluo.mahjong/blob/master/ChiriNulluo.Mahjong.Test"
    click Tools "https://github.com/nulluo/chirinulluo.mahjong/blob/master/ChiriNulluo.Mahjong.Tools"
    click Updater "https://github.com/nulluo/chirinulluo.mahjong/blob/master/ChiriNulluo.OnlineUpdater"

    %% Styles
    classDef app fill:#87cefa,stroke:#000,stroke-width:2px;
    classDef core fill:#f4a460,stroke:#000,stroke-width:2px;
    classDef util fill:#dda0dd,stroke:#000,stroke-width:2px;
    classDef test fill:#ffb6c1,stroke:#000,stroke-width:2px;
```
