# uahh/toastfish architecture

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

- Interactive diagram: https://gitdiagram.com/uahh/toastfish
- Repository: https://github.com/uahh/toastfish

## Overview

##### Project type and purpose
- ToastFish is a Windows desktop application built in WPF/.NET 4.7.2 following the MVVM pattern.
- Its purpose is to quietly push vocabulary words via Windows 10 notifications (Tray toasts), play pronunciations, track progress in a local SQLite DB, and allow custom word imports.

##### File structure
- Top-level files: App.xaml(.cs) (startup), App.config, ToastFish.sln/.csproj, README, LICENSE.
- MVC-style separation:
- View/: XAML views (ToastFish.xaml)
- ViewModel/: ViewModelLocator, ToastFishModel.cs
- Model/: domain modules (Log, Mp3, PushControl, SM2plus algorithm, SqliteControl, StartWithWindows)
- .github/workflows: CI pipeline for .NET Desktop

##### README
- Describes features: choose word library, set count, start memorization, testing, record logs (.xlsx under Log folder), import or customize words via Excel template, Windows 10 requirement.
- Tech stack: WPF, MVVM, local SQLite, Windows notification API, .NET 4.7.2

##### Main components & their interactions
a. UI Layer (View)
- ToastFish.xaml: user controls for selecting libraries, count, start/test flow
- Binds to ViewModel via ViewModelLocator
b. Presentation Logic (ViewModel)
- ToastFishModel: orchestrates user actions, invokes Model services, exposes Commands & Observable properties
c. Domain/Service Layer (Model)
- PushControl: builds and schedules notification payloads (PushWords, PushCustomizeWords, PushGoinWords, PushJpWords)
- Mp3: DownloadMp3, PlayMp3 for pronunciation (uses local Resources/Goin mp3s or remote if configured)
- SqliteControl: data persistence (Select.cs) reading/writing review history (inami.db)
- Log: CreateLog writes session logs (.xlsx in Log folder)
- SM2plus: spaced-repetition algorithm (Card.cs, Parameters.cs)
- StartWithWindows: HotKey.cs & startup registration
d. External Dependencies
- Windows 10 Toast Notification Center
- Local .db files, .xlsx templates & generated logs
- Excel engine/library (implicit via .NET interop)

Data flow summary:
User → View → ViewModel
→ invokes Model services (SM2 scheduling, DB reads)
→ PushControl schedules Windows◎Notifications
→ Mp3 service plays audio
→ On session end, Log service writes .xlsx; SQLite persists status

##### Architectural patterns & principles
- MVVM: clear separation of View, ViewModel, Model
- Layered architecture: Presentation → Application → Domain → Infrastructure
- Dependency injection via ViewModelLocator (if used)
- Single responsibility per sub-module (Push, DB, Audio, Logging)
- Extensibility: custom Excel template for user-defined words

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    subgraph "UI Layer"
        direction TB
        View["WPF View\n(ToastFish.xaml)"]:::ui
    end

    %% Application Layer
    subgraph "ViewModel Layer"
        direction TB
        VMLocator["ViewModel Locator"]:::vm
        ToastFishModel["ToastFishModel"]:::vm
    end

    %% Domain/Model Layer
    subgraph "Domain/Model Layer"
        direction TB
        subgraph "PushControl Module"
            direction TB
            PushWords["PushWords"]:::domain
            PushCustomizeWords["PushCustomizeWords"]:::domain
            PushGoinWords["PushGoinWords"]:::domain
            PushJpWords["PushJpWords"]:::domain
            WordType["WordType enum"]:::domain
        end
        Mp3Service["Mp3 Service\n(Download & Play)"]:::domain
        SqliteService["SQLite Service\n(Select Operations)"]:::domain
        LogService["Log Service\n(CreateLog)"]:::domain
        SM2plus["Spaced-Repetition\n(SM2plus)"]:::domain
        StartupService["Startup & Hotkey\n(StartupService)"]:::domain
    end

    %% Infrastructure / External
    subgraph "Infrastructure/External"
        direction TB
        DBFile["inami.db"]:::storage
        ExcelTemplate["Excel Template"]:::storage
        MP3Files["Pronunciation MP3s"]:::storage
        NotificationAPI["Windows Notification Center"]:::external
        AudioDriver["Audio Driver"]:::external
        FileSystem["File System"]:::external
    end

    %% Connections
    View -->|"binds to"| VMLocator
    VMLocator -->|"resolves"| ToastFishModel

    ToastFishModel -->|"uses"| SM2plus
    ToastFishModel -->|"calls"| SqliteService
    ToastFishModel -->|"calls"| PushWords
    ToastFishModel -->|"calls"| Mp3Service
    ToastFishModel -->|"calls"| LogService
    ToastFishModel -->|"calls"| StartupService

    PushWords -->|"enum"| WordType
    PushCustomizeWords --> WordType
    PushGoinWords --> WordType
    PushJpWords --> WordType

    PushWords -->|"schedules"| NotificationAPI
    NotificationAPI -->|"push toast"| View

    Mp3Service -->|"reads from"| MP3Files
    Mp3Service -->|"plays via"| AudioDriver

    SqliteService -->|"reads/writes"| DBFile

    LogService -->|"writes"| FileSystem

    StartupService -->|"register startup"| FileSystem

    %% Click Events
    click View "https://github.com/uahh/toastfish/blob/main/View/ToastFish.xaml"
    click VMLocator "https://github.com/uahh/toastfish/blob/main/ViewModel/ViewModelLocator.cs"
    click ToastFishModel "https://github.com/uahh/toastfish/blob/main/ViewModel/ToastFishModel.cs"
    click PushWords "https://github.com/uahh/toastfish/blob/main/Model/PushControl/PushWords.cs"
    click PushCustomizeWords "https://github.com/uahh/toastfish/blob/main/Model/PushControl/PushCustomizeWords.cs"
    click PushGoinWords "https://github.com/uahh/toastfish/blob/main/Model/PushControl/PushGoinWords.cs"
    click PushJpWords "https://github.com/uahh/toastfish/blob/main/Model/PushControl/PushJpWords.cs"
    click WordType "https://github.com/uahh/toastfish/blob/main/Model/PushControl/WordType.cs"
    click Mp3Service "https://github.com/uahh/toastfish/blob/main/Model/Mp3/DownloadMp3.cs"
    click Mp3Service "https://github.com/uahh/toastfish/blob/main/Model/Mp3/PlayMp3.cs"
    click SqliteService "https://github.com/uahh/toastfish/blob/main/Model/SqliteControl/Select.cs"
    click DBFile "https://github.com/uahh/toastfish/blob/main/Resources/inami.db"
    click LogService "https://github.com/uahh/toastfish/blob/main/Model/Log/CreateLog.cs"
    click SM2plus "https://github.com/uahh/toastfish/blob/main/Model/SM2plus/Card.cs"
    click SM2plus "https://github.com/uahh/toastfish/blob/main/Model/SM2plus/Parameters.cs"
    click StartupService "https://github.com/uahh/toastfish/blob/main/Model/StartWithWindows/StartWithWindows.cs"
    click StartupService "https://github.com/uahh/toastfish/blob/main/Model/StartWithWindows/HotKey.cs"

    %% Styles
    classDef ui fill:#B3DDF2,stroke:#333,stroke-width:1px
    classDef vm fill:#C6E2A3,stroke:#333,stroke-width:1px
    classDef domain fill:#F7C873,stroke:#333,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef storage fill:#FFFFFF,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5
```
