# neemzaza/hearpiano architecture

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

- Interactive diagram: https://gitdiagram.com/neemzaza/hearpiano
- Repository: https://github.com/neemzaza/hearpiano

## Overview

##### Project Type and Purpose
- This is a Swift-based music training app that combines interactive gameplay with piano tuning simulation. The app’s purpose is to help users improve their note-hearing skills while engaging in a “Piano tuner Job” experience.

##### File Structure
- Notice the presence of a main directory (HearPiano.swiftpm) that includes:
- Component directory: with files like PianoUpright.swift and TuningStick.swift – these are likely UI or interactive components representing the physical parts of a piano.
- Multiple view files: ContentView.swift, WelcomeScreen.swift, CourseList.swift, PracticeView.swift – these control the various screens.
- LearnPage directory: containing modules such as EarTrain.swift and a nested pianotuner folder with PianoTuner.swift – used for the music training gameplay.
- Function directory: including Function.swift – this likely encapsulates core logic or shared functionality.
- Resources directory: with subdirectories for sound effects, piano note audio, and even music tracks.
- The existence of the Package.swift and Package.resolved indicates dependency management and build configuration, but for system design, your focus is more on functional components rather than low-level build details.

##### Main Components
a. UI/Presentation Layer:
- Main App Entry: MyApp.swift that initializes the SwiftUI app.
- Main Views: ContentView.swift, WelcomeScreen.swift, CourseList.swift, PracticeView.swift.
- Learn & Training Modules: EarTrain.swift and PianoTuner.swift under LearnPage.
b. Component Subsystem:
- Reusable Components: Files in the Component directory (PianoUpright.swift, TuningStick.swift) are used to represent interactive or visual elements of the piano.
c. Core Functionality:
- Business Logic: Function.swift might encapsulate core functions like scorekeeping, game progression, or tuning algorithms.
d. Media Resources:
- Assets: The Assets.xcassets directory for images and branding.
- Audio Engine: Resources directory holds sound effects (in the Effect subfolder) and the note samples (HighNote5, Music, and other wav/m4a files).
e. External Integration:
- While there are no explicit external API clients present, the use of external media (licensed assets) and possible Swift Package Manager dependencies may be indicated in the Package.swift file.

##### Relationships and Interactions
- App start-up (MyApp.swift) initializes the UI and routes to the WelcomeScreen.
- The navigation from the WelcomeScreen leads to CourseList, PracticeView, or LearnPage modules.
- Within LearnPage, user interactions (e.g., playing an interactive piano tuning game) invoke both UI components (from Component folder) and business logic (Function.swift).
- Sound and media assets are fetched from the Resources directory to generate audio feedback aligning with user actions.
- Assets like images used in the UI are drawn from the Assets.xcassets folder.
- The overall architecture exhibits a separation of concerns: UI views, modular components, business logic, and media resources.

##### Final Checklist
- Every key module from the file tree is represented – from the main entry point down to the resource files.
- Interactions: user action in the UI triggering audio playback (via resources) or engaging components (via the business logic).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend/UI Layer
    subgraph "Frontend/UI Layer"
        A["MyApp.swift – App Entry Point"]:::ui
        B["ContentView.swift – Main UI"]:::ui
        C["WelcomeScreen.swift – Welcome Screen"]:::ui
        D["CourseList.swift – Course List"]:::ui
        E["PracticeView.swift – Practice View"]:::ui
    end

    %% Learn & Training Modules
    subgraph "Learn & Training Modules"
        F["EarTrain.swift – Ear Training Module"]:::learn
        G["PianoTuner.swift – Piano Tuning Module"]:::learn
    end

    %% Interactive Components
    subgraph "Interactive Components"
        H["PianoUpright.swift – Piano Upright Component"]:::comp
        I["TuningStick.swift – Tuning Stick Component"]:::comp
    end

    %% Core Business Logic
    subgraph "Core Business Logic"
        J["Function.swift – Business Logic"]:::logic
    end

    %% Media Resources
    subgraph "Media Resources"
        K["Assets.xcassets – Visual Assets"]:::res
        L["Sound Effects"]:::res
        M["HighNote5 – Note Samples"]:::res
        N["Music – Audio Tracks"]:::res
    end

    %% Connections between Frontend/UI components
    A -->|"initializes"| C
    A -->|"loads"| B
    C -->|"navigates"| D
    C -->|"navigates"| E
    C -->|"navigates"| F
    C -->|"navigates"| G

    %% Connections to Business Logic
    B -->|"triggers"| J
    F -->|"triggers"| J
    G -->|"triggers"| J

    %% Connections from Learn Modules to Interactive Components
    F -->|"uses"| H
    F -->|"uses"| I
    G -->|"uses"| H
    G -->|"uses"| I

    %% Business Logic triggering Media Resources
    J -->|"plays"| L
    J -->|"plays"| M
    J -->|"plays"| N

    %% Visual Assets feeding UI components
    K -->|"supplies"| B
    K -->|"supplies"| C

    %% Styling Classes
    classDef ui fill:#ffd1dc,stroke:#333,stroke-width:2px;
    classDef learn fill:#ffe699,stroke:#333,stroke-width:2px;
    classDef comp fill:#c6f7d0,stroke:#333,stroke-width:2px;
    classDef logic fill:#c8d1ff,stroke:#333,stroke-width:2px;
    classDef res fill:#fff5ba,stroke:#333,stroke-width:2px;

    %% Click Events for Frontend/UI Layer
    click A "https://github.com/neemzaza/hearpiano/blob/main/HearPiano.swiftpm/MyApp.swift"
    click B "https://github.com/neemzaza/hearpiano/blob/main/HearPiano.swiftpm/ContentView.swift"
    click C "https://github.com/neemzaza/hearpiano/blob/main/HearPiano.swiftpm/WelcomeScreen.swift"
    click D "https://github.com/neemzaza/hearpiano/blob/main/HearPiano.swiftpm/CourseList.swift"
    click E "https://github.com/neemzaza/hearpiano/blob/main/HearPiano.swiftpm/PracticeView.swift"

    %% Click Events for Learn & Training Modules
    click F "https://github.com/neemzaza/hearpiano/blob/main/HearPiano.swiftpm/LearnPage/EarTrain.swift"
    click G "https://github.com/neemzaza/hearpiano/blob/main/HearPiano.swiftpm/LearnPage/pianotuner/PianoTuner.swift"

    %% Click Events for Interactive Components
    click H "https://github.com/neemzaza/hearpiano/blob/main/HearPiano.swiftpm/Component/PianoUpright.swift"
    click I "https://github.com/neemzaza/hearpiano/blob/main/HearPiano.swiftpm/Component/TuningStick.swift"

    %% Click Event for Business Logic
    click J "https://github.com/neemzaza/hearpiano/blob/main/HearPiano.swiftpm/Function/Function.swift"

    %% Click Events for Media Resources
    click K "https://github.com/neemzaza/hearpiano/blob/main/HearPiano.swiftpm/Assets.xcassets"
    click L "https://github.com/neemzaza/hearpiano/tree/main/HearPiano.swiftpm/Resources/Effect"
    click M "https://github.com/neemzaza/hearpiano/tree/main/HearPiano.swiftpm/Resources/HighNote5"
    click N "https://github.com/neemzaza/hearpiano/tree/main/HearPiano.swiftpm/Resources/Music"
```
