# somethingwithagun/keyboardsong architecture

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

- Interactive diagram: https://gitdiagram.com/somethingwithagun/keyboardsong
- Repository: https://github.com/somethingwithagun/keyboardsong

## Overview

#### Purpose and entry point
This is a C++ desktop application organized around a central engine, custom-drawn UI widgets, dialogs, and a parser. The executable starts in `main.cpp`, with application coordination likely delegated to `engine.cpp` / `engine.h`.

#### Application orchestration
`engine.cpp` and `engine.h` are the primary control boundary: they likely own application state, initialize UI, route user actions, and coordinate loading, parsing, display, and song-request workflows. Shared compile-time values are centralized in `constants.h`.

Paths: `main.cpp`, `engine.cpp`, `engine.h`, `constants.h`

#### Content parsing and lyric data
`parser.cpp` / `parser.h` form the input-processing boundary for lyric or song content. `date.h` suggests parsed or displayed content may carry date metadata. Parsed results should be treated as domain data consumed by the engine and presentation layer rather than directly coupled to dialog controls.

Paths: `parser.cpp`, `parser.h`, `date.h`

#### Main visualization surface
`plotwidget.cpp` / `plotwidget.h` appear to provide the primary custom rendering surface, likely displaying parsed lyric-related data, timing, or another plotted representation. Drawing primitives are separated into `drawfuncs.cpp` / `drawfuncs.h`, keeping reusable rendering operations outside the widget’s state and event handling.

Paths: `plotwidget.cpp`, `plotwidget.h`, `drawfuncs.cpp`, `drawfuncs.h`

#### UI component layer
The repository implements custom controls instead of relying solely on framework-provided widgets. `button`, `radiobutton`, and `textinput` likely encapsulate rendering, input handling, and control-local state. These components should communicate upward through the engine or owning dialog rather than directly driving parsing or persistence.

Paths: `button.cpp`, `button.h`, `radiobutton.cpp`, `radiobutton.h`, `textinput.cpp`, `textinput.h`

#### Dialog workflows
`dialogbase.cpp` / `dialogbase.h` define a shared dialog abstraction. Specialized dialogs isolate distinct user flows: loading lyrics, requesting songs, and showing information. These dialogs are a boundary between interactive input and engine-level actions.

Paths: `dialogbase.cpp`, `dialogbase.h`, `loadlyricsdialog.cpp`, `requestsongdialog.cpp`, `infodialog.cpp`

#### Primary flow and dependencies
The expected control flow is: `main.cpp` initializes `Engine`; the engine creates or manages the visualization and dialogs; user interaction from custom controls triggers dialog or engine actions; lyric input passes through `Parser`; parsed data is rendered through `PlotWidget` and drawing functions. No external services, deployment infrastructure, or third-party runtime dependencies are identifiable from the supplied tree; the build boundary is CMake via `CMakeLists.txt`.

Paths: `main.cpp`, `engine.cpp`, `parser.cpp`, `plotwidget.cpp`, `CMakeLists.txt`

Main entry points: [`engine.cpp`](https://github.com/somethingwithagun/keyboardsong/blob/master/engine.cpp) (Engine), [`dialogbase.cpp`](https://github.com/somethingwithagun/keyboardsong/blob/master/dialogbase.cpp) (Dialog base), [`main.cpp`](https://github.com/somethingwithagun/keyboardsong/blob/master/main.cpp) (Program entry), [`parser.cpp`](https://github.com/somethingwithagun/keyboardsong/blob/master/parser.cpp) (Parser)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_main(("Program entry<br/>C++ entry point<br/>[main.cpp]"))
  node_engine{{"Engine<br/>application coordinator<br/>[engine.cpp]"}}
  node_constants["Constants<br/>shared values<br/>[constants.h]"]
  node_build["CMake build<br/>build definition<br/>[CMakeLists.txt]"]
end

subgraph group_parsing["Content parsing"]
  node_parser["Parser<br/>[parser.cpp]"]
  node_date["Date metadata<br/>domain data<br/>[date.h]"]
end

subgraph group_ui["UI and dialogs"]
  node_plot["Plot widget<br/>custom visualization<br/>[plotwidget.cpp]"]
  node_drawing["Drawing functions<br/>rendering primitives<br/>[drawfuncs.cpp]"]
  node_dialogbase["Dialog base<br/>dialog abstraction<br/>[dialogbase.cpp]"]
  node_load_dialog["Load lyrics dialog<br/>input workflow"]
  node_request_dialog["Request song dialog<br/>request workflow"]
  node_info_dialog["Info dialog<br/>information workflow<br/>[infodialog.cpp]"]
  node_button["Button<br/>custom control<br/>[button.cpp]"]
  node_radio_button["Radio button<br/>custom control<br/>[radiobutton.cpp]"]
  node_text_input["Text input<br/>custom control<br/>[textinput.cpp]"]
end

node_build -->|"builds executable"| node_main
node_main -->|"initializes"| node_engine
node_engine -->|"uses"| node_constants
node_engine -->|"loads content through"| node_parser
node_parser -->|"produces metadata"| node_date
node_engine -->|"updates display"| node_plot
node_plot -->|"renders with"| node_drawing
node_engine -->|"manages dialogs"| node_dialogbase
node_dialogbase -->|"base for"| node_load_dialog
node_dialogbase -->|"base for"| node_request_dialog
node_dialogbase -->|"base for"| node_info_dialog
node_load_dialog -->|"submits load action"| node_engine
node_request_dialog -->|"submits request"| node_engine
node_button -->|"drives actions"| node_dialogbase
node_radio_button -->|"selects options"| node_dialogbase
node_text_input -->|"provides input"| node_dialogbase

click node_main "https://github.com/somethingwithagun/keyboardsong/blob/master/main.cpp"
click node_engine "https://github.com/somethingwithagun/keyboardsong/blob/master/engine.cpp"
click node_constants "https://github.com/somethingwithagun/keyboardsong/blob/master/constants.h"
click node_build "https://github.com/somethingwithagun/keyboardsong/blob/master/CMakeLists.txt"
click node_parser "https://github.com/somethingwithagun/keyboardsong/blob/master/parser.cpp"
click node_date "https://github.com/somethingwithagun/keyboardsong/blob/master/date.h"
click node_plot "https://github.com/somethingwithagun/keyboardsong/blob/master/plotwidget.cpp"
click node_drawing "https://github.com/somethingwithagun/keyboardsong/blob/master/drawfuncs.cpp"
click node_dialogbase "https://github.com/somethingwithagun/keyboardsong/blob/master/dialogbase.cpp"
click node_load_dialog "https://github.com/somethingwithagun/keyboardsong/blob/master/loadlyricsdialog.cpp"
click node_request_dialog "https://github.com/somethingwithagun/keyboardsong/blob/master/requestsongdialog.cpp"
click node_info_dialog "https://github.com/somethingwithagun/keyboardsong/blob/master/infodialog.cpp"
click node_button "https://github.com/somethingwithagun/keyboardsong/blob/master/button.cpp"
click node_radio_button "https://github.com/somethingwithagun/keyboardsong/blob/master/radiobutton.cpp"
click node_text_input "https://github.com/somethingwithagun/keyboardsong/blob/master/textinput.cpp"

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_main,node_engine,node_constants,node_build toneBlue
class node_parser,node_date toneAmber
class node_plot,node_drawing,node_dialogbase,node_load_dialog,node_request_dialog,node_info_dialog,node_button,node_radio_button,node_text_input toneMint
```

## Components

### Application

- [Program entry](https://github.com/somethingwithagun/keyboardsong/blob/master/main.cpp): C++ entry point · `main.cpp`
- [Engine](https://github.com/somethingwithagun/keyboardsong/blob/master/engine.cpp): application coordinator · Owns state and coordinates UI, parsing, and display. · `engine.cpp`
- [Constants](https://github.com/somethingwithagun/keyboardsong/blob/master/constants.h): shared values · `constants.h`
- [CMake build](https://github.com/somethingwithagun/keyboardsong/blob/master/CMakeLists.txt): build definition · `CMakeLists.txt`

### Content parsing

- [Parser](https://github.com/somethingwithagun/keyboardsong/blob/master/parser.cpp): lyric parser · `parser.cpp`
- [Date metadata](https://github.com/somethingwithagun/keyboardsong/blob/master/date.h): domain data · `date.h`

### UI and dialogs

- [Plot widget](https://github.com/somethingwithagun/keyboardsong/blob/master/plotwidget.cpp): custom visualization · Renders parsed lyric-related content. · `plotwidget.cpp`
- [Drawing functions](https://github.com/somethingwithagun/keyboardsong/blob/master/drawfuncs.cpp): rendering primitives · `drawfuncs.cpp`
- [Dialog base](https://github.com/somethingwithagun/keyboardsong/blob/master/dialogbase.cpp): dialog abstraction · `dialogbase.cpp`
- [Load lyrics dialog](https://github.com/somethingwithagun/keyboardsong/blob/master/loadlyricsdialog.cpp): input workflow · `loadlyricsdialog.cpp`
- [Request song dialog](https://github.com/somethingwithagun/keyboardsong/blob/master/requestsongdialog.cpp): request workflow · `requestsongdialog.cpp`
- [Info dialog](https://github.com/somethingwithagun/keyboardsong/blob/master/infodialog.cpp): information workflow · `infodialog.cpp`
- [Button](https://github.com/somethingwithagun/keyboardsong/blob/master/button.cpp): custom control · `button.cpp`
- [Radio button](https://github.com/somethingwithagun/keyboardsong/blob/master/radiobutton.cpp): custom control · `radiobutton.cpp`
- [Text input](https://github.com/somethingwithagun/keyboardsong/blob/master/textinput.cpp): custom control · `textinput.cpp`

## Connections

- CMake build → Program entry: builds executable
- Program entry → Engine: initializes
- Engine → Constants: uses
- Engine → Parser: loads content through
- Parser → Date metadata: produces metadata
- Engine → Plot widget: updates display
- Plot widget → Drawing functions: renders with
- Engine → Dialog base: manages dialogs
- Dialog base → Load lyrics dialog: base for
- Dialog base → Request song dialog: base for
- Dialog base → Info dialog: base for
- Load lyrics dialog → Engine: submits load action
- Request song dialog → Engine: submits request
- Button → Dialog base: drives actions
- Radio button → Dialog base: selects options
- Text input → Dialog base: provides input
