# tomoyu719/simple_sheet_music architecture

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

- Interactive diagram: https://gitdiagram.com/tomoyu719/simple_sheet_music
- Repository: https://github.com/tomoyu719/simple_sheet_music

## Overview

##### Main components of the system
- Core Library (found in the “lib” directory)
– API/Entry point: simple_sheet_music.dart
– Internal modules: sheet_music_layout, sheet_music_renderer, staff, measure, musical objects (clef, key signature, notes, rest, etc.), font types, glyph metadata/path, extensions, and positioning mixins.
- Example Applications (found in the “example” directory)
– Flutter projects tailored for various platforms demonstrating how the library is used.
– Each example contains platform-specific code (Android, iOS, etc.) that integrates the library.
- Test Suite (found in the “test” directory)
– Contains tests for validating individual modules (e.g., note rendering, measure metrics, extensions, etc.).
- Assets (under “assets”)
– Provide additional data like metadata files for fonts (e.g., bravura_metadata.json, petaluma_metadata.json).

##### Establish the relationships and interactions
- The core library exposes the API for rendering sheet music. Internally, various modules communicate:
– Layout modules (sheet_music_layout, staff/staff_renderer, measure/measure_renderer) work together to compute placement of notation elements.
– Musical object classes (notes, clefs, key signatures, rests) provide data/logic that is used by renderer classes.
- The example applications serve as consuming clients demonstrating how to connect UI (Flutter widgets) with these rendering APIs.
- The test suite validates the behavior of both the layout logic and the rendering components.

##### Architectural patterns and design principles
- Modular design – the project separates concerns neatly into distinct folders (e.g., musical objects, layout, rendering).
- Reusability and Extendability – different notation elements are encapsulated into separate classes and files.
- Clear separation between demonstration code (example) and production library code (lib), which is further reinforced through the tests.

##### Relevant technologies and frameworks
- Pub package ecosystem – managed via pubspec.yaml.
- Testing frameworks – utilized in the “test” directory.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Core Library"
        API["API/Entry Point"]:::core
        Layout["Sheet Music Layout"]:::core
        Renderer["Sheet Music Renderer"]:::core
        StaffRenderer["Staff Renderer"]:::core
        StaffMetrics["Staff Metrics"]:::core
        Measure["Measure Logic"]:::core
        MeasureRenderer["Measure Renderer"]:::core
        MeasureMetrics["Measure Metrics"]:::core

        subgraph "Musical Objects"
            Clef["Clef"]:::core
            ClefType["Clef Type"]:::core
            KeySignature["Key Signature"]:::core
            KeySignatureType["Key Signature Type"]:::core
            Accidental["Accidental"]:::core
            ChordNote["Chord Note"]:::core
            Legerline["Legerline"]:::core
            NoteDuration["Note Duration"]:::core
            NotePitch["Note Pitch"]:::core
            NoteflagType["Noteflag Type"]:::core
            NoteheadType["Notehead Type"]:::core
            Positions["Positions"]:::core
            SingleNote["Single Note"]:::core
            StemDirection["Stem Direction"]:::core
            Rest["Rest"]:::core
            RestType["Rest Type"]:::core
            MusicalSymbol["Musical Symbol"]:::core
            MusicalSymbolMetrics["Musical Symbol Metrics"]:::core
            MusicalSymbolRenderer["Musical Symbol Renderer"]:::core
        end

        subgraph "Font and Glyph"
            FontTypes["Font Types"]:::core
            GlyphMetadata["Glyph Metadata"]:::core
            GlyphPath["Glyph Path"]:::core
        end

        subgraph "Extensions & Mixins"
            ListExtension["List Extension"]:::core
            PositioningMixins["Positioning Mixins"]:::core
        end
    end

    subgraph "Example Applications"
        ExampleApps["Example Applications"]:::examples
        Android["Android"]:::examples
        iOS["iOS"]:::examples
        Linux["Linux"]:::examples
        macOS["macOS"]:::examples
        Web["Web"]:::examples
        Windows["Windows"]:::examples
    end

    subgraph "Test Suite"
        TestSuite["Test Suite"]:::tests
    end

    subgraph "Assets"
        Bravura["Bravura Metadata"]:::assets
        Petaluma["Petaluma Metadata"]:::assets
    end

    %% Relationships within Core Library
    API -->|"exposes"| Layout
    API -->|"exposes"| Renderer
    API -->|"exposes"| StaffRenderer
    API -->|"exposes"| StaffMetrics
    API -->|"exposes"| Measure
    API -->|"exposes"| MeasureRenderer
    API -->|"exposes"| MeasureMetrics
    Layout -->|"supports"| Renderer
    StaffRenderer -->|"aids"| Renderer
    MeasureRenderer -->|"aids"| Renderer
    %% Musical Objects provide data to Renderer
    Clef -->|"providesData"| Renderer
    KeySignature -->|"providesData"| Renderer
    Accidental -->|"providesData"| Renderer
    SingleNote -->|"providesData"| Renderer
    %% Font and Glyph used by Renderer
    FontTypes -->|"usedBy"| Renderer
    GlyphMetadata -->|"usedBy"| Renderer
    GlyphPath -->|"usedBy"| Renderer
    %% Extensions & Mixins assist components
    ListExtension -->|"enhances"| Clef
    PositioningMixins -->|"assists"| StaffRenderer

    %% External Relationships
    ExampleApps -->|"consumes"| API
    Android -->|"platform"| ExampleApps
    iOS -->|"platform"| ExampleApps
    Linux -->|"platform"| ExampleApps
    macOS -->|"platform"| ExampleApps
    Web -->|"platform"| ExampleApps
    Windows -->|"platform"| ExampleApps
    TestSuite -->|"validates"| API
    Renderer -->|"uses"| Bravura
    Renderer -->|"uses"| Petaluma

    %% Classes
    classDef core fill:#a0cee8,stroke:#333,stroke-width:2px;
    classDef examples fill:#f9d5a7,stroke:#333,stroke-width:2px;
    classDef tests fill:#d4a5a5,stroke:#333,stroke-width:2px;
    classDef assets fill:#f7c6c7,stroke:#333,stroke-width:2px;

    %% Click Events
    click API "https://github.com/tomoyu719/simple_sheet_music/blob/main/lib/simple_sheet_music.dart"
    click Layout "https://github.com/tomoyu719/simple_sheet_music/blob/main/lib/src/sheet_music_layout.dart"
    click Renderer "https://github.com/tomoyu719/simple_sheet_music/blob/main/lib/src/sheet_music_renderer.dart"
    click StaffRenderer "https://github.com/tomoyu719/simple_sheet_music/blob/main/lib/src/staff/staff_renderer.dart"
    click StaffMetrics "https://github.com/tomoyu719/simple_sheet_music/blob/main/lib/src/staff/staff_metrics.dart"
    click Measure "https://github.com/tomoyu719/simple_sheet_music/blob/main/lib/src/measure/measure.dart"
    click MeasureRenderer "https://github.com/tomoyu719/simple_sheet_music/blob/main/lib/src/measure/measure_renderer.dart"
    click MeasureMetrics "https://github.com/tomoyu719/simple_sheet_music/blob/main/lib/src/measure/measure_metrics.dart"
    click Clef "https://github.com/tomoyu719/simple_sheet_music/blob/main/lib/src/music_objects/clef/clef.dart"
    click ClefType "https://github.com/tomoyu719/simple_sheet_music/blob/main/lib/src/music_objects/clef/clef_type.dart"
    click KeySignature "https://github.com/tomoyu719/simple_sheet_music/blob/main/lib/src/music_objects/key_signature/key_signature.dart"
    click KeySignatureType "https://github.com/tomoyu719/simple_sheet_music/blob/main/lib/src/music_objects/key_signature/keysignature_type.dart"
    click Accidental "https://github.com/tomoyu719/simple_sheet_music/blob/main/lib/src/music_objects/notes/accidental.dart"
    click ChordNote "https://github.com/tomoyu719/simple_sheet_music/blob/main/lib/src/music_objects/notes/chord_note/chord_note.dart"
    click Legerline "https://github.com/tomoyu719/simple_sheet_music/blob/main/lib/src/music_objects/notes/legerline.dart"
    click NoteDuration "https://github.com/tomoyu719/simple_sheet_music/blob/main/lib/src/music_objects/notes/note_duration.dart"
    click NotePitch "https://github.com/tomoyu719/simple_sheet_music/blob/main/lib/src/music_objects/notes/note_pitch.dart"
    click NoteflagType "https://github.com/tomoyu719/simple_sheet_music/blob/main/lib/src/music_objects/notes/noteflag_type.dart"
    click NoteheadType "https://github.com/tomoyu719/simple_sheet_music/blob/main/lib/src/music_objects/notes/notehead_type.dart"
    click Positions "https://github.com/tomoyu719/simple_sheet_music/blob/main/lib/src/music_objects/notes/positions.dart"
    click SingleNote "https://github.com/tomoyu719/simple_sheet_music/blob/main/lib/src/music_objects/notes/single_note/note.dart"
    click StemDirection "https://github.com/tomoyu719/simple_sheet_music/blob/main/lib/src/music_objects/notes/stem_direction.dart"
    click Rest "https://github.com/tomoyu719/simple_sheet_music/blob/main/lib/src/music_objects/rest/rest.dart"
    click RestType "https://github.com/tomoyu719/simple_sheet_music/blob/main/lib/src/music_objects/rest/rest_type.dart"
    click MusicalSymbol "https://github.com/tomoyu719/simple_sheet_music/blob/main/lib/src/music_objects/interface/musical_symbol.dart"
    click MusicalSymbolMetrics "https://github.com/tomoyu719/simple_sheet_music/blob/main/lib/src/music_objects/interface/musical_symbol_metrics.dart"
    click MusicalSymbolRenderer "https://github.com/tomoyu719/simple_sheet_music/blob/main/lib/src/music_objects/interface/musical_symbol_renderer.dart"
    click FontTypes "https://github.com/tomoyu719/simple_sheet_music/blob/main/lib/src/font_types.dart"
    click GlyphMetadata "https://github.com/tomoyu719/simple_sheet_music/blob/main/lib/src/glyph_metadata.dart"
    click GlyphPath "https://github.com/tomoyu719/simple_sheet_music/blob/main/lib/src/glyph_path.dart"
    click ListExtension "https://github.com/tomoyu719/simple_sheet_music/blob/main/lib/src/extension/list_extension.dart"
    click PositioningMixins "https://github.com/tomoyu719/simple_sheet_music/blob/main/lib/src/music_objects/position_mixin.dart"
    click ExampleApps "https://github.com/tomoyu719/simple_sheet_music/tree/main/example/"
    click Android "https://github.com/tomoyu719/simple_sheet_music/tree/main/example/android"
    click iOS "https://github.com/tomoyu719/simple_sheet_music/tree/main/example/ios"
    click Linux "https://github.com/tomoyu719/simple_sheet_music/tree/main/example/linux"
    click macOS "https://github.com/tomoyu719/simple_sheet_music/tree/main/example/macos"
    click Web "https://github.com/tomoyu719/simple_sheet_music/tree/main/example/web"
    click Windows "https://github.com/tomoyu719/simple_sheet_music/tree/main/example/windows"
    click TestSuite "https://github.com/tomoyu719/simple_sheet_music/tree/main/test/"
    click Bravura "https://github.com/tomoyu719/simple_sheet_music/blob/main/assets/bravura_metadata.json"
    click Petaluma "https://github.com/tomoyu719/simple_sheet_music/blob/main/assets/petaluma_metadata.json"
```
