# matthewkeah/harmonyapp architecture

> Architecture diagram of the GitHub repository matthewkeah/harmonyapp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/matthewkeah/harmonyapp
- Repository: https://github.com/matthewkeah/harmonyapp

## Overview

Smart Harmony Assistant is a desktop score editor and four-part harmony critique tool. The main workflow is to load or import a score, submit it for chord and voice-leading analysis, and inspect faults and transition ratings on the manuscript and in the Red Pen Report. The graph also shows score editing, playback, and settings. Several connections are documented in the README or import references in the SOURCE INDEX; unsampled implementations are represented only where documented, and uncertain links are omitted.

Main entry points: [`app.py`](https://github.com/matthewkeah/harmonyapp/blob/main/app.py) (Desktop app), [`harmony.py`](https://github.com/matthewkeah/harmonyapp/blob/main/harmony.py) (Score and slices), [`sheria.py`](https://github.com/matthewkeah/harmonyapp/blob/main/sheria.py) (Fault rule dispatch), [`playback_controller.py`](https://github.com/matthewkeah/harmonyapp/blob/main/playback_controller.py) (Playback control)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_score["Score and input"]
  node_desktop["Desktop app<br/>[app.py]"]
  node_score_files["Score files"]
  node_music_import["Music import"]
  node_bar_layout["Bar layout<br/>[bar_layout.py]"]
  node_score_model["Score and slices<br/>[harmony.py]"]
end

subgraph group_analysis["Harmony analysis"]
  node_figuration["Figuration filter<br/>[figuration.py]"]
  node_chord_analysis["Chord analysis<br/>[sheria_base.py]"]
  node_context["Harmonic context<br/>[harmony_context.py]"]
  node_rule_dispatch["Fault rule dispatch<br/>[sheria.py]"]
  node_fault_passes["Fault passes<br/>[sheria_pass1.py]"]
  node_quality_analysis["Transition quality<br/>[quality.py]"]
  node_grading["Score and report<br/>[gradealgorithm.py]"]
end

subgraph group_results["Critique and display"]
  node_manuscript["Manuscript display<br/>[rendering.py]"]
  node_fault_marks["Fault annotations"]
  node_red_pen["Red Pen Report<br/>[app.py]"]
end

subgraph group_interaction["Editing and playback"]
  node_editor["Score editing<br/>[app.py]"]
  node_settings["Playback settings<br/>[settings_ui.py]"]
  node_playback_control["Playback control"]
  node_playback_engine["MIDI playback<br/>[engine.py]"]
end

subgraph group_rules["Rule definitions"]
  node_fault_rules["Fault rule data<br/>[rules_pass1.json]"]
  node_quality_rules["Quality rule data<br/>[quality_pass1.json]"]
end

node_musician(("Musician"))
node_audio(("Audio output"))

node_musician -->|"uses"| node_desktop
node_musician -->|"opens"| node_score_files
node_score_files -->|"imports"| node_music_import
node_music_import -->|"creates score"| node_desktop
node_desktop -->|"uses layout"| node_bar_layout
node_desktop -->|"builds slices"| node_score_model
node_score_model -->|"filters onsets"| node_figuration
node_score_model -->|"analyzes slices"| node_chord_analysis
node_chord_analysis -->|"provides chords"| node_context
node_desktop -->|"submits analysis"| node_rule_dispatch
node_rule_dispatch -->|"registers passes"| node_fault_passes
node_rule_dispatch -->|"loads rules"| node_fault_rules
node_desktop -->|"rates transitions"| node_quality_analysis
node_quality_analysis -->|"loads rules"| node_quality_rules
node_desktop -->|"scores faults"| node_grading
node_desktop -->|"draws score"| node_manuscript
node_desktop -->|"draws annotations"| node_fault_marks
node_desktop -->|"shows report"| node_red_pen
node_musician -->|"edits score"| node_editor
node_editor -->|"updates layout"| node_bar_layout
node_editor -->|"updates notes"| node_score_model
node_musician -->|"controls playback"| node_playback_control
node_playback_control -->|"schedules notes"| node_playback_engine
node_playback_engine -->|"plays MIDI"| node_audio
node_musician -->|"configures sound"| node_settings
node_settings -.->|"sets playback"| node_playback_control

click node_desktop "https://github.com/matthewkeah/harmonyapp/blob/main/app.py"
click node_music_import "https://github.com/matthewkeah/harmonyapp/blob/main/validation/convert_musicxml.py"
click node_bar_layout "https://github.com/matthewkeah/harmonyapp/blob/main/bar_layout.py"
click node_score_model "https://github.com/matthewkeah/harmonyapp/blob/main/harmony.py"
click node_figuration "https://github.com/matthewkeah/harmonyapp/blob/main/figuration.py"
click node_chord_analysis "https://github.com/matthewkeah/harmonyapp/blob/main/sheria_base.py"
click node_context "https://github.com/matthewkeah/harmonyapp/blob/main/harmony_context.py"
click node_rule_dispatch "https://github.com/matthewkeah/harmonyapp/blob/main/sheria.py"
click node_fault_passes "https://github.com/matthewkeah/harmonyapp/blob/main/sheria_pass1.py"
click node_fault_rules "https://github.com/matthewkeah/harmonyapp/blob/main/rules_pass1.json"
click node_quality_analysis "https://github.com/matthewkeah/harmonyapp/blob/main/quality.py"
click node_quality_rules "https://github.com/matthewkeah/harmonyapp/blob/main/quality_pass1.json"
click node_grading "https://github.com/matthewkeah/harmonyapp/blob/main/gradealgorithm.py"
click node_manuscript "https://github.com/matthewkeah/harmonyapp/blob/main/rendering.py"
click node_fault_marks "https://github.com/matthewkeah/harmonyapp/blob/main/annotation_formats.py"
click node_red_pen "https://github.com/matthewkeah/harmonyapp/blob/main/app.py"
click node_editor "https://github.com/matthewkeah/harmonyapp/blob/main/app.py"
click node_settings "https://github.com/matthewkeah/harmonyapp/blob/main/settings_ui.py"
click node_playback_control "https://github.com/matthewkeah/harmonyapp/blob/main/playback_controller.py"
click node_playback_engine "https://github.com/matthewkeah/harmonyapp/blob/main/engine.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_desktop,node_score_files,node_music_import,node_bar_layout,node_score_model toneBlue
class node_figuration,node_chord_analysis,node_context,node_rule_dispatch,node_fault_passes,node_quality_analysis,node_grading toneAmber
class node_manuscript,node_fault_marks,node_red_pen toneMint
class node_editor,node_settings,node_playback_control,node_playback_engine toneRose
class node_fault_rules,node_quality_rules,node_musician,node_audio toneIndigo
```

## Components

### Score and input

- [Desktop app](https://github.com/matthewkeah/harmonyapp/blob/main/app.py): `app.py`
- **Score files**
- [Music import](https://github.com/matthewkeah/harmonyapp/blob/main/validation/convert_musicxml.py): `validation/convert_musicxml.py`
- [Bar layout](https://github.com/matthewkeah/harmonyapp/blob/main/bar_layout.py): `bar_layout.py`
- [Score and slices](https://github.com/matthewkeah/harmonyapp/blob/main/harmony.py): `harmony.py`

### Harmony analysis

- [Figuration filter](https://github.com/matthewkeah/harmonyapp/blob/main/figuration.py): `figuration.py`
- [Chord analysis](https://github.com/matthewkeah/harmonyapp/blob/main/sheria_base.py): `sheria_base.py`
- [Harmonic context](https://github.com/matthewkeah/harmonyapp/blob/main/harmony_context.py): `harmony_context.py`
- [Fault rule dispatch](https://github.com/matthewkeah/harmonyapp/blob/main/sheria.py): `sheria.py`
- [Fault passes](https://github.com/matthewkeah/harmonyapp/blob/main/sheria_pass1.py): `sheria_pass1.py`
- [Transition quality](https://github.com/matthewkeah/harmonyapp/blob/main/quality.py): `quality.py`
- [Score and report](https://github.com/matthewkeah/harmonyapp/blob/main/gradealgorithm.py): `gradealgorithm.py`

### Critique and display

- [Manuscript display](https://github.com/matthewkeah/harmonyapp/blob/main/rendering.py): `rendering.py`
- [Fault annotations](https://github.com/matthewkeah/harmonyapp/blob/main/annotation_formats.py): `annotation_formats.py`
- [Red Pen Report](https://github.com/matthewkeah/harmonyapp/blob/main/app.py): `app.py`

### Editing and playback

- [Score editing](https://github.com/matthewkeah/harmonyapp/blob/main/app.py): `app.py`
- [Playback settings](https://github.com/matthewkeah/harmonyapp/blob/main/settings_ui.py): `settings_ui.py`
- [Playback control](https://github.com/matthewkeah/harmonyapp/blob/main/playback_controller.py): `playback_controller.py`
- [MIDI playback](https://github.com/matthewkeah/harmonyapp/blob/main/engine.py): `engine.py`

### Rule definitions

- [Fault rule data](https://github.com/matthewkeah/harmonyapp/blob/main/rules_pass1.json): `rules_pass1.json`
- [Quality rule data](https://github.com/matthewkeah/harmonyapp/blob/main/quality_pass1.json): `quality_pass1.json`

### Other components

- **Musician**
- **Audio output**

## Connections

- Musician → Desktop app: uses (evidence: `readme.md`)
- Musician → Score files: opens (evidence: `readme.md`)
- Score files → Music import: imports (evidence: `readme.md`)
- Music import → Desktop app: creates score (evidence: `readme.md`)
- Desktop app → Bar layout: uses layout (evidence: `app.py`)
- Desktop app → Score and slices: builds slices (evidence: `app.py`)
- Score and slices → Figuration filter: filters onsets (evidence: `readme.md`)
- Score and slices → Chord analysis: analyzes slices (evidence: `readme.md`)
- Chord analysis → Harmonic context: provides chords (evidence: `harmony_context.py`)
- Desktop app → Fault rule dispatch: submits analysis (evidence: `app.py`)
- Fault rule dispatch → Fault passes: registers passes (evidence: `sheria.py`)
- Fault rule dispatch → Fault rule data: loads rules (evidence: `sheria.py`)
- Desktop app → Transition quality: rates transitions (evidence: `app.py`)
- Transition quality → Quality rule data: loads rules (evidence: `readme.md`)
- Desktop app → Score and report: scores faults (evidence: `app.py`)
- Desktop app → Manuscript display: draws score (evidence: `app.py`)
- Desktop app → Fault annotations: draws annotations (evidence: `app.py`)
- Desktop app → Red Pen Report: shows report (evidence: `readme.md`)
- Musician → Score editing: edits score (evidence: `readme.md`)
- Score editing → Bar layout: updates layout (evidence: `app.py`)
- Score editing → Score and slices: updates notes (evidence: `app.py`)
- Musician → Playback control: controls playback (evidence: `readme.md`)
- Playback control → MIDI playback: schedules notes (evidence: `playback_controller.py`)
- MIDI playback → Audio output: plays MIDI (evidence: `readme.md`)
- Musician → Playback settings: configures sound
- Playback settings → Playback control: sets playback
