# jackzhen1324/tunesync architecture

> Architecture diagram of the GitHub repository jackzhen1324/tunesync, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jackzhen1324/tunesync
- Repository: https://github.com/jackzhen1324/tunesync

## Overview

##### Project Type and Purpose
- TuneSync is a cross-platform (iOS and Android) music/audio streaming application built primarily using React Native with Expo.
- The app emphasizes client-side streaming from both local storage and remote sources. It includes features such as metadata scraping, lyrics display, playlist and queue management, and a unique Coverflow UI.
- Notice that the README highlights early access features and extensive support for audio playback and metadata gathering.

##### Analyzing the File Structure
- Native Platform Directories:
- “android” and “ios” directories hold native project configuration files and platform-specific code.
- These include build.gradle, AndroidManifest.xml (for Android) and Xcode project files, Info.plist for iOS.
- React Native/Expo Code:
- The “src” directory contains most of the application logic, including UI components (in components), application routing/layout (in app), state management (in store), and various helpers and services.
- The “app.json”, “babel.config.js”, and “metro.config.js” files indicate Expo-based configuration.
- Modular Native Code:
- The “modules” folder (with submodules like “awesome-module” and “tunesyncmodule”) suggests custom native modules that interface with React Native to support device-specific functionalities like metadata extraction and audio handling.
- Services and State Management:
- In “src/service” you have code for handling metadata fetching and integrations with external APIs (e.g., Spotify, netease, WebDAV).
- The “src/store” directory indicates a centralized state management system (likely using a pattern such as Redux or React Context) that ties together UI and business logic.

##### Main Components & Their Relationships
- Presentation/UI Layer:
- Components inside “src/components” (player controls, playlists, menus, settings, Coverflow UI, etc.) and “src/app” which organizes navigation and screens.
- Business Logic & State Management:
- “src/store” modules for managing application state (player, library, tasks, etc.) and reducers or middleware (see “src/store/middleware.tsx”).
- Service Layer:
- Under “src/service,” include modules for metadata, authentication, and third-party integrations (Spotify, NetEase, WebDAV).
- That these services are invoked by the state management layer to fetch or update data.
- Native Modules & Platform-Specific Code:
- “android” and “ios” directories as platform-specific components that handle lower-level, native functionality (audio processing, manifest configurations).
- “modules/tunesyncmodule” that bridges native code with the React Native layer.
- External Dependencies and Data Sources:

##### Including Architectural Patterns and Design Principles
- Modularization and Separation of Concerns:
- Separate UI (view) from state management and business logic.
- Clearly delineate platform-specific native modules from cross-platform code.
- Component-Based Architecture:
- Use clear labels indicating React components, modules, and services.
- Data Flow:
- Serverless/Client-Heavy Design:
- That the core functionality is client-based, eliminating the need for a backend – yet it integrates external APIs.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Presentation Layer (React Native UI)"
        Components["Components (src/components)"]:::ui
        Navigation["Navigation & Screens (src/app)"]:::ui
    end

    subgraph "Business Logic & State Management"
        Store["Store (src/store)"]:::state
    end

    subgraph "Service Layer"
        Service["Metadata & API Service (src/service)"]:::service
    end

    subgraph "Native Modules"
        TuneSyncModule["TuneSync Module (modules/tunesyncmodule)"]:::native
    end

    subgraph "Platform-Specific Native Code"
        Android["Android (android)"]:::platform
        iOS["iOS (ios)"]:::platform
    end

    subgraph "External Dependencies"
        LocalAudio["Local Audio Source"]:::external
        WebDAV["WebDAV Server"]:::external
        MetadataAPI["Metadata API"]:::external
        LyricsAPI["Lyrics API"]:::external
    end

    %% Connections
    Components -->|"dispatches_action"| Store
    Navigation -->|"triggers_navigation"| Store
    Store -->|"invokes_service"| Service
    Store -->|"calls_native"| TuneSyncModule
    Service -->|"fetches_from"| LocalAudio
    Service -->|"fetches_from"| WebDAV
    Service -->|"calls"| MetadataAPI
    Service -->|"calls"| LyricsAPI
    TuneSyncModule -->|"integrates_with"| Android
    TuneSyncModule -->|"integrates_with"| iOS
    Store -->|"updates_ui"| Components

    %% Click Events
    click Components "https://github.com/jackzhen1324/tunesync/tree/master/src/components"
    click Navigation "https://github.com/jackzhen1324/tunesync/tree/master/src/app"
    click Store "https://github.com/jackzhen1324/tunesync/tree/master/src/store"
    click Service "https://github.com/jackzhen1324/tunesync/tree/master/src/service"
    click TuneSyncModule "https://github.com/jackzhen1324/tunesync/tree/master/modules/tunesyncmodule"
    click Android "https://github.com/jackzhen1324/tunesync/tree/master/android"
    click iOS "https://github.com/jackzhen1324/tunesync/tree/master/ios"

    %% Styles
    classDef ui fill:#AED6F1,stroke:#1E90FF,stroke-width:2px;
    classDef state fill:#A9DFBF,stroke:#196F3D,stroke-width:2px;
    classDef service fill:#F9E79F,stroke:#B9770E,stroke-width:2px;
    classDef native fill:#D7BDE2,stroke:#7D3C98,stroke-width:2px;
    classDef platform fill:#D7BDE2,stroke:#6C3483,stroke-width:2px;
    classDef external fill:#F5CBA7,stroke:#B9770E,stroke-width:2px;
```
