# juancho033/juantune architecture

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

- Interactive diagram: https://gitdiagram.com/juancho033/juantune
- Repository: https://github.com/juancho033/juantune

## Overview

#### Purpose and entry point
JuanTune is a Python music-player application with local playback, library/state persistence, and optional cloud-backed media/cache integrations. The primary application bootstrap is `main.py`; packaging is defined by `JuanTune.spec`. Administrative cloud upload work is separated into `admin_upload.py`.

#### Application orchestration
`core/manager.py` is the likely coordination layer between UI actions, player control, library/history state, and service-backed media acquisition. `core/player.py` owns playback-facing behavior and forms the principal boundary between application logic and the underlying audio runtime.

Paths: `main.py`, `core/manager.py`, `core/player.py`

#### Presentation layer
The UI is isolated under `ui/`, suggesting the rest of the application should interact through view/component events rather than directly manipulating widgets. `ui/views.py` likely defines screens or major panels; `ui/components.py` provides reusable controls; `ui/styles.py` centralizes presentation rules.

Paths: `ui/views.py`, `ui/components.py`, `ui/styles.py`

#### Local data and user state
The `data/` package separates durable application concerns from playback and UI logic. Database access is centralized in `data/database.py`; filesystem locations and storage layout are established in `data/paths.py`; user-facing listening history and aggregate metrics are represented by `data/recent.py` and `data/stats.py`.

Primary local flow: manager/player events update recent-track and statistics state, which is persisted through the database/path layer and then reflected in views.

Paths: `data/database.py`, `data/recent.py`, `data/stats.py`

#### Media retrieval and caching
Media access is abstracted behind service modules rather than embedded in player logic. `services/stream_cache.py` appears to manage transient or stream-oriented cached content, while `services/cloud_cache.py` likely maintains locally reusable copies of cloud media. This creates an important boundary: the player should consume resolved local/streamable media, while service code handles remote fetch, cache validity, and storage.

Paths: `services/stream_cache.py`, `services/cloud_cache.py`, `core/player.py`

#### External cloud integrations
Three dedicated adapters indicate supported backend providers: Cloudinary for hosted media, Google Drive for remote file access, and Firebase for application/cloud data. Credentials are expected outside source control through example configuration files.

Paths: `services/cloudinary_service.py`, `services/drive_service.py`, `services/firebase_service.py`

Relevant external configuration: `cloudinary_config.example.json`, `drive_oauth.example.json`, `firebase_config.example.json`

#### Configuration and control flow
`config.py` is the central configuration boundary and should supply environment- or file-derived settings to data and service layers. A typical control path is: `main.py` initializes configuration, persistence, services, manager, and UI; UI commands flow to `core/manager.py`; the manager invokes playback or media services; state changes persist through `data/` and update the UI.

Paths: `config.py`, `main.py`, `core/manager.py`

Main entry points: [`config.py`](https://github.com/juancho033/juantune/blob/master/config.py) (Configuration), [`ui/views.py`](https://github.com/juancho033/juantune/blob/master/ui/views.py) (Views), [`core/manager.py`](https://github.com/juancho033/juantune/blob/master/core/manager.py) (Playback manager), [`core/player.py`](https://github.com/juancho033/juantune/blob/master/core/player.py) (Player)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_main{{"Application bootstrap<br/>entry point<br/>[main.py]"}}
  node_config["Configuration<br/>settings boundary<br/>[config.py]"]
  node_manager["Playback manager<br/>orchestrator<br/>[manager.py]"]
  node_player["Player<br/>playback boundary<br/>[player.py]"]
end

subgraph group_ui["Presentation"]
  node_views["Views<br/>screens<br/>[views.py]"]
  node_components["UI components<br/>controls<br/>[components.py]"]
  node_styles["UI styles<br/>presentation rules<br/>[styles.py]"]
end

subgraph group_data["Local state"]
  node_database[("Database<br/>persistence access<br/>[database.py]")]
  node_paths["Storage paths<br/>filesystem layout<br/>[paths.py]"]
  node_recent["Recent history<br/>listening state<br/>[recent.py]"]
  node_stats["Listening statistics<br/>aggregate state<br/>[stats.py]"]
end

subgraph group_media["Media services"]
  node_stream_cache["Stream cache<br/>media cache<br/>[stream_cache.py]"]
  node_cloud_cache["Cloud cache<br/>media cache<br/>[cloud_cache.py]"]
end

subgraph group_cloud["Cloud adapters"]
  node_cloudinary["Cloudinary adapter<br/>cloud media adapter"]
  node_drive["Google Drive adapter<br/>remote file adapter<br/>[drive_service.py]"]
  node_firebase["Firebase adapter<br/>cloud data adapter"]
  node_admin_upload{{"Admin upload<br/>administrative entry point<br/>[admin_upload.py]"}}
end

node_main -->|"loads"| node_config
node_main -->|"initializes"| node_database
node_main -->|"starts"| node_manager
node_main -->|"launches"| node_views
node_config -->|"configures"| node_database
node_config -->|"configures"| node_stream_cache
node_config -->|"configures"| node_cloud_cache
node_config -->|"configures"| node_cloudinary
node_config -->|"configures"| node_drive
node_config -->|"configures"| node_firebase
node_views -->|"composes"| node_components
node_styles -->|"styles"| node_views
node_views -->|"user commands"| node_manager
node_manager -->|"controls playback"| node_player
node_manager -->|"acquires media"| node_stream_cache
node_manager -->|"acquires media"| node_cloud_cache
node_stream_cache -->|"streamable media"| node_player
node_cloud_cache -->|"local media"| node_player
node_stream_cache -->|"fetches media"| node_cloudinary
node_cloud_cache -->|"fetches media"| node_drive
node_player -->|"play events"| node_recent
node_player -->|"play events"| node_stats
node_recent -->|"persists"| node_database
node_stats -->|"persists"| node_database
node_database -->|"uses storage layout"| node_paths
node_recent -->|"history updates"| node_views
node_stats -->|"metric updates"| node_views
node_admin_upload -->|"uploads media"| node_cloudinary
node_admin_upload -->|"uploads files"| node_drive

click node_main "https://github.com/juancho033/juantune/blob/master/main.py"
click node_config "https://github.com/juancho033/juantune/blob/master/config.py"
click node_manager "https://github.com/juancho033/juantune/blob/master/core/manager.py"
click node_player "https://github.com/juancho033/juantune/blob/master/core/player.py"
click node_views "https://github.com/juancho033/juantune/blob/master/ui/views.py"
click node_components "https://github.com/juancho033/juantune/blob/master/ui/components.py"
click node_styles "https://github.com/juancho033/juantune/blob/master/ui/styles.py"
click node_database "https://github.com/juancho033/juantune/blob/master/data/database.py"
click node_paths "https://github.com/juancho033/juantune/blob/master/data/paths.py"
click node_recent "https://github.com/juancho033/juantune/blob/master/data/recent.py"
click node_stats "https://github.com/juancho033/juantune/blob/master/data/stats.py"
click node_stream_cache "https://github.com/juancho033/juantune/blob/master/services/stream_cache.py"
click node_cloud_cache "https://github.com/juancho033/juantune/blob/master/services/cloud_cache.py"
click node_cloudinary "https://github.com/juancho033/juantune/blob/master/services/cloudinary_service.py"
click node_drive "https://github.com/juancho033/juantune/blob/master/services/drive_service.py"
click node_firebase "https://github.com/juancho033/juantune/blob/master/services/firebase_service.py"
click node_admin_upload "https://github.com/juancho033/juantune/blob/master/admin_upload.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_main,node_config,node_manager,node_player toneBlue
class node_views,node_components,node_styles toneAmber
class node_database,node_paths,node_recent,node_stats toneMint
class node_stream_cache,node_cloud_cache toneRose
class node_cloudinary,node_drive,node_firebase,node_admin_upload toneIndigo
```

## Components

### Application

- [Application bootstrap](https://github.com/juancho033/juantune/blob/master/main.py): entry point · `main.py`
- [Configuration](https://github.com/juancho033/juantune/blob/master/config.py): settings boundary · `config.py`
- [Playback manager](https://github.com/juancho033/juantune/blob/master/core/manager.py): orchestrator · Coordinates UI commands, playback, media acquisition, and state. · `core/manager.py`
- [Player](https://github.com/juancho033/juantune/blob/master/core/player.py): playback boundary · Owns playback-facing behavior and audio runtime interaction. · `core/player.py`

### Presentation

- [Views](https://github.com/juancho033/juantune/blob/master/ui/views.py): screens · `ui/views.py`
- [UI components](https://github.com/juancho033/juantune/blob/master/ui/components.py): controls · `ui/components.py`
- [UI styles](https://github.com/juancho033/juantune/blob/master/ui/styles.py): presentation rules · `ui/styles.py`

### Local state

- [Database](https://github.com/juancho033/juantune/blob/master/data/database.py): persistence access · `data/database.py`
- [Storage paths](https://github.com/juancho033/juantune/blob/master/data/paths.py): filesystem layout · `data/paths.py`
- [Recent history](https://github.com/juancho033/juantune/blob/master/data/recent.py): listening state · `data/recent.py`
- [Listening statistics](https://github.com/juancho033/juantune/blob/master/data/stats.py): aggregate state · `data/stats.py`

### Media services

- [Stream cache](https://github.com/juancho033/juantune/blob/master/services/stream_cache.py): media cache · Resolves transient or stream-oriented media. · `services/stream_cache.py`
- [Cloud cache](https://github.com/juancho033/juantune/blob/master/services/cloud_cache.py): media cache · Maintains reusable local copies of cloud media. · `services/cloud_cache.py`

### Cloud adapters

- [Cloudinary adapter](https://github.com/juancho033/juantune/blob/master/services/cloudinary_service.py): cloud media adapter · `services/cloudinary_service.py`
- [Google Drive adapter](https://github.com/juancho033/juantune/blob/master/services/drive_service.py): remote file adapter · `services/drive_service.py`
- [Firebase adapter](https://github.com/juancho033/juantune/blob/master/services/firebase_service.py): cloud data adapter · `services/firebase_service.py`
- [Admin upload](https://github.com/juancho033/juantune/blob/master/admin_upload.py): administrative entry point · Separates cloud upload work from the player application. · `admin_upload.py`

## Connections

- Application bootstrap → Configuration: loads
- Application bootstrap → Database: initializes
- Application bootstrap → Playback manager: starts
- Application bootstrap → Views: launches
- Configuration → Database: configures
- Configuration → Stream cache: configures
- Configuration → Cloud cache: configures
- Configuration → Cloudinary adapter: configures
- Configuration → Google Drive adapter: configures
- Configuration → Firebase adapter: configures
- Views → UI components: composes
- UI styles → Views: styles
- Views → Playback manager: user commands
- Playback manager → Player: controls playback
- Playback manager → Stream cache: acquires media
- Playback manager → Cloud cache: acquires media
- Stream cache → Player: streamable media
- Cloud cache → Player: local media
- Stream cache → Cloudinary adapter: fetches media
- Cloud cache → Google Drive adapter: fetches media
- Player → Recent history: play events
- Player → Listening statistics: play events
- Recent history → Database: persists
- Listening statistics → Database: persists
- Database → Storage paths: uses storage layout
- Recent history → Views: history updates
- Listening statistics → Views: metric updates
- Admin upload → Cloudinary adapter: uploads media
- Admin upload → Google Drive adapter: uploads files
