# estrosebas/noox-player architecture

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

- Interactive diagram: https://gitdiagram.com/estrosebas/noox-player
- Repository: https://github.com/estrosebas/noox-player

## Overview

##### Main Components
- Frontend:
- Built with React and Vite (found under the “src” folder and “index.html”).
- Components include search bars, music players, modals, and animation handling via Framer Motion.
- Backend:
- A Node.js/Express server (server.js) managing SSL endpoints, YouTube search and suggestion endpoints (e.g., /api/suggestions, /api/yt-search), and conversion/proxy endpoints.
- Optionally, additional backend logic residing in the “back” directory.
- Desktop Packaging:
- An Electron app (see the “electron” folder with its main process in main.mjs) which essentially wraps the built frontend (the “dist” folder generated from Vite).
- Mobile (Android):
- The “android” folder contains the Android project integrated via Capacitor (configured with capacitor.config.ts).
- External Tools/Services:
- yt-dlp and ffmpeg installed on the system for downloading and converting audio.
- External services such as YouTube APIs (and the upcoming Spotify integration) that feed data into the app.
- Database:
- A “noox-db.sql” file exists, which suggests that there is a local database used to store data like playlists or user information.

##### Lay Out Relationships and Interactions
- Client (Frontend) Interaction:
- The user interacts with the React-based UI, utilizing components (like SearchBar, MusicPlayer, and Playlist) to trigger events.
- Server/Backend Interaction:
- The Express server receives requests from the frontend, processes them (including interfacing with yt-dlp/ffmpeg for audio extraction and conversion), and returns responses.
- Flow from the backend to external services (YouTube/Spotify) and the local database if applicable.
- Packaging Branches:
- Separate modules should show the Electron component: The Electron main process loads the built “dist” folder (i.e., the same frontend) to run as a desktop app.
- Similarly, show a branch for Android using Capacitor, which wraps the web application for mobile.

##### Architectural Patterns & Key Design Principles
- Modular Design: Emphasize how the separation of concerns is maintained – the frontend (“src”) is built independently while the backend (server.js and optionally “back”) deals with API and business logic.
- Multi-Platform Packaging: Highlight the use of Electron and Capacitor to reuse the same core functionality across desktop and mobile.
- Integration with External Tools: Indicate the dependency on yt-dlp and ffmpeg that are critical for downloading and converting media from YouTube.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interaction
    U["User"]:::user

    %% Frontend Layer
    subgraph "Frontend Layer"
        Idx["Index HTML"]:::frontend
        FE["React Frontend"]:::frontend
        Idx --> FE
        FEbuild["Built Frontend (dist)"]:::frontend
        FE -->|"builds"| FEbuild
    end

    %% Backend Layer
    subgraph "Backend Layer"
        BE["Express API Server"]:::backend
        FE -->|"APIcalls"| BE
        DB["Local Database"]:::database
        BE -->|"queries"| DB
        YT_API["YouTube API"]:::external
        BE -->|"calls"| YT_API
        SP_API["Spotify Integration"]:::external
        BE -->|"calls"| SP_API
        YTDL["yt-dlp"]:::external
        BE -->|"invokes"| YTDL
        FFMPEG["ffmpeg"]:::external
        BE -->|"invokes"| FFMPEG
    end

    %% Packaging Layer
    subgraph "Packaging Layer"
        Electron["Electron Wrapper"]:::desktop
        FEbuild -->|"loadedBy"| Electron

        subgraph "Mobile Packaging"
            AndroidProj["Android Project"]:::mobile
            CapacitorConfig["Capacitor Config"]:::mobile
            AndroidProj --> CapacitorConfig
        end
        FEbuild -->|"wrappedBy"| AndroidProj
    end

    %% User Interaction to Frontend Entry
    U -->|"interacts"| Idx

    %% Styles
    classDef frontend fill:#c2f0fc,stroke:#0077b6,stroke-width:2px;
    classDef backend fill:#f9c74f,stroke:#f9844a,stroke-width:2px;
    classDef desktop fill:#ffb6c1,stroke:#ff69b4,stroke-width:2px;
    classDef mobile fill:#d3f9d8,stroke:#2b9348,stroke-width:2px;
    classDef database fill:#f0e68c,stroke:#b8860b,stroke-width:2px;
    classDef external fill:#e0bbe4,stroke:#957dad,stroke-width:2px;
    classDef user fill:#caffbf,stroke:#43aa8b,stroke-width:2px;

    %% Click Events
    click FE "https://github.com/estrosebas/noox-player/tree/main/src/"
    click Idx "https://github.com/estrosebas/noox-player/blob/main/index.html"
    click BE "https://github.com/estrosebas/noox-player/blob/main/back/server.js"
    click Electron "https://github.com/estrosebas/noox-player/blob/main/electron/main.mjs"
    click AndroidProj "https://github.com/estrosebas/noox-player/tree/main/android/"
    click CapacitorConfig "https://github.com/estrosebas/noox-player/blob/main/capacitor.config.ts"
    click DB "https://github.com/estrosebas/noox-player/blob/main/noox-db.sql"
```
