# aicelen/andromr architecture

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

- Interactive diagram: https://gitdiagram.com/aicelen/andromr
- Repository: https://github.com/aicelen/andromr

## Overview

Andromr is an on-device Android optical music recognition app: users scan or open score images, run recognition, and share the resulting MusicXML. The main runtime spans image preparation and staff/symbol analysis, neural-model inference, score parsing, and XML generation. README documents multi-page input, local privacy, LiteRT encoder/segmentation, and an ONNX decoder. The excerpts do not show all UI callbacks or the complete recognition orchestration, so uncertain internal call links are omitted; the documented model roles and paths are represented.

Main entry points: [`homr/main.py`](https://github.com/aicelen/andromr/blob/main/homr/main.py) (Recognition workflow), [`main.py`](https://github.com/aicelen/andromr/blob/main/main.py) (Scan and export UI), [`homr/transformer/staff2score.py`](https://github.com/aicelen/andromr/blob/main/homr/transformer/staff2score.py) (Staff to score), [`homr/tr_omr_parser.py`](https://github.com/aicelen/andromr/blob/main/homr/tr_omr_parser.py) (Token score parser)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Android app"]
  node_ui["Scan and export UI<br/>[main.py]"]
  node_homr["Recognition workflow<br/>[main.py]"]
end

subgraph group_vision["Image analysis"]
  node_image["Image preparation<br/>[image_utils.py]"]
  node_staff["Staff analysis<br/>[staff_detection.py]"]
  node_symbols["Symbol detection<br/>[note_detection.py]"]
  node_staffparse["Staff parsing<br/>[staff_parsing.py]"]
end

subgraph group_inference["Model inference"]
  node_seg["Segmentation inference"]
  node_staff2score["Staff to score<br/>[staff2score.py]"]
  node_encoder["Transformer encoder"]
  node_decoder["Transformer decoder"]
  node_java["Android inference bridge<br/>[Staff2Score.java]"]
  node_litert["LiteRT model runtime<br/>[LiteRTModel.java]"]
end

subgraph group_score["Score output"]
  node_parser["Token score parser<br/>[tr_omr_parser.py]"]
  node_results["Structured score<br/>[results.py]"]
  node_xml["MusicXML generation"]
  node_xmlgen["XML serialization<br/>[xml_generator.py]"]
end

node_user(("Score user"))
node_share(("Share target"))

node_user -->|"scans or opens"| node_ui
node_ui -->|"starts recognition"| node_homr
node_homr -->|"prepares image"| node_image
node_homr -->|"requests segmentation"| node_seg
node_homr -->|"analyzes staffs"| node_staff
node_homr -->|"detects symbols"| node_symbols
node_homr -->|"parses staffs"| node_staffparse
node_staff2score -->|"encodes staff"| node_encoder
node_staff2score -->|"decodes score"| node_decoder
node_java -->|"runs LiteRT"| node_litert
node_homr -->|"requests score inference"| node_staff2score
node_homr -->|"parses tokens"| node_parser
node_parser -->|"produces score"| node_results
node_homr -->|"generates MusicXML"| node_xml
node_xml -->|"serializes output"| node_xmlgen
node_ui -->|"shares export"| node_share

click node_ui "https://github.com/aicelen/andromr/blob/main/main.py"
click node_homr "https://github.com/aicelen/andromr/blob/main/homr/main.py"
click node_image "https://github.com/aicelen/andromr/blob/main/homr/image_utils.py"
click node_seg "https://github.com/aicelen/andromr/blob/main/homr/segmentation/inference_segnet.py"
click node_staff "https://github.com/aicelen/andromr/blob/main/homr/staff_detection.py"
click node_symbols "https://github.com/aicelen/andromr/blob/main/homr/note_detection.py"
click node_staffparse "https://github.com/aicelen/andromr/blob/main/homr/staff_parsing.py"
click node_staff2score "https://github.com/aicelen/andromr/blob/main/homr/transformer/staff2score.py"
click node_encoder "https://github.com/aicelen/andromr/blob/main/homr/transformer/encoder_inference.py"
click node_decoder "https://github.com/aicelen/andromr/blob/main/homr/transformer/decoder_inference.py"
click node_java "https://github.com/aicelen/andromr/blob/main/java/Staff2Score.java"
click node_litert "https://github.com/aicelen/andromr/blob/main/java/LiteRTModel.java"
click node_parser "https://github.com/aicelen/andromr/blob/main/homr/tr_omr_parser.py"
click node_results "https://github.com/aicelen/andromr/blob/main/homr/results.py"
click node_xml "https://github.com/aicelen/andromr/blob/main/homr/music_xml_generator.py"
click node_xmlgen "https://github.com/aicelen/andromr/blob/main/homr/xml_generator.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_ui,node_homr,node_user toneBlue
class node_image,node_staff,node_symbols,node_staffparse toneAmber
class node_seg,node_staff2score,node_encoder,node_decoder,node_java,node_litert toneMint
class node_parser,node_results,node_xml,node_xmlgen toneRose
class node_share toneIndigo
```

## Components

### Android app

- [Scan and export UI](https://github.com/aicelen/andromr/blob/main/main.py): `main.py`
- [Recognition workflow](https://github.com/aicelen/andromr/blob/main/homr/main.py): `homr/main.py`

### Image analysis

- [Image preparation](https://github.com/aicelen/andromr/blob/main/homr/image_utils.py): `homr/image_utils.py`
- [Staff analysis](https://github.com/aicelen/andromr/blob/main/homr/staff_detection.py): `homr/staff_detection.py`
- [Symbol detection](https://github.com/aicelen/andromr/blob/main/homr/note_detection.py): `homr/note_detection.py`
- [Staff parsing](https://github.com/aicelen/andromr/blob/main/homr/staff_parsing.py): `homr/staff_parsing.py`

### Model inference

- [Segmentation inference](https://github.com/aicelen/andromr/blob/main/homr/segmentation/inference_segnet.py): `homr/segmentation/inference_segnet.py`
- [Staff to score](https://github.com/aicelen/andromr/blob/main/homr/transformer/staff2score.py): `homr/transformer/staff2score.py`
- [Transformer encoder](https://github.com/aicelen/andromr/blob/main/homr/transformer/encoder_inference.py): `homr/transformer/encoder_inference.py`
- [Transformer decoder](https://github.com/aicelen/andromr/blob/main/homr/transformer/decoder_inference.py): `homr/transformer/decoder_inference.py`
- [Android inference bridge](https://github.com/aicelen/andromr/blob/main/java/Staff2Score.java): `java/Staff2Score.java`
- [LiteRT model runtime](https://github.com/aicelen/andromr/blob/main/java/LiteRTModel.java): `java/LiteRTModel.java`

### Score output

- [Token score parser](https://github.com/aicelen/andromr/blob/main/homr/tr_omr_parser.py): `homr/tr_omr_parser.py`
- [Structured score](https://github.com/aicelen/andromr/blob/main/homr/results.py): `homr/results.py`
- [MusicXML generation](https://github.com/aicelen/andromr/blob/main/homr/music_xml_generator.py): `homr/music_xml_generator.py`
- [XML serialization](https://github.com/aicelen/andromr/blob/main/homr/xml_generator.py): `homr/xml_generator.py`

### Other components

- **Score user**
- **Share target**

## Connections

- Score user → Scan and export UI: scans or opens
- Scan and export UI → Recognition workflow: starts recognition
- Recognition workflow → Image preparation: prepares image
- Recognition workflow → Segmentation inference: requests segmentation
- Recognition workflow → Staff analysis: analyzes staffs
- Recognition workflow → Symbol detection: detects symbols
- Recognition workflow → Staff parsing: parses staffs
- Staff to score → Transformer encoder: encodes staff
- Staff to score → Transformer decoder: decodes score
- Android inference bridge → LiteRT model runtime: runs LiteRT
- Recognition workflow → Staff to score: requests score inference
- Recognition workflow → Token score parser: parses tokens
- Token score parser → Structured score: produces score
- Recognition workflow → MusicXML generation: generates MusicXML
- MusicXML generation → XML serialization: serializes output
- Scan and export UI → Share target: shares export
