# abnerbgs/langgam-app architecture

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

- Interactive diagram: https://gitdiagram.com/abnerbgs/langgam-app
- Repository: https://github.com/abnerbgs/langgam-app

## Overview

Langgam is a cross-platform app for reading and editing gamelan song notation, with optional Android USB serial support for Arduino Piezo Shield boards. Users browse the song collection, open a song’s chord sheet, or add/edit lyrics and chord positions; changes are persisted through a platform-specific store. The catalog also supports validated JSON import/export, while a separate connection tab provides the documented board workflow. Edges reflect excerpted calls and README statements; unsampled screen and integration internals are not asserted.

Main entry points: [`src/context/songs-context.tsx`](https://github.com/abnerbgs/langgam-app/blob/master/src/context/songs-context.tsx) (Song state), [`src/services/song-file-format.ts`](https://github.com/abnerbgs/langgam-app/blob/master/src/services/song-file-format.ts) (Song JSON format), [`src/components/add-song-form.tsx`](https://github.com/abnerbgs/langgam-app/blob/master/src/components/add-song-form.tsx) (Song editor form), [`src/app/song/[id].tsx`](https://github.com/abnerbgs/langgam-app/blob/master/src/app/song/%5Bid%5D.tsx) (Song reader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_song_ui["Song experience"]
  node_home["Home activity<br/>[index.tsx]"]
  node_catalog["Song catalog<br/>[explore.tsx]"]
  node_song_detail["Song reader<br/>[&#91;id&#93;.tsx]"]
  node_song_form["Song editor form<br/>[add-song-form.tsx]"]
  node_lyrics_editor["Lyrics and chords"]
  node_chord_sheet["Chord sheet"]
  node_song_methods["Entry methods"]
  node_file_actions["JSON file actions"]
end

subgraph group_song_data["Song data"]
  node_songs_context["Song state<br/>[songs-context.tsx]"]
  node_song_storage["Song persistence<br/>[song-storage.ts]"]
  node_native_storage[("Private file store")]
  node_web_storage[("Browser local store")]
  node_file_transfer["Platform file transfer"]
  node_native_transfer["Native file transfer"]
  node_web_transfer["Web file transfer"]
  node_file_format["Song JSON format"]
end

subgraph group_device["Board connection"]
  node_connect_screen["Connect screen<br/>[connect.tsx]"]
  node_usb_serial["Serial interface<br/>[usb-serial.ts]"]
  node_android_serial["Android USB serial"]
end

subgraph group_presentation["App presentation"]
  node_app_layout["App layout<br/>[_layout.tsx]"]
  node_tabs["Tab navigation<br/>[app-tabs.tsx]"]
  node_theme["Theme tokens<br/>[theme.ts]"]
  node_themed_text["Themed text<br/>[themed-text.tsx]"]
  node_themed_view["Themed view<br/>[themed-view.tsx]"]
  node_use_theme["Theme hook<br/>[use-theme.ts]"]
  node_collapsible["Collapsible panel<br/>[collapsible.tsx]"]
  node_web_badge["Web badge<br/>[web-badge.tsx]"]
  node_animated_icon["Animated icon<br/>[animated-icon.tsx]"]
end

node_user(("App user"))
node_arduino{{"Arduino board"}}

node_user -->|"opens"| node_home
node_home -->|"reads activity"| node_songs_context
node_user -->|"browses"| node_catalog
node_catalog -->|"reads and mutates"| node_songs_context
node_user -->|"opens song"| node_song_detail
node_song_detail -->|"reads and marks"| node_songs_context
node_song_detail -->|"renders"| node_chord_sheet
node_song_form -->|"renders"| node_lyrics_editor
node_song_form -->|"renders"| node_song_methods
node_song_form -->|"adds or updates"| node_songs_context
node_user -->|"imports or exports"| node_file_actions
node_file_actions -->|"requests transfer"| node_file_transfer
node_file_actions -->|"replaces songs"| node_songs_context
node_songs_context -->|"reads and writes"| node_song_storage
node_song_storage -.->|"platform selects"| node_native_storage
node_song_storage -.->|"platform selects"| node_web_storage
node_native_storage -->|"parses and serializes"| node_file_format
node_web_storage -->|"parses and serializes"| node_file_format
node_file_transfer -.->|"platform selects"| node_native_transfer
node_file_transfer -.->|"platform selects"| node_web_transfer
node_native_transfer -->|"parses and serializes"| node_file_format
node_web_transfer -->|"parses and serializes"| node_file_format
node_user -->|"connects board"| node_connect_screen
node_connect_screen -->|"uses serial interface"| node_usb_serial
node_usb_serial -->|"Android implementation"| node_android_serial
node_android_serial -->|"USB serial"| node_arduino
node_app_layout -->|"provides state"| node_songs_context
node_app_layout -->|"renders"| node_animated_icon
node_tabs -->|"uses tokens"| node_theme
node_themed_text -->|"gets colors"| node_use_theme
node_themed_view -->|"gets colors"| node_use_theme
node_use_theme -->|"selects palette"| node_theme
node_collapsible -->|"renders"| node_themed_text
node_collapsible -->|"renders"| node_themed_view
node_web_badge -->|"renders"| node_themed_text
node_web_badge -->|"renders"| node_themed_view

click node_home "https://github.com/abnerbgs/langgam-app/blob/master/src/app/(tabs)/index.tsx"
click node_catalog "https://github.com/abnerbgs/langgam-app/blob/master/src/app/(tabs)/explore.tsx"
click node_song_detail "https://github.com/abnerbgs/langgam-app/blob/master/src/app/song/%5Bid%5D.tsx"
click node_song_form "https://github.com/abnerbgs/langgam-app/blob/master/src/components/add-song-form.tsx"
click node_lyrics_editor "https://github.com/abnerbgs/langgam-app/blob/master/src/components/manual-song-lyrics-editor.tsx"
click node_chord_sheet "https://github.com/abnerbgs/langgam-app/blob/master/src/components/song-chord-sheet.tsx"
click node_song_methods "https://github.com/abnerbgs/langgam-app/blob/master/src/components/song-entry-methods.tsx"
click node_file_actions "https://github.com/abnerbgs/langgam-app/blob/master/src/components/song-file-actions.tsx"
click node_songs_context "https://github.com/abnerbgs/langgam-app/blob/master/src/context/songs-context.tsx"
click node_song_storage "https://github.com/abnerbgs/langgam-app/blob/master/src/services/song-storage.ts"
click node_native_storage "https://github.com/abnerbgs/langgam-app/blob/master/src/services/song-storage.native.ts"
click node_web_storage "https://github.com/abnerbgs/langgam-app/blob/master/src/services/song-storage.web.ts"
click node_file_transfer "https://github.com/abnerbgs/langgam-app/blob/master/src/services/song-file-transfer.ts"
click node_native_transfer "https://github.com/abnerbgs/langgam-app/blob/master/src/services/song-file-transfer.native.ts"
click node_web_transfer "https://github.com/abnerbgs/langgam-app/blob/master/src/services/song-file-transfer.web.ts"
click node_file_format "https://github.com/abnerbgs/langgam-app/blob/master/src/services/song-file-format.ts"
click node_connect_screen "https://github.com/abnerbgs/langgam-app/blob/master/src/app/(tabs)/connect.tsx"
click node_usb_serial "https://github.com/abnerbgs/langgam-app/blob/master/src/services/usb-serial.ts"
click node_android_serial "https://github.com/abnerbgs/langgam-app/blob/master/src/services/usb-serial.android.ts"
click node_app_layout "https://github.com/abnerbgs/langgam-app/blob/master/src/app/_layout.tsx"
click node_tabs "https://github.com/abnerbgs/langgam-app/blob/master/src/components/app-tabs.tsx"
click node_theme "https://github.com/abnerbgs/langgam-app/blob/master/src/constants/theme.ts"
click node_themed_text "https://github.com/abnerbgs/langgam-app/blob/master/src/components/themed-text.tsx"
click node_themed_view "https://github.com/abnerbgs/langgam-app/blob/master/src/components/themed-view.tsx"
click node_use_theme "https://github.com/abnerbgs/langgam-app/blob/master/src/hooks/use-theme.ts"
click node_collapsible "https://github.com/abnerbgs/langgam-app/blob/master/src/components/ui/collapsible.tsx"
click node_web_badge "https://github.com/abnerbgs/langgam-app/blob/master/src/components/web-badge.tsx"
click node_animated_icon "https://github.com/abnerbgs/langgam-app/blob/master/src/components/animated-icon.tsx"

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_home,node_catalog,node_song_detail,node_song_form,node_lyrics_editor,node_chord_sheet,node_song_methods,node_file_actions,node_user toneBlue
class node_songs_context,node_song_storage,node_native_storage,node_web_storage,node_file_transfer,node_native_transfer,node_web_transfer,node_file_format toneAmber
class node_connect_screen,node_usb_serial,node_android_serial toneMint
class node_app_layout,node_tabs,node_theme,node_themed_text,node_themed_view,node_use_theme,node_collapsible,node_web_badge,node_animated_icon toneRose
class node_arduino toneIndigo
```

## Components

### Song experience

- [Home activity](https://github.com/abnerbgs/langgam-app/blob/master/src/app/(tabs)/index.tsx): `src/app/(tabs)/index.tsx`
- [Song catalog](https://github.com/abnerbgs/langgam-app/blob/master/src/app/(tabs)/explore.tsx): `src/app/(tabs)/explore.tsx`
- [Song reader](https://github.com/abnerbgs/langgam-app/blob/master/src/app/song/%5Bid%5D.tsx): `src/app/song/[id].tsx`
- [Song editor form](https://github.com/abnerbgs/langgam-app/blob/master/src/components/add-song-form.tsx): `src/components/add-song-form.tsx`
- [Lyrics and chords](https://github.com/abnerbgs/langgam-app/blob/master/src/components/manual-song-lyrics-editor.tsx): `src/components/manual-song-lyrics-editor.tsx`
- [Chord sheet](https://github.com/abnerbgs/langgam-app/blob/master/src/components/song-chord-sheet.tsx): `src/components/song-chord-sheet.tsx`
- [Entry methods](https://github.com/abnerbgs/langgam-app/blob/master/src/components/song-entry-methods.tsx): `src/components/song-entry-methods.tsx`
- [JSON file actions](https://github.com/abnerbgs/langgam-app/blob/master/src/components/song-file-actions.tsx): `src/components/song-file-actions.tsx`

### Song data

- [Song state](https://github.com/abnerbgs/langgam-app/blob/master/src/context/songs-context.tsx): `src/context/songs-context.tsx`
- [Song persistence](https://github.com/abnerbgs/langgam-app/blob/master/src/services/song-storage.ts): `src/services/song-storage.ts`
- [Private file store](https://github.com/abnerbgs/langgam-app/blob/master/src/services/song-storage.native.ts): `src/services/song-storage.native.ts`
- [Browser local store](https://github.com/abnerbgs/langgam-app/blob/master/src/services/song-storage.web.ts): `src/services/song-storage.web.ts`
- [Platform file transfer](https://github.com/abnerbgs/langgam-app/blob/master/src/services/song-file-transfer.ts): `src/services/song-file-transfer.ts`
- [Native file transfer](https://github.com/abnerbgs/langgam-app/blob/master/src/services/song-file-transfer.native.ts): `src/services/song-file-transfer.native.ts`
- [Web file transfer](https://github.com/abnerbgs/langgam-app/blob/master/src/services/song-file-transfer.web.ts): `src/services/song-file-transfer.web.ts`
- [Song JSON format](https://github.com/abnerbgs/langgam-app/blob/master/src/services/song-file-format.ts): `src/services/song-file-format.ts`

### Board connection

- [Connect screen](https://github.com/abnerbgs/langgam-app/blob/master/src/app/(tabs)/connect.tsx): `src/app/(tabs)/connect.tsx`
- [Serial interface](https://github.com/abnerbgs/langgam-app/blob/master/src/services/usb-serial.ts): `src/services/usb-serial.ts`
- [Android USB serial](https://github.com/abnerbgs/langgam-app/blob/master/src/services/usb-serial.android.ts): `src/services/usb-serial.android.ts`

### App presentation

- [App layout](https://github.com/abnerbgs/langgam-app/blob/master/src/app/_layout.tsx): `src/app/_layout.tsx`
- [Tab navigation](https://github.com/abnerbgs/langgam-app/blob/master/src/components/app-tabs.tsx): `src/components/app-tabs.tsx`
- [Theme tokens](https://github.com/abnerbgs/langgam-app/blob/master/src/constants/theme.ts): `src/constants/theme.ts`
- [Themed text](https://github.com/abnerbgs/langgam-app/blob/master/src/components/themed-text.tsx): `src/components/themed-text.tsx`
- [Themed view](https://github.com/abnerbgs/langgam-app/blob/master/src/components/themed-view.tsx): `src/components/themed-view.tsx`
- [Theme hook](https://github.com/abnerbgs/langgam-app/blob/master/src/hooks/use-theme.ts): `src/hooks/use-theme.ts`
- [Collapsible panel](https://github.com/abnerbgs/langgam-app/blob/master/src/components/ui/collapsible.tsx): `src/components/ui/collapsible.tsx`
- [Web badge](https://github.com/abnerbgs/langgam-app/blob/master/src/components/web-badge.tsx): `src/components/web-badge.tsx`
- [Animated icon](https://github.com/abnerbgs/langgam-app/blob/master/src/components/animated-icon.tsx): `src/components/animated-icon.tsx`

### Other components

- **App user**
- **Arduino board**

## Connections

- App user → Home activity: opens (evidence: `README.md`)
- Home activity → Song state: reads activity (evidence: `src/app/(tabs)/index.tsx`)
- App user → Song catalog: browses (evidence: `README.md`)
- Song catalog → Song state: reads and mutates (evidence: `src/app/(tabs)/explore.tsx`)
- App user → Song reader: opens song (evidence: `src/app/song/[id].tsx`)
- Song reader → Song state: reads and marks (evidence: `src/app/song/[id].tsx`)
- Song reader → Chord sheet: renders (evidence: `src/app/song/[id].tsx`)
- Song editor form → Lyrics and chords: renders (evidence: `src/components/add-song-form.tsx`)
- Song editor form → Entry methods: renders (evidence: `src/components/add-song-form.tsx`)
- Song editor form → Song state: adds or updates (evidence: `src/components/add-song-form.tsx`)
- App user → JSON file actions: imports or exports (evidence: `README.md`)
- JSON file actions → Platform file transfer: requests transfer (evidence: `src/components/song-file-actions.tsx`)
- JSON file actions → Song state: replaces songs (evidence: `src/components/song-file-actions.tsx`)
- Song state → Song persistence: reads and writes (evidence: `src/context/songs-context.tsx`)
- Song persistence → Private file store: platform selects (evidence: `README.md`)
- Song persistence → Browser local store: platform selects (evidence: `README.md`)
- Private file store → Song JSON format: parses and serializes (evidence: `src/services/song-storage.native.ts`)
- Browser local store → Song JSON format: parses and serializes (evidence: `src/services/song-storage.web.ts`)
- Platform file transfer → Native file transfer: platform selects (evidence: `README.md`)
- Platform file transfer → Web file transfer: platform selects (evidence: `README.md`)
- Native file transfer → Song JSON format: parses and serializes (evidence: `src/services/song-file-transfer.native.ts`)
- Web file transfer → Song JSON format: parses and serializes (evidence: `src/services/song-file-transfer.web.ts`)
- App user → Connect screen: connects board (evidence: `README.md`)
- Connect screen → Serial interface: uses serial interface (evidence: `src/app/(tabs)/connect.tsx`)
- Serial interface → Android USB serial: Android implementation (evidence: `src/services/usb-serial.android.ts`)
- Android USB serial → Arduino board: USB serial (evidence: `README.md`)
- App layout → Song state: provides state (evidence: `src/app/_layout.tsx`)
- App layout → Animated icon: renders (evidence: `src/app/_layout.tsx`)
- Tab navigation → Theme tokens: uses tokens (evidence: `src/components/app-tabs.tsx`)
- Themed text → Theme hook: gets colors (evidence: `src/components/themed-text.tsx`)
- Themed view → Theme hook: gets colors (evidence: `src/components/themed-view.tsx`)
- Theme hook → Theme tokens: selects palette (evidence: `src/hooks/use-theme.ts`)
- Collapsible panel → Themed text: renders (evidence: `src/components/ui/collapsible.tsx`)
- Collapsible panel → Themed view: renders (evidence: `src/components/ui/collapsible.tsx`)
- Web badge → Themed text: renders (evidence: `src/components/web-badge.tsx`)
- Web badge → Themed view: renders (evidence: `src/components/web-badge.tsx`)
