# xvierpalopo/dugonginaja architecture

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

- Interactive diagram: https://gitdiagram.com/xvierpalopo/dugonginaja
- Repository: https://github.com/xvierpalopo/dugonginaja

## Overview

DugonginAja is a browser-based foreign-text pronunciation guide that turns text into natural Indonesian-style readings. The main flow runs from the workspace through a worker and phonetic pipeline, then presents editable readings in text, teleprompter, or karaoke views. Karaoke adds lyric lookup, timing, and playback; history, custom overrides, speech, and subtitle export support the result. The README documents local G2P/NER and ONNX inference, plus optional Spotify and YouTube integrations. Some subsystem links below rely on README statements because their implementation was not sampled.

Main entry points: [`src/components/Workspace.tsx`](https://github.com/xvierpalopo/dugonginaja/blob/main/src/components/Workspace.tsx) (Workspace), [`src/components/KaraokeView.tsx`](https://github.com/xvierpalopo/dugonginaja/blob/main/src/components/KaraokeView.tsx) (Karaoke View), [`src/lib/pipeline.ts`](https://github.com/xvierpalopo/dugonginaja/blob/main/src/lib/pipeline.ts) (Reading Pipeline), [`src/app/api/lyrics/search/route.ts`](https://github.com/xvierpalopo/dugonginaja/blob/main/src/app/api/lyrics/search/route.ts) (Lyrics Search API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workspace["Workspace and Views"]
  node_workspace["Workspace<br/>[Workspace.tsx]"]
  node_text_view["Text View<br/>[OutputPane.tsx]"]
  node_teleprompter["Teleprompter"]
end

subgraph group_phonetics["Phonetic Processing"]
  node_worker_client["Worker Client<br/>[worker-client.ts]"]
  node_worker["Phonetic Worker<br/>[phonetic.worker.ts]"]
  node_pipeline["Reading Pipeline<br/>[pipeline.ts]"]
  node_g2p["Script-aware G2P<br/>[index.ts]"]
  node_language_rules["Language Rules<br/>[languages.ts]"]
  node_onnx["ONNX Inference<br/>[onnx-engine.ts]"]
  node_entity_protection["Entity Protection"]
end

subgraph group_karaoke["Lyrics and Playback"]
  node_karaoke_view["Karaoke View<br/>[KaraokeView.tsx]"]
  node_lyrics_search["Lyrics Search API<br/>[route.ts]"]
  node_lyrics_fallback["Lyrics Fallback API<br/>[route.ts]"]
  node_lrc_parser["LRC Parser<br/>[lrc-parser.ts]"]
  node_batch_phonetics["Lyric Phonetics<br/>[batch-phonetics.ts]"]
  node_audio_player["Audio Matching"]
  node_youtube_player["YouTube Mini Player"]
  node_youtube_meta["YouTube Metadata API<br/>[route.ts]"]
end

subgraph group_personalization["User Tools"]
  node_custom_dict[("Custom Dictionary<br/>[custom-dict.ts]")]
  node_history[("History<br/>[history.ts]")]
  node_subtitles["Subtitle Export<br/>[subtitles.ts]"]
  node_speech["Pronunciation Audio<br/>[speech.ts]"]
end

subgraph group_integrations["External Services"]
  node_spotify_session["Spotify Session"]
  node_spotify_auth["Spotify Auth and API<br/>[spotify-auth.ts]"]
  node_spotify["Spotify"]
  node_lyrics_service["LRCLIB"]
  node_lyrics_fallback_service["lyrics.ovh"]
  node_youtube["YouTube"]
end

node_user(("Text or Song User"))

node_user -->|"enters text"| node_workspace
node_workspace -->|"requests readings"| node_worker_client
node_worker_client -->|"dispatches work"| node_worker
node_worker -->|"runs pipeline"| node_pipeline
node_pipeline -->|"converts to IPA"| node_g2p
node_pipeline -->|"infers readings"| node_onnx
node_pipeline -->|"uses profiles"| node_language_rules
node_g2p -->|"protects names"| node_entity_protection
node_workspace -->|"renders results"| node_text_view
node_workspace -->|"opens mode"| node_teleprompter
node_workspace -->|"opens mode"| node_karaoke_view
node_karaoke_view -->|"searches lyrics"| node_lyrics_search
node_lyrics_search -->|"queries"| node_lyrics_service
node_lyrics_search -->|"falls back"| node_lyrics_fallback
node_lyrics_fallback -->|"queries"| node_lyrics_fallback_service
node_karaoke_view -->|"parses lyrics"| node_lrc_parser
node_karaoke_view -->|"processes lines"| node_batch_phonetics
node_karaoke_view -->|"matches audio"| node_audio_player
node_karaoke_view -->|"offers sync"| node_youtube_player
node_karaoke_view -->|"loads metadata"| node_youtube_meta
node_youtube_meta -->|"reads oEmbed"| node_youtube
node_workspace -->|"loads overrides"| node_custom_dict
node_workspace -->|"stores recent work"| node_history
node_workspace -->|"exports subtitles"| node_subtitles
node_workspace -->|"plays pronunciation"| node_speech
node_workspace -->|"tracks session"| node_spotify_session
node_spotify_session -->|"manages tokens"| node_spotify_auth
node_spotify_auth -->|"calls API"| node_spotify

click node_workspace "https://github.com/xvierpalopo/dugonginaja/blob/main/src/components/Workspace.tsx"
click node_text_view "https://github.com/xvierpalopo/dugonginaja/blob/main/src/components/OutputPane.tsx"
click node_teleprompter "https://github.com/xvierpalopo/dugonginaja/blob/main/src/components/TeleprompterView.tsx"
click node_karaoke_view "https://github.com/xvierpalopo/dugonginaja/blob/main/src/components/KaraokeView.tsx"
click node_worker_client "https://github.com/xvierpalopo/dugonginaja/blob/main/src/lib/worker-client.ts"
click node_worker "https://github.com/xvierpalopo/dugonginaja/blob/main/src/workers/phonetic.worker.ts"
click node_pipeline "https://github.com/xvierpalopo/dugonginaja/blob/main/src/lib/pipeline.ts"
click node_g2p "https://github.com/xvierpalopo/dugonginaja/blob/main/src/lib/g2p/index.ts"
click node_language_rules "https://github.com/xvierpalopo/dugonginaja/blob/main/src/lib/languages.ts"
click node_onnx "https://github.com/xvierpalopo/dugonginaja/blob/main/src/lib/ml/onnx-engine.ts"
click node_entity_protection "https://github.com/xvierpalopo/dugonginaja/blob/main/src/lib/ner/entity-protector.ts"
click node_custom_dict "https://github.com/xvierpalopo/dugonginaja/blob/main/src/lib/custom-dict.ts"
click node_history "https://github.com/xvierpalopo/dugonginaja/blob/main/src/lib/history.ts"
click node_subtitles "https://github.com/xvierpalopo/dugonginaja/blob/main/src/lib/export/subtitles.ts"
click node_speech "https://github.com/xvierpalopo/dugonginaja/blob/main/src/lib/speech.ts"
click node_lyrics_search "https://github.com/xvierpalopo/dugonginaja/blob/main/src/app/api/lyrics/search/route.ts"
click node_lyrics_fallback "https://github.com/xvierpalopo/dugonginaja/blob/main/src/app/api/lyrics/fallback/route.ts"
click node_lrc_parser "https://github.com/xvierpalopo/dugonginaja/blob/main/src/lib/lyrics/lrc-parser.ts"
click node_batch_phonetics "https://github.com/xvierpalopo/dugonginaja/blob/main/src/lib/lyrics/batch-phonetics.ts"
click node_audio_player "https://github.com/xvierpalopo/dugonginaja/blob/main/src/hooks/useSmartAudioPlayer.ts"
click node_youtube_player "https://github.com/xvierpalopo/dugonginaja/blob/main/src/components/YouTubeMiniPlayer.tsx"
click node_youtube_meta "https://github.com/xvierpalopo/dugonginaja/blob/main/src/app/api/youtube/meta/route.ts"
click node_spotify_session "https://github.com/xvierpalopo/dugonginaja/blob/main/src/hooks/useSpotifySession.ts"
click node_spotify_auth "https://github.com/xvierpalopo/dugonginaja/blob/main/src/lib/spotify-auth.ts"

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_workspace,node_text_view,node_teleprompter,node_user toneBlue
class node_worker_client,node_worker,node_pipeline,node_g2p,node_language_rules,node_onnx,node_entity_protection toneAmber
class node_karaoke_view,node_lyrics_search,node_lyrics_fallback,node_lrc_parser,node_batch_phonetics,node_audio_player,node_youtube_player,node_youtube_meta toneMint
class node_custom_dict,node_history,node_subtitles,node_speech toneRose
class node_spotify_session,node_spotify_auth,node_spotify,node_lyrics_service,node_lyrics_fallback_service,node_youtube toneIndigo
```

## Components

### Workspace and Views

- [Workspace](https://github.com/xvierpalopo/dugonginaja/blob/main/src/components/Workspace.tsx): `src/components/Workspace.tsx`
- [Text View](https://github.com/xvierpalopo/dugonginaja/blob/main/src/components/OutputPane.tsx): `src/components/OutputPane.tsx`
- [Teleprompter](https://github.com/xvierpalopo/dugonginaja/blob/main/src/components/TeleprompterView.tsx): `src/components/TeleprompterView.tsx`

### Phonetic Processing

- [Worker Client](https://github.com/xvierpalopo/dugonginaja/blob/main/src/lib/worker-client.ts): `src/lib/worker-client.ts`
- [Phonetic Worker](https://github.com/xvierpalopo/dugonginaja/blob/main/src/workers/phonetic.worker.ts): `src/workers/phonetic.worker.ts`
- [Reading Pipeline](https://github.com/xvierpalopo/dugonginaja/blob/main/src/lib/pipeline.ts): `src/lib/pipeline.ts`
- [Script-aware G2P](https://github.com/xvierpalopo/dugonginaja/blob/main/src/lib/g2p/index.ts): `src/lib/g2p/index.ts`
- [Language Rules](https://github.com/xvierpalopo/dugonginaja/blob/main/src/lib/languages.ts): `src/lib/languages.ts`
- [ONNX Inference](https://github.com/xvierpalopo/dugonginaja/blob/main/src/lib/ml/onnx-engine.ts): `src/lib/ml/onnx-engine.ts`
- [Entity Protection](https://github.com/xvierpalopo/dugonginaja/blob/main/src/lib/ner/entity-protector.ts): `src/lib/ner/entity-protector.ts`

### Lyrics and Playback

- [Karaoke View](https://github.com/xvierpalopo/dugonginaja/blob/main/src/components/KaraokeView.tsx): `src/components/KaraokeView.tsx`
- [Lyrics Search API](https://github.com/xvierpalopo/dugonginaja/blob/main/src/app/api/lyrics/search/route.ts): `src/app/api/lyrics/search/route.ts`
- [Lyrics Fallback API](https://github.com/xvierpalopo/dugonginaja/blob/main/src/app/api/lyrics/fallback/route.ts): `src/app/api/lyrics/fallback/route.ts`
- [LRC Parser](https://github.com/xvierpalopo/dugonginaja/blob/main/src/lib/lyrics/lrc-parser.ts): `src/lib/lyrics/lrc-parser.ts`
- [Lyric Phonetics](https://github.com/xvierpalopo/dugonginaja/blob/main/src/lib/lyrics/batch-phonetics.ts): `src/lib/lyrics/batch-phonetics.ts`
- [Audio Matching](https://github.com/xvierpalopo/dugonginaja/blob/main/src/hooks/useSmartAudioPlayer.ts): `src/hooks/useSmartAudioPlayer.ts`
- [YouTube Mini Player](https://github.com/xvierpalopo/dugonginaja/blob/main/src/components/YouTubeMiniPlayer.tsx): `src/components/YouTubeMiniPlayer.tsx`
- [YouTube Metadata API](https://github.com/xvierpalopo/dugonginaja/blob/main/src/app/api/youtube/meta/route.ts): `src/app/api/youtube/meta/route.ts`

### User Tools

- [Custom Dictionary](https://github.com/xvierpalopo/dugonginaja/blob/main/src/lib/custom-dict.ts): `src/lib/custom-dict.ts`
- [History](https://github.com/xvierpalopo/dugonginaja/blob/main/src/lib/history.ts): `src/lib/history.ts`
- [Subtitle Export](https://github.com/xvierpalopo/dugonginaja/blob/main/src/lib/export/subtitles.ts): `src/lib/export/subtitles.ts`
- [Pronunciation Audio](https://github.com/xvierpalopo/dugonginaja/blob/main/src/lib/speech.ts): `src/lib/speech.ts`

### External Services

- [Spotify Session](https://github.com/xvierpalopo/dugonginaja/blob/main/src/hooks/useSpotifySession.ts): `src/hooks/useSpotifySession.ts`
- [Spotify Auth and API](https://github.com/xvierpalopo/dugonginaja/blob/main/src/lib/spotify-auth.ts): `src/lib/spotify-auth.ts`
- **Spotify**
- **LRCLIB**
- **lyrics.ovh**
- **YouTube**

### Other components

- **Text or Song User**

## Connections

- Text or Song User → Workspace: enters text
- Workspace → Worker Client: requests readings (evidence: `src/components/Workspace.tsx`)
- Worker Client → Phonetic Worker: dispatches work (evidence: `src/lib/worker-client.ts`)
- Phonetic Worker → Reading Pipeline: runs pipeline (evidence: `src/workers/phonetic.worker.ts`)
- Reading Pipeline → Script-aware G2P: converts to IPA (evidence: `src/lib/pipeline.ts`)
- Reading Pipeline → ONNX Inference: infers readings (evidence: `src/lib/pipeline.ts`)
- Reading Pipeline → Language Rules: uses profiles (evidence: `src/lib/pipeline.ts`)
- Script-aware G2P → Entity Protection: protects names (evidence: `src/lib/g2p/index.ts`)
- Workspace → Text View: renders results (evidence: `src/components/Workspace.tsx`)
- Workspace → Teleprompter: opens mode (evidence: `src/components/Workspace.tsx`)
- Workspace → Karaoke View: opens mode (evidence: `src/components/Workspace.tsx`)
- Karaoke View → Lyrics Search API: searches lyrics
- Lyrics Search API → LRCLIB: queries
- Lyrics Search API → Lyrics Fallback API: falls back
- Lyrics Fallback API → lyrics.ovh: queries
- Karaoke View → LRC Parser: parses lyrics (evidence: `src/components/KaraokeView.tsx`)
- Karaoke View → Lyric Phonetics: processes lines (evidence: `src/components/KaraokeView.tsx`)
- Karaoke View → Audio Matching: matches audio (evidence: `src/components/KaraokeView.tsx`)
- Karaoke View → YouTube Mini Player: offers sync (evidence: `src/components/KaraokeView.tsx`)
- Karaoke View → YouTube Metadata API: loads metadata
- YouTube Metadata API → YouTube: reads oEmbed
- Workspace → Custom Dictionary: loads overrides (evidence: `src/components/Workspace.tsx`)
- Workspace → History: stores recent work (evidence: `src/components/Workspace.tsx`)
- Workspace → Subtitle Export: exports subtitles (evidence: `src/components/Workspace.tsx`)
- Workspace → Pronunciation Audio: plays pronunciation (evidence: `src/components/Workspace.tsx`)
- Workspace → Spotify Session: tracks session (evidence: `src/components/Workspace.tsx`)
- Spotify Session → Spotify Auth and API: manages tokens (evidence: `src/hooks/useSpotifySession.ts`)
- Spotify Auth and API → Spotify: calls API (evidence: `src/lib/spotify-auth.ts`)
