# xujiangjiang/easy-cat-timer architecture

> Architecture diagram of the GitHub repository xujiangjiang/easy-cat-timer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/xujiangjiang/easy-cat-timer
- Repository: https://github.com/xujiangjiang/easy-cat-timer

## Overview

##### Main Components
- User Interface (UI) Layer:
– MainWindow (MainWindow.xaml and its code-behind) presenting the main timer interface.
– NotificationWindow (NotificationWindow.xaml) for popup notifications.
– Custom XAML controls and styles (found in the Xaml/Control, Xaml/Dictionary, and Xaml/Style folders) used throughout the UI.
- Core System Services:
– AppManager.cs acts as the central orchestrator that initializes and manages the windows, logic, and data objects.
– Timer/Time System (TimeSystem.cs) for the countdown functionality.
– Audio System (AudioSystem.cs) that plays various sound effects stored in the Asset/Audio folder.
– Language and Localization (LanguageSystem.cs) for handling text (with resources stored in Xaml/Dictionary).
– Save System (SaveSystem.cs) for persisting settings and states.
- Data Models:
– Data classes located in Code/Data (e.g., AppDatas.cs, SettingData.cs, StateData.cs, TimeData.cs) which support data binding to the UI.
- Assets & Resources:
– Asset folder contains fonts, images, and audio files necessary for the visual and audio aesthetics.
– Xaml resources (styles and dictionaries) support UI theming and localization.

##### Relationships and Interactions
- The AppManager serves as the central hub that ties the UI layer and the system services together. It instantiates and coordinates the timer, audio notifications, language changes, and saving actions.
- The MainWindow acts as the primary UI element and is connected to various data models via WPF data binding. User actions in the MainWindow will trigger calls to the underlying systems (e.g., TimeSystem or AudioSystem).
- When the countdown reaches its endpoint, the TimeSystem notifies both the NotificationSystem and the AudioSystem, which in turn trigger the NotificationWindow to appear and play the appropriate sounds.
- The SaveSystem and LanguageSystem ensure that user settings persist and that the UI supports multiple languages.

##### Architectural Patterns and Design Principles
- Separation of Concerns: There is a clear split between UI layers (XAML and code-behind) and business logic (services in Code/System and data classes in Code/Data).
- Data Binding: Leveraging WPF’s native data binding to connect the UI (defined in XAML) to the underlying data models—this is evident from the project’s structure and comments.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    subgraph "UI Layer"
        MWX["MainWindow.xaml (UI)"]:::ui
        MWXB["MainWindow.xaml.cs (UI)"]:::ui
        NWX["NotificationWindow.xaml (UI)"]:::ui
        NWXB["NotificationWindow.xaml.cs (UI)"]:::ui
        CC["Custom Controls (Xaml/Control)"]:::ui
        XS["Xaml Styles"]:::ui
        XD["Xaml Dictionaries"]:::ui
    end

    %% Core Services
    subgraph "Core Services"
        AM["AppManager.cs"]:::service
        TS["TimeSystem.cs"]:::service
        AS["AudioSystem.cs"]:::service
        LS["LanguageSystem.cs"]:::service
        SS["SaveSystem.cs"]:::service
        NS["NotificationSystem.cs"]:::service
    end

    %% Data Layer
    subgraph "Data Layer"
        DM["Data Models (Code/Data)"]:::data
    end

    %% Assets & Resources
    subgraph "Assets & Resources"
        AA["Audio Assets (Asset/Audio)"]:::asset
        FA["Font Assets (Asset/Font)"]:::asset
        IA["Image Assets (Asset/Image)"]:::asset
    end

    %% Relationships & Interactions
    MWX -->|"triggers"| AM
    AM -->|"manages"| TS
    AM -->|"manages"| AS
    AM -->|"manages"| LS
    AM -->|"manages"| SS
    AM -->|"manages"| NS

    TS -->|"notifies"| AS
    TS -->|"notifies"| NS

    NS -->|"displays"| NWX

    MWX -->|"binds"| DM
    MWX -->|"uses"| CC
    XS -->|"applies"| MWX
    XD -->|"applies"| MWX

    AS -->|"plays"| AA
    MWX -->|"loads"| FA
    MWX -->|"loads"| IA

    LS -->|"utilizes"| XD

    %% Styles
    classDef ui fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef service fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef data fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef asset fill:#f8d7da,stroke:#721c24,stroke-width:2px;

    %% Click Events for UI Layer
    click MWX "https://github.com/xujiangjiang/easy-cat-timer/blob/master/CatTimer WpfProject/MainWindow.xaml"
    click MWXB "https://github.com/xujiangjiang/easy-cat-timer/blob/master/CatTimer WpfProject/MainWindow.xaml.cs"
    click NWX "https://github.com/xujiangjiang/easy-cat-timer/blob/master/CatTimer WpfProject/Code/Notification/NotificationWindow.xaml"
    click NWXB "https://github.com/xujiangjiang/easy-cat-timer/blob/master/CatTimer WpfProject/Code/Notification/NotificationWindow.xaml.cs"
    click CC "https://github.com/xujiangjiang/easy-cat-timer/tree/master/CatTimer WpfProject/Xaml/Control"
    click XS "https://github.com/xujiangjiang/easy-cat-timer/tree/master/CatTimer WpfProject/Xaml/Style"
    click XD "https://github.com/xujiangjiang/easy-cat-timer/tree/master/CatTimer WpfProject/Xaml/Dictionary"

    %% Click Events for Core Services
    click AM "https://github.com/xujiangjiang/easy-cat-timer/blob/master/CatTimer WpfProject/AppManager.cs"
    click TS "https://github.com/xujiangjiang/easy-cat-timer/blob/master/CatTimer WpfProject/Code/System/TimeSystem.cs"
    click AS "https://github.com/xujiangjiang/easy-cat-timer/blob/master/CatTimer WpfProject/Code/System/AudioSystem.cs"
    click LS "https://github.com/xujiangjiang/easy-cat-timer/blob/master/CatTimer WpfProject/Code/System/LanguageSystem.cs"
    click SS "https://github.com/xujiangjiang/easy-cat-timer/blob/master/CatTimer WpfProject/Code/System/SaveSystem.cs"
    click NS "https://github.com/xujiangjiang/easy-cat-timer/blob/master/CatTimer WpfProject/Code/Notification/NotificationSystem.cs"

    %% Click Event for Data Layer
    click DM "https://github.com/xujiangjiang/easy-cat-timer/tree/master/CatTimer WpfProject/Code/Data"

    %% Click Events for Assets & Resources
    click AA "https://github.com/xujiangjiang/easy-cat-timer/tree/master/CatTimer WpfProject/Asset/Audio"
    click FA "https://github.com/xujiangjiang/easy-cat-timer/tree/master/CatTimer WpfProject/Asset/Font"
    click IA "https://github.com/xujiangjiang/easy-cat-timer/tree/master/CatTimer WpfProject/Asset/Image"
```
