Skip to main content

MeloAmp

Imported component documentation. Source: melodee-project/meloamp at commit 0c3aed5f39ba73b48b9bb9ff00e3ede02c6f56eb. Version 1.5.0. License MIT. Status: independent desktop client; source and release history present; not bundled with the distribution and not qualified by it. This is the component's committed documentation, not proof of a distribution release or production qualification.

MeloAmp Logo

MeloAmp is a cross-platform desktop music client for the Melodee API. It uses:

  • React 19 + MUI 9 frontend built with Vite
  • Electron + Express shell
  • Zustand for UI state
  • React Router + i18n + Material theming

It targets Linux, Windows, and macOS.


Table of Contents​

Note: This project is intended to run with Yarn 4 and uses a monorepo layout with two independent package folders.


Repository structure​

src/
ui/ # React 19 + MUI 9 + Zustand app (Vite)
electron/ # Electron main process + preload + package/build config
scripts/ # Build scripts and quality gates (check.py / do-prechecks.py)
AGENTS.md # Local development and architecture instructions

There is no shared workspace root config.


Features​

  • 🎵 Stream music from a Melodee server
  • 🖼️ Browse by artist, album, playlist, and songs
  • 🎚️ Playback queue with shuffle/repeat and queue actions
  • ✅ Save to playlist and playlist management
  • ⭐ Star and rate tracks, then play next / add to queue
  • 🎛️ Equalizer and playback preferences
  • 🌈 Theme system with multiple visual themes and high-contrast options
  • 🌍 i18n with 9 locales
  • 🔒 JWT auth flow
  • 📦 Linux/Windows/macOS packaging via electron-builder
  • 🖥️ Electron shell with optional MPRIS on Linux
  • ♻️ Scrobbling support and tray controls
  • ♿ Keyboard and media controls support

Prerequisites​

  • Node.js 22.12+ (CI uses Node 22)
  • Yarn 4.x (repo enforces this via packageManager in the root package.json)
    • yarn --version should report 4.x
  • rsync for Linux packaging script
  • rpm-tools / fakeroot / libxcrypt-compat on Linux builders as needed
  • Git

Why Yarn 4​

This project is now using Yarn 4 across src/ui and src/electron with deterministic installs per package lockfile:

  • src/ui/yarn.lock
  • src/electron/yarn.lock (generated from src/electron/package.json)

Enable Yarn 4 for this repo with:

corepack enable
corepack prepare yarn@4.14.1 --activate

Linux dependency examples:

  • Arch/Manjaro: sudo pacman -S --needed base-devel rpm-tools fakeroot libxcrypt-compat
  • Ubuntu/Debian: sudo apt-get update && sudo apt-get install -y rpm fakeroot libxcrypt-compat
  • Fedora: sudo dnf install -y rpm-build rpmdevtools fakeroot xz libxcrypt-compat

Developer onboarding​

This section is intentionally detailed so a new contributor can get from clone to a running app in one pass.

1) Clone and prepare the repository​

cd /path/to/workspace
git clone https://github.com/melodee/meloamp.git
cd meloamp

2) Verify Node/Yarn toolchain​

Run this once per machine:

node -v
yarn -v
  • Required baseline: Node 22.12+, Yarn 4.x.
  • If yarn -v is not a 4.x version, run:
corepack prepare yarn@4.14.1 --activate

3) Install dependencies (package-by-package)​

Install frontend and Electron dependencies separately so each lockfile stays consistent:

cd src/ui
yarn install
cd ../electron
yarn install

Do not run install at the repo root.

4) Confirm lockfiles were generated in place​

You should have:

  • src/ui/yarn.lock
  • src/electron/yarn.lock

If you add/update dependencies, keep lockfile updates scoped to the package you changed.

5) Start with the fastest local loop (UI work)​

cd src/ui
yarn start

Open http://localhost:3000.

If your API endpoint is not the default, set the env var before startup:

REACT_APP_API_URL=http://host:4000 yarn start

6) Run desktop wrapper for integration checks​

When you need Electron parity:

cd src/ui
yarn build
cd ../electron
yarn start

Electron serves the built frontend from src/electron/build through http://localhost:3001.

7) API URL and auth quick-checks​

In your browser console while the UI is open:

localStorage.setItem('serverUrl', 'http://your-api-host:4000/api/v1')
localStorage.setItem('jwt', '<your-jwt-token>')
location.reload()

Local development workflows​

UI-only development​

cd src/ui
yarn start

Useful debug helpers:

localStorage.setItem('serverUrl', 'http://your-api-host:4000/api/v1')
localStorage.setItem('jwt', '<your-jwt-token>')
location.reload()

Electron desktop testing​

Electron serves the prebuilt React output in src/electron/build.

cd src/ui
yarn build
cd ../electron
yarn start

The app serves on localhost:3001 with fallback ports if already in use.

Development API URL flow​

  • REACT_APP_API_URL is read during React startup for API base URL overrides.
  • localStorage.serverUrl (set by frontend) also influences API routing and supports quick re-pointing between environments.

Test commands​

From src/ui:

yarn test # Vitest watch mode
yarn test run # single run
yarn test:coverage # single run + coverage thresholds
yarn typecheck # tsc --noEmit
yarn lint # eslint (flat config), zero warnings allowed

From src/electron:

yarn test # node --test helpers.test.js strings.test.js

Pre-push checks​

Run the full gate sequence before pushing (whitespace, repo hygiene, i18n, Electron helpers, typecheck, lint, tests + coverage, production build):

python3 scripts/do-prechecks.py
python3 scripts/do-prechecks.py --fast # skip tests + build
python3 scripts/do-prechecks.py --audit # include dependency audits (network)
python3 scripts/check.py --list # list individual gates

Coverage output:

  • src/ui/coverage/lcov-report/index.html
  • src/ui/coverage/lcov.info
  • src/ui/coverage/coverage-summary.json

Coverage thresholds (global plus per-file floors for api.ts, queueStore.ts, settings.ts, storage.ts, themes/registry.ts, and utils/) are enforced by yarn test:coverage. They are a ratchet: raise them when adding tests.

For CI parity use the immutable install command:

cd src/ui
yarn install --immutable

Use this instead of a regular install when you specifically want to enforce lockfile exactness:

cd src/electron
yarn install --immutable

Useful maintenance commands​

If you add or update dependencies, run the package-level install and commit the updated lockfile:

cd src/ui # or src/electron
yarn install

Use immutable installs for CI and fresh-checkout checks.


Build and packaging​

Production Linux build​

./scripts/build-linux.sh

Artifact names include the OS and architecture (MeloAmp-<version>-linux-x64.AppImage, ...); Windows installer and portable builds have distinct names so releases never overwrite each other.

Optional variants:

  • CLEAN=1 ./scripts/build-linux.sh to force a clean build
  • SKIP_PACKAGE=1 ./scripts/build-linux.sh to run UI+Electron sync only (no packaging)

Artifacts are written to:

  • src/electron/dist/

Packages configured in Electron config:

  • Linux: AppImage, tar.gz
  • Windows: nsis installer, portable, zip
  • macOS: dmg, zip (x64 + arm64) with hardened runtime

Code signing/notarization is driven by the standard electron-builder environment variables (CSC_LINK, CSC_KEY_PASSWORD, APPLE_ID, APPLE_APP_SPECIFIC_PASSWORD, APPLE_TEAM_ID); unsigned local builds still work but trigger OS warnings.

Build for other OSes​

Use electron-builder commands from src/electron:

cd src/electron
yarn electron-builder --linux AppImage tar.gz

yarn electron-builder --win nsis portable zip

yarn electron-builder --mac dmg zip

CI reference and expected outcomes​

GitHub Actions is defined in .github/workflows/build.yml and does:

  1. Run UI tests with coverage
  2. Build UI
  3. Build Linux / Windows / macOS Electron packages
  4. On tags v*, publish GitHub release artifacts

Application architecture​

Frontend (React)​

  • Location: src/ui
  • State: Zustand stores (src/ui/src/queueStore.ts), not Redux/context for app state
  • Themes: MUI theme map in src/ui/src/themes/
  • i18n: react-i18next, locale resources under src/ui/src/locales/
  • Testing: Vitest + React Testing Library, src/ui/src/test helpers

Electron shell​

  • Location: src/electron
  • Serves src/electron/build via local Express server (default port 3001)
  • IPC bridge is exposed in src/electron/preload.js
  • MPRIS, tray, global media shortcuts and auto-updater are handled in main process
  • New IPC channels must also be added to allowlists in preload

Data and runtime expectations​

  • Queue and playback preferences are persisted to localStorage.
  • MPRIS requires D-Bus session bus on Linux.
  • DevTools are disabled in packaged builds.
  • Set MELOAMP_DEBUG_CONSOLE=1 for devtools in packaged app sessions.

Configuration notes​

  • Theme, equalizer, and playback settings are managed in app UI and persisted in local storage through the single merge-based writer in src/ui/src/settings.ts.
  • Supported locales are configured under src/ui/src/locales/. en.json is complete and enforced by prechecks; other locales fall back to English until translated.
  • Authentication: the JWT lives in localStorage (browser-compatible) and is sent as a Bearer header; stream URLs receive it at playback time only. When the server issues a refresh token at sign-in, MeloAmp keeps it in window-scoped session storage and rotates it when the access token expires. Playback continues during renewal. Closing the window ends access to that refresh token. A previously expired login needs one fresh sign-in. Never persist or log stream URLs with credentials. The packaged app adds a strict CSP, no-referrer, and a loopback-only server to reduce the XSS surface.
  • Use localStorage values with care when switching environments.

Troubleshooting​

  • Node/yarn mismatch: ensure yarn -v is Yarn 4.x.
  • Port conflicts: Electron static server tries fallback ports if 3001 is occupied.
  • Linux packaging failures: run CLEAN=1 and confirm Linux build dependencies are installed.
  • Yarn immutable install fails with lockfile errors after dependency changes: run yarn install in that package to refresh the lockfile.
  • Prechecks fail on a missing translation key: add the key to src/ui/src/locales/en.json; other locales fall back to English.
  • Prechecks fail on hardcoded UI text: route the string through t() (scripts/check.py i18n detects plain JSX text).
  • MPRIS not available on Linux: requires D-Bus session bus (DBUS_SESSION_BUS_ADDRESS should be set by desktop session).
  • Desktop app cannot connect to the server: the Electron shell serves the UI from http://localhost:3001 (fallbacks :3000, :8080). The Melodee server must allow those origins in CORS. As a quick check, run the browser UI at http://localhost:3000; if that works, it is a CORS/origin issue. The login screen normalises https://host to https://host/api/v1 automatically.
  • Fedora AppImage issues: use --gtk-version=3 when needed.

Contributing​

  1. Fork and create a feature branch
  2. Keep changes scoped and aligned with existing architecture (zustand, i18n, Material-UI patterns)
  3. Run python3 scripts/do-prechecks.py before opening a PR
  4. Prefer small, reviewable commits

License​

This project is licensed under the MIT License.


Contact​

For support or questions: info@melodee.org