# rodrichgk/butu architecture

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

- Interactive diagram: https://gitdiagram.com/rodrichgk/butu
- Repository: https://github.com/rodrichgk/butu

## Overview

Butu is a multi-platform Plex/Jellyfin media client: users connect an existing server, browse and select media, then play it with playback enhancements. The web/Tauri frontend, native Android app, marker-analysis pipeline, and optional crowdsourced marker service are distinct product branches. Edges cite only relationships visible in the supplied excerpts or README; unsampled platform features are included where documented, with unverified wiring omitted.

Main entry points: [`src/App.tsx`](https://github.com/rodrichgk/butu/blob/master/src/App.tsx) (Web App), [`crates/butu-markers/src/pipeline.rs`](https://github.com/rodrichgk/butu/blob/master/crates/butu-markers/src/pipeline.rs) (Marker Pipeline), [`src/hooks/useLibraryQuery.ts`](https://github.com/rodrichgk/butu/blob/master/src/hooks/useLibraryQuery.ts) (Library Query), [`crates/butu-markers/src/pipeline_fast.rs`](https://github.com/rodrichgk/butu/blob/master/crates/butu-markers/src/pipeline_fast.rs) (Fast Pipeline)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web Client"]
  node_webapp["Web App<br/>[App.tsx]"]
  node_setup["Server Setup<br/>[MediaSetup.tsx]"]
  node_config[("Connection Config<br/>[useConfigStore.ts]")]
  node_libraryquery["Library Query<br/>[useLibraryQuery.ts]"]
  node_plex["Plex Client<br/>[plexApi.ts]"]
  node_jellyfin["Jellyfin Client<br/>[jellyfinApi.ts]"]
  node_browse["Browse &amp; Search<br/>[SearchView.tsx]"]
  node_detail["Media Details"]
  node_player["Media Player<br/>[ButuPlayer.tsx]"]
  node_progress[("Watch Progress<br/>[useLibraryStore.ts]")]
  node_mediastage["Media Presentation<br/>[MediaStage.tsx]"]
  node_mediaitem["Media Model<br/>[index.ts]"]
end

subgraph group_android["Android TV"]
  node_androidapp["Android App<br/>[MainActivity.kt]"]
  node_androidsetup["Android Setup<br/>[SetupViewModel.kt]"]
  node_androidmedia["Media Repository<br/>[MediaRepository.kt]"]
  node_androidplex["Plex Repository<br/>[PlexRepository.kt]"]
  node_androidjellyfin["Jellyfin Repository"]
  node_androidplayer["TV Playback<br/>[PlayerViewModel.kt]"]
  node_remote["Air Mouse Remote<br/>[RemoteClient.kt]"]
end

subgraph group_markers["Marker Analysis"]
  node_analysis["Marker Pipeline<br/>[pipeline.rs]"]
  node_fastanalysis["Fast Pipeline<br/>[pipeline_fast.rs]"]
  node_audio["Audio Extraction<br/>[audio.rs]"]
  node_fingerprint["Audio Fingerprints<br/>[fingerprint.rs]"]
  node_detection["Marker Detection<br/>[detect.rs]"]
  node_segmentation["Credits Segments<br/>[segment.rs]"]
  node_runner["Media Runner<br/>[runner.rs]"]
end

subgraph group_desktop["Desktop Services"]
  node_tauri["Desktop Bridge<br/>[lib.rs]"]
  node_analysiscmd["Analysis Commands<br/>[commands.rs]"]
  node_markerui["Marker Service<br/>[markerService.ts]"]
end

subgraph group_cloud["Crowdsourced Markers"]
  node_markercloud["Marker API<br/>[index.ts]"]
end

node_user(("Viewer"))
node_plexserver[("Plex Server")]
node_jellyfinserver[("Jellyfin Server")]
node_supabase[("Supabase")]

node_user -->|"uses"| node_webapp
node_webapp -->|"opens setup"| node_setup
node_setup -.->|"saves connection"| node_config
node_webapp -->|"loads library"| node_libraryquery
node_libraryquery -->|"reads config"| node_config
node_libraryquery -->|"fetches Plex"| node_plex
node_libraryquery -->|"fetches Jellyfin"| node_jellyfin
node_plex -->|"requests library"| node_plexserver
node_jellyfin -->|"requests library"| node_jellyfinserver
node_webapp -.->|"routes to"| node_browse
node_browse -->|"filters results"| node_libraryquery
node_browse -->|"renders results"| node_mediastage
node_webapp -->|"renders library"| node_mediastage
node_webapp -->|"opens details"| node_detail
node_webapp -->|"opens playback"| node_player
node_player -.->|"tracks progress"| node_progress
node_user -->|"uses TV app"| node_androidapp
node_androidapp -.->|"starts setup"| node_androidsetup
node_androidsetup -.->|"configures media"| node_androidmedia
node_androidmedia -->|"delegates Plex"| node_androidplex
node_androidmedia -->|"delegates Jellyfin"| node_androidjellyfin
node_androidplex -->|"connects server"| node_plexserver
node_androidjellyfin -->|"connects server"| node_jellyfinserver
node_androidapp -.->|"plays media"| node_androidplayer
node_user -.->|"controls remotely"| node_remote
node_analysis -->|"extracts audio"| node_audio
node_analysis -->|"fingerprints audio"| node_fingerprint
node_analysis -->|"detects markers"| node_detection
node_analysis -->|"refines credits"| node_segmentation
node_fastanalysis -->|"extracts audio"| node_audio
node_fastanalysis -->|"fingerprints audio"| node_fingerprint
node_fastanalysis -->|"detects markers"| node_detection
node_analysis -->|"runs media tools"| node_runner
node_fastanalysis -->|"runs media tools"| node_runner
node_tauri -->|"registers commands"| node_analysiscmd
node_analysiscmd -.->|"runs analysis"| node_analysis
node_markerui -->|"invokes desktop"| node_tauri
node_markerui -.->|"submits markers"| node_markercloud
node_markercloud -.->|"stores markers"| node_supabase

click node_webapp "https://github.com/rodrichgk/butu/blob/master/src/App.tsx"
click node_setup "https://github.com/rodrichgk/butu/blob/master/src/components/MediaSetup.tsx"
click node_config "https://github.com/rodrichgk/butu/blob/master/src/store/useConfigStore.ts"
click node_libraryquery "https://github.com/rodrichgk/butu/blob/master/src/hooks/useLibraryQuery.ts"
click node_plex "https://github.com/rodrichgk/butu/blob/master/src/services/plexApi.ts"
click node_jellyfin "https://github.com/rodrichgk/butu/blob/master/src/services/jellyfinApi.ts"
click node_browse "https://github.com/rodrichgk/butu/blob/master/src/components/views/SearchView.tsx"
click node_detail "https://github.com/rodrichgk/butu/blob/master/src/components/ContentDetailPage.tsx"
click node_player "https://github.com/rodrichgk/butu/blob/master/src/components/ButuPlayer.tsx"
click node_progress "https://github.com/rodrichgk/butu/blob/master/src/store/useLibraryStore.ts"
click node_mediastage "https://github.com/rodrichgk/butu/blob/master/src/components/MediaStage.tsx"
click node_mediaitem "https://github.com/rodrichgk/butu/blob/master/src/types/index.ts"
click node_androidapp "https://github.com/rodrichgk/butu/blob/master/android/app/src/main/java/dev/butu/MainActivity.kt"
click node_androidsetup "https://github.com/rodrichgk/butu/blob/master/android/app/src/main/java/dev/butu/feature/setup/SetupViewModel.kt"
click node_androidmedia "https://github.com/rodrichgk/butu/blob/master/android/app/src/main/java/dev/butu/data/media/MediaRepository.kt"
click node_androidplex "https://github.com/rodrichgk/butu/blob/master/android/app/src/main/java/dev/butu/data/plex/PlexRepository.kt"
click node_androidjellyfin "https://github.com/rodrichgk/butu/blob/master/android/app/src/main/java/dev/butu/data/jellyfin/JellyfinRepository.kt"
click node_androidplayer "https://github.com/rodrichgk/butu/blob/master/android/app/src/main/java/dev/butu/feature/player/PlayerViewModel.kt"
click node_remote "https://github.com/rodrichgk/butu/blob/master/android/app/src/main/java/dev/butu/feature/remote/RemoteClient.kt"
click node_analysis "https://github.com/rodrichgk/butu/blob/master/crates/butu-markers/src/pipeline.rs"
click node_fastanalysis "https://github.com/rodrichgk/butu/blob/master/crates/butu-markers/src/pipeline_fast.rs"
click node_audio "https://github.com/rodrichgk/butu/blob/master/crates/butu-markers/src/audio.rs"
click node_fingerprint "https://github.com/rodrichgk/butu/blob/master/crates/butu-markers/src/fingerprint.rs"
click node_detection "https://github.com/rodrichgk/butu/blob/master/crates/butu-markers/src/detect.rs"
click node_segmentation "https://github.com/rodrichgk/butu/blob/master/crates/butu-markers/src/segment.rs"
click node_runner "https://github.com/rodrichgk/butu/blob/master/crates/butu-markers/src/runner.rs"
click node_tauri "https://github.com/rodrichgk/butu/blob/master/src-tauri/src/lib.rs"
click node_analysiscmd "https://github.com/rodrichgk/butu/blob/master/src-tauri/src/analysis/commands.rs"
click node_markerui "https://github.com/rodrichgk/butu/blob/master/src/services/markerService.ts"
click node_markercloud "https://github.com/rodrichgk/butu/blob/master/cloud/supabase/functions/submit-markers/index.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_webapp,node_setup,node_config,node_libraryquery,node_plex,node_jellyfin,node_browse,node_detail,node_player,node_progress,node_mediastage,node_mediaitem,node_user toneBlue
class node_androidapp,node_androidsetup,node_androidmedia,node_androidplex,node_androidjellyfin,node_androidplayer,node_remote,node_plexserver,node_jellyfinserver,node_supabase toneAmber
class node_analysis,node_fastanalysis,node_audio,node_fingerprint,node_detection,node_segmentation,node_runner toneMint
class node_tauri,node_analysiscmd,node_markerui toneRose
class node_markercloud toneIndigo
```

## Components

### Web Client

- [Web App](https://github.com/rodrichgk/butu/blob/master/src/App.tsx): `src/App.tsx`
- [Server Setup](https://github.com/rodrichgk/butu/blob/master/src/components/MediaSetup.tsx): `src/components/MediaSetup.tsx`
- [Connection Config](https://github.com/rodrichgk/butu/blob/master/src/store/useConfigStore.ts): `src/store/useConfigStore.ts`
- [Library Query](https://github.com/rodrichgk/butu/blob/master/src/hooks/useLibraryQuery.ts): `src/hooks/useLibraryQuery.ts`
- [Plex Client](https://github.com/rodrichgk/butu/blob/master/src/services/plexApi.ts): `src/services/plexApi.ts`
- [Jellyfin Client](https://github.com/rodrichgk/butu/blob/master/src/services/jellyfinApi.ts): `src/services/jellyfinApi.ts`
- [Browse & Search](https://github.com/rodrichgk/butu/blob/master/src/components/views/SearchView.tsx): `src/components/views/SearchView.tsx`
- [Media Details](https://github.com/rodrichgk/butu/blob/master/src/components/ContentDetailPage.tsx): `src/components/ContentDetailPage.tsx`
- [Media Player](https://github.com/rodrichgk/butu/blob/master/src/components/ButuPlayer.tsx): `src/components/ButuPlayer.tsx`
- [Watch Progress](https://github.com/rodrichgk/butu/blob/master/src/store/useLibraryStore.ts): `src/store/useLibraryStore.ts`
- [Media Presentation](https://github.com/rodrichgk/butu/blob/master/src/components/MediaStage.tsx): `src/components/MediaStage.tsx`
- [Media Model](https://github.com/rodrichgk/butu/blob/master/src/types/index.ts): `src/types/index.ts`

### Android TV

- [Android App](https://github.com/rodrichgk/butu/blob/master/android/app/src/main/java/dev/butu/MainActivity.kt): `android/app/src/main/java/dev/butu/MainActivity.kt`
- [Android Setup](https://github.com/rodrichgk/butu/blob/master/android/app/src/main/java/dev/butu/feature/setup/SetupViewModel.kt): `android/app/src/main/java/dev/butu/feature/setup/SetupViewModel.kt`
- [Media Repository](https://github.com/rodrichgk/butu/blob/master/android/app/src/main/java/dev/butu/data/media/MediaRepository.kt): `android/app/src/main/java/dev/butu/data/media/MediaRepository.kt`
- [Plex Repository](https://github.com/rodrichgk/butu/blob/master/android/app/src/main/java/dev/butu/data/plex/PlexRepository.kt): `android/app/src/main/java/dev/butu/data/plex/PlexRepository.kt`
- [Jellyfin Repository](https://github.com/rodrichgk/butu/blob/master/android/app/src/main/java/dev/butu/data/jellyfin/JellyfinRepository.kt): `android/app/src/main/java/dev/butu/data/jellyfin/JellyfinRepository.kt`
- [TV Playback](https://github.com/rodrichgk/butu/blob/master/android/app/src/main/java/dev/butu/feature/player/PlayerViewModel.kt): `android/app/src/main/java/dev/butu/feature/player/PlayerViewModel.kt`
- [Air Mouse Remote](https://github.com/rodrichgk/butu/blob/master/android/app/src/main/java/dev/butu/feature/remote/RemoteClient.kt): `android/app/src/main/java/dev/butu/feature/remote/RemoteClient.kt`

### Marker Analysis

- [Marker Pipeline](https://github.com/rodrichgk/butu/blob/master/crates/butu-markers/src/pipeline.rs): `crates/butu-markers/src/pipeline.rs`
- [Fast Pipeline](https://github.com/rodrichgk/butu/blob/master/crates/butu-markers/src/pipeline_fast.rs): `crates/butu-markers/src/pipeline_fast.rs`
- [Audio Extraction](https://github.com/rodrichgk/butu/blob/master/crates/butu-markers/src/audio.rs): `crates/butu-markers/src/audio.rs`
- [Audio Fingerprints](https://github.com/rodrichgk/butu/blob/master/crates/butu-markers/src/fingerprint.rs): `crates/butu-markers/src/fingerprint.rs`
- [Marker Detection](https://github.com/rodrichgk/butu/blob/master/crates/butu-markers/src/detect.rs): `crates/butu-markers/src/detect.rs`
- [Credits Segments](https://github.com/rodrichgk/butu/blob/master/crates/butu-markers/src/segment.rs): `crates/butu-markers/src/segment.rs`
- [Media Runner](https://github.com/rodrichgk/butu/blob/master/crates/butu-markers/src/runner.rs): `crates/butu-markers/src/runner.rs`

### Desktop Services

- [Desktop Bridge](https://github.com/rodrichgk/butu/blob/master/src-tauri/src/lib.rs): `src-tauri/src/lib.rs`
- [Analysis Commands](https://github.com/rodrichgk/butu/blob/master/src-tauri/src/analysis/commands.rs): `src-tauri/src/analysis/commands.rs`
- [Marker Service](https://github.com/rodrichgk/butu/blob/master/src/services/markerService.ts): `src/services/markerService.ts`

### Crowdsourced Markers

- [Marker API](https://github.com/rodrichgk/butu/blob/master/cloud/supabase/functions/submit-markers/index.ts): `cloud/supabase/functions/submit-markers/index.ts`

### Other components

- **Viewer**
- **Plex Server**
- **Jellyfin Server**
- **Supabase**

## Connections

- Viewer → Web App: uses (evidence: `README.md`)
- Web App → Server Setup: opens setup (evidence: `src/App.tsx`)
- Server Setup → Connection Config: saves connection
- Web App → Library Query: loads library (evidence: `src/App.tsx`)
- Library Query → Connection Config: reads config (evidence: `src/hooks/useLibraryQuery.ts`)
- Library Query → Plex Client: fetches Plex (evidence: `src/hooks/useLibraryQuery.ts`)
- Library Query → Jellyfin Client: fetches Jellyfin (evidence: `src/hooks/useLibraryQuery.ts`)
- Plex Client → Plex Server: requests library (evidence: `README.md`)
- Jellyfin Client → Jellyfin Server: requests library (evidence: `README.md`)
- Web App → Browse & Search: routes to (evidence: `src/App.tsx`)
- Browse & Search → Library Query: filters results (evidence: `src/components/views/SearchView.tsx`)
- Browse & Search → Media Presentation: renders results (evidence: `src/components/views/SearchView.tsx`)
- Web App → Media Presentation: renders library (evidence: `src/App.tsx`)
- Web App → Media Details: opens details (evidence: `src/App.tsx`)
- Web App → Media Player: opens playback (evidence: `src/App.tsx`)
- Media Player → Watch Progress: tracks progress
- Viewer → Android App: uses TV app (evidence: `README.md`)
- Android App → Android Setup: starts setup
- Android Setup → Media Repository: configures media
- Media Repository → Plex Repository: delegates Plex (evidence: `android/app/src/main/java/dev/butu/data/media/MediaRepository.kt`)
- Media Repository → Jellyfin Repository: delegates Jellyfin (evidence: `android/app/src/main/java/dev/butu/data/media/MediaRepository.kt`)
- Plex Repository → Plex Server: connects server (evidence: `README.md`)
- Jellyfin Repository → Jellyfin Server: connects server (evidence: `README.md`)
- Android App → TV Playback: plays media
- Viewer → Air Mouse Remote: controls remotely
- Marker Pipeline → Audio Extraction: extracts audio (evidence: `crates/butu-markers/src/pipeline.rs`)
- Marker Pipeline → Audio Fingerprints: fingerprints audio (evidence: `crates/butu-markers/src/pipeline.rs`)
- Marker Pipeline → Marker Detection: detects markers (evidence: `crates/butu-markers/src/pipeline.rs`)
- Marker Pipeline → Credits Segments: refines credits (evidence: `crates/butu-markers/src/pipeline.rs`)
- Fast Pipeline → Audio Extraction: extracts audio (evidence: `crates/butu-markers/src/pipeline_fast.rs`)
- Fast Pipeline → Audio Fingerprints: fingerprints audio (evidence: `crates/butu-markers/src/pipeline_fast.rs`)
- Fast Pipeline → Marker Detection: detects markers (evidence: `crates/butu-markers/src/pipeline_fast.rs`)
- Marker Pipeline → Media Runner: runs media tools (evidence: `crates/butu-markers/src/pipeline.rs`)
- Fast Pipeline → Media Runner: runs media tools (evidence: `crates/butu-markers/src/pipeline_fast.rs`)
- Desktop Bridge → Analysis Commands: registers commands (evidence: `src-tauri/src/lib.rs`)
- Analysis Commands → Marker Pipeline: runs analysis
- Marker Service → Desktop Bridge: invokes desktop (evidence: `src/services/markerService.ts`)
- Marker Service → Marker API: submits markers
- Marker API → Supabase: stores markers
