docs: unify bilingual README/LIESMICH, logo, and repo cleanup
This commit is contained in:
1 parent
c8e1641383
commit
df83a1b9fb
2 files changed
+390
-30
No files matched your search
+206
@@ -0,0 +1,206 @@
|
||||
<p align="center">
|
||||
<img src="public/favicon.png" alt="KeySelector Logo" width="128" />
|
||||
</p>
|
||||
|
||||
<h1 align="center">KeySelector</h1>
|
||||
<p align="center"><strong>Ein browserbasierter harmonischer DJ-Assistent mit Live-Audio-Erkennung, interaktivem Camelot Wheel und PostgreSQL-Track-Katalog.</strong></p>
|
||||
|
||||
<p align="center">
|
||||
<a href="README.md">🇬🇧 English</a> · <a href="LIESMICH.md">🇩🇪 Deutsch</a>
|
||||
</p>
|
||||
|
||||
---
|
||||
|
||||
## Überblick
|
||||
|
||||
**KeySelector** ist eine leichtgewichtige, Local-First-Webanwendung für DJs, die laufende Tracks erkennt, deren musikalische Tonart (als **Camelot-Code** sowie klassische Tonart) und **BPM** bestimmt und direkt harmonisch sowie rhythmisch passende Folge-Tracks vorschlägt.
|
||||
|
||||
```text
|
||||
┌───────────────────────────┐ HTTP / REST ┌──────────────────────────────┐
|
||||
│ Browser (Vanilla JS SPA) │ ◄───────────────────► │ Node.js / Express (:3000) │
|
||||
│ • System- / Mikro-Audio │ │ • /api/recognize (ACR/AudD) │
|
||||
│ • Interaktives SVG-Wheel │ │ • /api/metadata (ffmpeg) │
|
||||
│ • Live-Suche & Filter │ │ • /api/suggestions │
|
||||
└───────────────────────────┘ │ • /api/search, /cover │
|
||||
└──────────────┬───────────────┘
|
||||
│ pg Pool
|
||||
┌──────────────▼───────────────┐
|
||||
│ PostgreSQL (26.000+ Tracks) │
|
||||
│ + In-Memory-Fallback │
|
||||
└──────────────────────────────┘
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Funktionen
|
||||
|
||||
- **Live-Audio-Erkennung (`POST /api/recognize`):** Erfasst wahlweise **PC- / System-Audio** (via `getDisplayMedia` für VLC, DJ-Software, Browser-Tabs, YouTube), **Mikrofon** oder ein **spezifisches Eingabegerät**, zeigt einen Live-Eingangspegel und erkennt Songs über **ACRCloud** oder **AudD**.
|
||||
- **Mehrstufige Metadaten- & Audioanalyse (`GET /api/metadata`):** Ermittelt Tonart, BPM, Genre-Tags, Dauer, Cover und 30-Sekunden-Hörprobe über PostgreSQL (Exakt- und Fuzzy-Suche), **Deezer API**, **SongBPM**, **GetSongBPM**, **Last.fm** sowie eine integrierte **FFmpeg**-Preview-Analyse (Onset-Autokorrelation für BPM + Goertzel-Chroma-Analyse für den Camelot-Key).
|
||||
- **Harmonische Mix-Vorschläge (`GET /api/suggestions`):** Nutzt die Mixed-In-Key-/Camelot-Regeln (`Perfect`, `Quinte -1`, `Quinte +1`, `Energy`, `Scale`, `Diagonal`, `Jaw's`, `Mood`) mit schrittweiser BPM-Toleranz-Erweiterung (`±6%`, `±12%`, `±20%`, bis `50–220 BPM`) sowie UI-Filtern für Mix-Typ und Pitch-Toleranz (`±4% (DJ)`, `±8%`, `Alle BPM`).
|
||||
- **Interaktives Camelot Wheel (`public/wheel.js`):** Zeichnet ein 24-teiliges SVG-Camelot-Wheel (äußerer Dur-Ring `B`, innerer Moll-Ring `A`), hebt kompatible Tonarten hervor und lässt sich per Klick vergrößern.
|
||||
- **Hybride Live-Suche (`GET /api/search`):** Durchsucht zuerst die lokale PostgreSQL-Datenbank und ergänzt Treffer aus der **Deezer Search API** inklusive 30s-Audio-Vorschau und Direktlinks zu Spotify, Deezer und YouTube.
|
||||
- **Dauerhafte Key- & BPM-Korrekturen (`POST /api/tracks/correct`):** Ein Klick auf die Key- oder BPM-Kachel öffnet ein Korrektur-Modal; gespeicherte Werte erhalten `is_corrected = TRUE` in PostgreSQL und haben bei künftigen Suchen Vorrang.
|
||||
- **Audio-Attribute & Cover-Zoom:** Zeigt Tunebat-ähnliche Werte (Dauer, Energy, Danceability, Mood) an und unterstützt Cover-Zoom sowie 30s-Vorschau-Wiedergabe.
|
||||
- **Dark / Light Mode:** Nahtloser Theme-Wechsel über CSS Custom Properties.
|
||||
- **26.000+ Track-Seed:** Initialisiert beim Start automatisch 24-Key-Referenzdaten (`db/schema.sql`) und importiert `db/spotify_songs.csv` (`server/importer.js`), sobald weniger als 5.000 Tracks in der Datenbank liegen.
|
||||
|
||||
---
|
||||
|
||||
## Funktionsweise & Tech-Stack
|
||||
|
||||
Das Frontend (`public/`) benötigt **keinen Build-Schritt** und wird zusammen mit den Modulen in `shared/` direkt von Express (`server/index.js`) ausgeliefert. Die gemeinsamen JavaScript-Dateien in `shared/` funktionieren sowohl in Node.js (`require`) als auch im Browser (`window.*`), sodass Camelot-Geometrie, Farben und Harmonieregeln identisch bleiben. Ist PostgreSQL beim Start nicht erreichbar, schaltet `server/db.js` automatisch auf einen In-Memory-Fallback (`Map`) um.
|
||||
|
||||
| Komponente | Technologie / Details |
|
||||
|---|---|
|
||||
| Frontend | Reines HTML5, CSS3 (Custom Properties), Vanilla JavaScript (`public/`) |
|
||||
| Backend | Node.js 22 (`node:22-alpine` im Docker-Image), Express `^4.18.2`, Multer `^2.2.0`, Axios `^1.19.0` |
|
||||
| Audioverarbeitung | `ffmpeg` & `chromaprint` (im Docker-Image enthalten), eigene PCM-BPM- & Key-Analyse |
|
||||
| Datenbank | PostgreSQL (`postgres:15-alpine`, `pg` `^8.23.0`) mit In-Memory-Fallback |
|
||||
| Externe APIs | ACRCloud, AudD, Deezer, SongBPM, GetSongBPM, Last.fm, iTunes Search API |
|
||||
| Ports | Backend lauscht auf `3000` (in `docker-compose.yml` auf `3030:3000` gemappt); PostgreSQL auf `5432` |
|
||||
|
||||
---
|
||||
|
||||
## Voraussetzungen & Installation
|
||||
|
||||
### Voraussetzungen
|
||||
|
||||
- **Docker & Docker Compose** (empfohlen, enthält PostgreSQL, `ffmpeg` und `chromaprint`), **oder**
|
||||
- **Node.js** (18/22+), **PostgreSQL** und **`ffmpeg`** im `PATH` für den lokalen Start
|
||||
|
||||
### Lokale Installation
|
||||
|
||||
1. Repository klonen:
|
||||
```bash
|
||||
git clone https://git.orfel.de/Jannik/KeySelector.git
|
||||
cd KeySelector
|
||||
```
|
||||
2. `.env.example` nach `.env` (bzw. `server/.env`) kopieren und Datenbank- sowie API-Daten eintragen:
|
||||
```bash
|
||||
cp .env.example server/.env
|
||||
```
|
||||
3. Abhängigkeiten im Server-Ordner installieren und starten:
|
||||
```bash
|
||||
cd server
|
||||
npm install
|
||||
npm start
|
||||
```
|
||||
4. Anwendung im Browser unter `http://localhost:3000` öffnen.
|
||||
|
||||
### Docker & Produktions-Setup
|
||||
|
||||
App und PostgreSQL gemeinsam mit Docker Compose starten:
|
||||
|
||||
```bash
|
||||
docker compose up -d --build
|
||||
```
|
||||
|
||||
Die Weboberfläche ist danach unter `http://localhost:3030` erreichbar (Container-Port `3000`).
|
||||
|
||||
In der **Jannik-Cloud** läuft KeySelector als integrierter Service unter `keyselector.orfel.de` (konfiguriert im Infrastruktur-Repository unter `services/keyselector`).
|
||||
|
||||
---
|
||||
|
||||
## Konfiguration
|
||||
|
||||
Umgebungsvariablen aus `.env.example`, `docker-compose.yml` und `server/`:
|
||||
|
||||
| Variable | Standardwert | Beschreibung |
|
||||
|---|---|---|
|
||||
| `PORT` | `3000` | Port, auf dem Express lokal / im Container lauscht |
|
||||
| `DATABASE_URL` | — | Optionaler PostgreSQL-Connection-String (überschreibt `DB_*`) |
|
||||
| `DB_HOST` | `localhost` (`postgres` in Compose) | PostgreSQL-Host |
|
||||
| `DB_PORT` | `5432` | PostgreSQL-Port |
|
||||
| `DB_USER` | `postgres` | PostgreSQL-Benutzername |
|
||||
| `DB_PASSWORD` | `postgres` | PostgreSQL-Passwort |
|
||||
| `DB_NAME` | `keyselector` | PostgreSQL-Datenbankname |
|
||||
| `ACRCLOUD_HOST` | `identify-eu-west-1.acrcloud.com` | ACRCloud-Erkennungs-Host |
|
||||
| `ACRCLOUD_ACCESS_KEY` | — | ACRCloud Access Key |
|
||||
| `ACRCLOUD_ACCESS_SECRET` | — | ACRCloud Access Secret |
|
||||
| `ACRCLOUD_CONSOLE_TOKEN` | — | Optionaler ACRCloud-Console-Token in `.env.example` |
|
||||
| `AUDD_API_TOKEN` | — | AudD API-Token (`AUDD_API_KEY` wird ebenfalls unterstützt) |
|
||||
| `GETSONGBPM_API_KEY` | — | Optionaler GetSongBPM API-Key für Key-/BPM-Abfragen |
|
||||
| `LASTFM_API_KEY` | — | Optionaler Last.fm API-Key für Genre-Tags |
|
||||
| `MINIMAX_API_KEY` | — | Optionaler MiniMax-Key aus `.env.example` / `docker-compose.yml` |
|
||||
| `NTFY_URL` | — | Optionaler ntfy-Endpunkt für `server/workers/poll-quota.js` |
|
||||
|
||||
### Volumes
|
||||
|
||||
- `pgdata:/var/lib/postgresql/data` (in `docker-compose.yml`) speichert den PostgreSQL-Track-Katalog und manuelle Korrekturen dauerhaft.
|
||||
|
||||
---
|
||||
|
||||
## Nutzung
|
||||
|
||||
### Ablauf in der Weboberfläche
|
||||
|
||||
1. **Audio-Erkennung:** Wähle oben links eine Audioquelle (**PC / System-Audio**, **Mikrofon** oder **Spezifisches Eingabegerät**) und klicke auf das Mikrofon-Badge (`Bereit`), um die Erkennung zu starten oder zu pausieren. Hinweis: Bei System-Audio im Browser-Dialog unbedingt **„Audio teilen“** aktivieren.
|
||||
2. **Manuelle Suche:** Gib Artist oder Songtitel in die Suchleiste ein, um gleichzeitig in der lokalen PostgreSQL-Datenbank und bei Deezer zu suchen.
|
||||
3. **Details & Vorschau:** Klicke auf das Cover zum Vergrößern, auf das Play-Symbol für eine 30s-Hörprobe oder auf das Camelot Wheel rechts unten für die Vollansicht.
|
||||
4. **Key / BPM korrigieren:** Klicke auf die **Key**- oder **BPM**-Statistik-Box, um korrigierte Werte dauerhaft in PostgreSQL zu speichern.
|
||||
5. **Folge-Tracks filtern:** Nutze über den Vorschlägen die Filter-Pills für **Mix** (`Alle`, `Exakt`, `Quinte (±1)`, `Relativ (A↔B)`, `Energy (+2)`) und **Pitch** (`±4% (DJ)`, `±8%`, `Alle BPM`).
|
||||
|
||||
### API-Endpunkte
|
||||
|
||||
| Methode & Pfad | Beschreibung |
|
||||
|---|---|
|
||||
| `POST /api/recognize` | Nimmt `multipart/form-data` (`audio`) entgegen, erkennt per ACRCloud/AudD und reichert aus DB an |
|
||||
| `GET /api/metadata?track=...&artist=...` | Ermittelt Camelot-Key, BPM, Cover, Preview-URL, Tags & Audio-Attribute |
|
||||
| `GET /api/suggestions?key=4B&bpm=120&artist=...&title=...` | Liefert harmonisch passende Tracks sortiert nach Kompatibilitätsstufe |
|
||||
| `GET /api/search?q=...` | Durchsucht lokale PostgreSQL-DB + Deezer API |
|
||||
| `POST /api/tracks/correct` | Speichert manuelle `artist`, `title`, `camelotKey`, `bpm`-Korrekturen (`is_corrected = TRUE`) |
|
||||
| `GET /api/cover?q=...` | Proxy für die iTunes Search API (`300x300` Album-Cover) |
|
||||
|
||||
---
|
||||
|
||||
## Projektstruktur
|
||||
|
||||
```text
|
||||
KeySelector/
|
||||
├── db/
|
||||
│ ├── schema.sql # PostgreSQL-Schema + kuratierte 24-Key-Seed-Tracks
|
||||
│ ├── seed-acousticbrainz.sh # Mock-Skript für AcousticBrainz-Seed
|
||||
│ └── spotify_songs.csv # 26.000+ Track-Katalog (Auto-Import beim Start)
|
||||
├── docs/
|
||||
│ ├── Camelot-Wheel-Chart.png
|
||||
│ ├── Camelot-Wheel-Mixed-In-Key-Harmonic-Mixing.png
|
||||
│ └── KeySelector_SPEC.md # Ursprüngliche Spezifikation
|
||||
├── public/
|
||||
│ ├── app.js # Audio-Capture, UI-Logik & API-Steuerung
|
||||
│ ├── cover.js # Cover-Loader & Zoom-Toggle
|
||||
│ ├── favicon.png
|
||||
│ ├── index.html # Single-Page-Frontend
|
||||
│ ├── search.js # Live-Suchfeld & Deezer-Integration
|
||||
│ ├── styles.css # Dark/Light-Theme-Styling
|
||||
│ └── wheel.js # Interaktives 24-Segment-SVG-Camelot-Wheel
|
||||
├── server/
|
||||
│ ├── routes/
|
||||
│ │ ├── cover.js # iTunes-Cover-Proxy
|
||||
│ │ ├── metadata.js # Multi-Source-Metadaten + ffmpeg-Audioanalyse
|
||||
│ │ ├── recognize.js # ACRCloud- & AudD-Audio-Erkennung
|
||||
│ │ ├── search.js # Hybride Suche (PostgreSQL + Deezer)
|
||||
│ │ ├── suggestions.js # Camelot-Harmonie-Matching-Engine
|
||||
│ │ └── tracks.js # Endpunkt für Key-/BPM-Korrekturen
|
||||
│ ├── workers/
|
||||
│ │ └── poll-quota.js # Täglicher Quota-Check-Stub (ntfy)
|
||||
│ ├── db.js # PostgreSQL-Pool, Schema-Init & In-Memory-Fallback
|
||||
│ ├── importer.js # CSV-Katalog-Importer
|
||||
│ ├── index.js # Express-Einstiegspunkt
|
||||
│ └── package.json
|
||||
├── shared/
|
||||
│ ├── camelot-angle.js # Camelot-Code → SVG-Winkel
|
||||
│ ├── camelot-to-musickey.js # Camelot-Code → Standard-Tonart
|
||||
│ ├── color-matrix.js # Camelot-Farbpalette
|
||||
│ └── mixing-rules.js # Mixed-In-Key-Regeln & Kompatibilitätslabels
|
||||
├── .env.example
|
||||
├── docker-compose.yml
|
||||
├── Dockerfile
|
||||
├── LIESMICH.md
|
||||
└── README.md
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Lizenz
|
||||
|
||||
Privates / Internes Projekt.
|
||||
@@ -1,52 +1,206 @@
|
||||
# KeySelector
|
||||
<p align="center">
|
||||
<img src="public/favicon.png" alt="KeySelector Logo" width="128" />
|
||||
</p>
|
||||
|
||||
KeySelector ist ein browserbasiertes DJ-Tool, das dir dabei hilft, harmonisch passende Tracks für dein nächstes Set zu finden. Es nutzt Audio-Fingerprinting (über das Mikrofon), um laufende Songs zu erkennen, analysiert deren BPM sowie die musikalische Tonart (ausgedrückt als Camelot-Code) und schlägt darauf basierend harmonisch kompatible Nachfolgetracks vor.
|
||||
<h1 align="center">KeySelector</h1>
|
||||
<p align="center"><strong>A browser-based harmonic DJ assistant with live audio recognition, interactive Camelot Wheel, and PostgreSQL track catalog.</strong></p>
|
||||
|
||||
## 🌟 Features
|
||||
<p align="center">
|
||||
<a href="README.md">🇬🇧 English</a> · <a href="LIESMICH.md">🇩🇪 Deutsch</a>
|
||||
</p>
|
||||
|
||||
- **🎤 Live Audio Recognition**: Erkennt den aktuell laufenden Track in der Umgebung (via AcoustID / Mock).
|
||||
- **🎛️ Harmonic Mixing Suggestions**: Nutzt die "Mixed In Key"-Regeln, um perfekte Übergänge (Perfect, Quinte, Energy, Scale etc.) vorzuschlagen.
|
||||
- **🎡 Interaktives Camelot Wheel**: Visualisiert die aktuelle Tonart und hebt kompatible Tonarten direkt im Wheel hervor.
|
||||
- **🔍 Manueller Fallback**: Song nicht erkannt? Die manuelle Suche findet Tracks über Metadaten.
|
||||
- **🌓 Dark/Light Mode**: Nahtloser Wechsel zwischen verschiedenen Farbschemata.
|
||||
---
|
||||
|
||||
## 🏗️ Architektur
|
||||
## Overview
|
||||
|
||||
Das Projekt ist bewusst leichtgewichtig aufgebaut und auf Dauerbetrieb in der Cloud ausgelegt:
|
||||
- **Frontend (`public/`)**: Pures Vanilla JS, HTML und CSS. Kein Build-Schritt, schnelle Ladezeiten.
|
||||
- **Backend (`server/`)**: Node.js mit Express. Handhabt das Audio-Fingerprinting, ruft Metadaten ab (GetSongBPM, Last.fm) und liefert Cover via iTunes-API (umgeht Frontend-CORS).
|
||||
- **Shared (`shared/`)**: Geteilte Logik für Camelot-Geometrie und Harmonie-Regeln.
|
||||
- **Datenbank (`db/`)**: PostgreSQL (via Jannik-Cloud bereitgestellt) für einen massiven Seed aus AcousticBrainz-Daten.
|
||||
**KeySelector** is a lightweight, local-first web application designed for DJs to identify currently playing tracks, inspect their musical key (in **Camelot** and standard musical notation) and **BPM**, and immediately discover harmonically and rhythmically compatible follow-up tracks.
|
||||
|
||||
## 🚀 Installation & Setup (Lokale Entwicklung)
|
||||
```text
|
||||
┌───────────────────────────┐ HTTP / REST ┌──────────────────────────────┐
|
||||
│ Browser (Vanilla JS SPA) │ ◄───────────────────► │ Node.js / Express (:3000) │
|
||||
│ • System / Mic Capture │ │ • /api/recognize (ACR/AudD) │
|
||||
│ • Interactive SVG Wheel │ │ • /api/metadata (ffmpeg) │
|
||||
│ • Live Search & Filters │ │ • /api/suggestions │
|
||||
└───────────────────────────┘ │ • /api/search, /cover │
|
||||
└──────────────┬───────────────┘
|
||||
│ pg Pool
|
||||
┌──────────────▼───────────────┐
|
||||
│ PostgreSQL (26,000+ tracks) │
|
||||
│ + In-Memory Fallback │
|
||||
└──────────────────────────────┘
|
||||
```
|
||||
|
||||
Voraussetzungen: [Node.js](https://nodejs.org/)
|
||||
---
|
||||
|
||||
1. **Repository klonen**
|
||||
## Features
|
||||
|
||||
- **Live Audio Recognition (`POST /api/recognize`):** Captures **PC / System Audio** (via `getDisplayMedia` for VLC, DJ software, browser tabs, YouTube), **Room Microphone**, or a **specific audio input device**, includes a live input level meter, and identifies songs via **ACRCloud** or **AudD**.
|
||||
- **Multi-Source Metadata & Audio Analysis (`GET /api/metadata`):** Resolves key, BPM, genre tags, duration, cover art, and 30-second audio previews using PostgreSQL lookup (exact + fuzzy matching), **Deezer API**, **SongBPM**, **GetSongBPM**, **Last.fm**, and built-in **FFmpeg** preview audio analysis (BPM onset autocorrelation + Goertzel chroma key detection).
|
||||
- **Harmonic Mixing Suggestions (`GET /api/suggestions`):** Applies Mixed In Key / Camelot compatibility rules (`Perfect`, `Quinte -1`, `Quinte +1`, `Energy`, `Scale`, `Diagonal`, `Jaw's`, `Mood`) with progressive BPM tolerance widening (`±6%`, `±12%`, `±20%`, up to `50–220 BPM`) and UI filters for Mix Type and Pitch Tolerance (`±4% (DJ)`, `±8%`, `All BPM`).
|
||||
- **Interactive Camelot Wheel (`public/wheel.js`):** Renders a 24-segment SVG Camelot Wheel (outer `B` Major ring, inner `A` Minor ring) that highlights compatible keys and expands inline on click.
|
||||
- **Live Hybrid Search (`GET /api/search`):** Searches local PostgreSQL tracks first and merges live results from the **Deezer Search API** with 30-second audio previews and quick links to Spotify, Deezer, and YouTube.
|
||||
- **Persistent Key & BPM Corrections (`POST /api/tracks/correct`):** Click on the Key or BPM stat card to correct values in a modal; corrections are saved with `is_corrected = TRUE` in PostgreSQL and take precedence in future lookups.
|
||||
- **Audio Attributes & Cover Zoom:** Displays Tunebat-style attributes (Duration, Energy, Danceability, Mood) and supports inline cover expansion and 30-second preview playback.
|
||||
- **Dark / Light Theme:** Instant theme switching via CSS custom properties.
|
||||
- **26,000+ Track Catalog Seed:** Automatically seeds curated Camelot reference tracks (`db/schema.sql`) and imports `db/spotify_songs.csv` (`server/importer.js`) on startup when the database has fewer than 5,000 tracks.
|
||||
|
||||
---
|
||||
|
||||
## How It Works & Tech Stack
|
||||
|
||||
The frontend (`public/`) requires **no build step** and is served statically alongside `/shared` modules by Express (`server/index.js`). Shared JavaScript files in `shared/` work identically in both Node.js (`require`) and the browser (`window.*`) to guarantee consistent Camelot geometry, colors, and mixing rules. If PostgreSQL is unavailable at startup, `server/db.js` automatically falls back to an in-memory `Map`.
|
||||
|
||||
| Component | Technology / Details |
|
||||
|---|---|
|
||||
| Frontend | Vanilla HTML5, CSS3 (Custom Properties), JavaScript (`public/`) |
|
||||
| Backend | Node.js 22 (`node:22-alpine` in Docker), Express `^4.18.2`, Multer `^2.2.0`, Axios `^1.19.0` |
|
||||
| Audio Processing | `ffmpeg` & `chromaprint` (installed in Docker image), custom PCM BPM & key analyzer |
|
||||
| Database | PostgreSQL (`postgres:15-alpine`, `pg` `^8.23.0`) with in-memory fallback |
|
||||
| External APIs | ACRCloud, AudD, Deezer, SongBPM, GetSongBPM, Last.fm, iTunes Search API |
|
||||
| Ports | Backend listens on `3000` (mapped to `3030:3000` in `docker-compose.yml`); PostgreSQL on `5432` |
|
||||
|
||||
---
|
||||
|
||||
## Prerequisites & Installation
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- **Docker & Docker Compose** (recommended, includes PostgreSQL, `ffmpeg`, and `chromaprint`), **or**
|
||||
- **Node.js** (18/22+), **PostgreSQL**, and **`ffmpeg`** in `PATH` for local execution
|
||||
|
||||
### Local Installation
|
||||
|
||||
1. Clone the repository:
|
||||
```bash
|
||||
git clone https://git.orfel.de/Jannik/KeySelector.git
|
||||
cd KeySelector
|
||||
```
|
||||
|
||||
2. **Backend starten (Node.js)**
|
||||
2. Copy `.env.example` to `.env` (or `server/.env`) and configure your database and API keys:
|
||||
```bash
|
||||
cp .env.example server/.env
|
||||
```
|
||||
3. Install backend dependencies and start the server:
|
||||
```bash
|
||||
cd server
|
||||
npm install
|
||||
|
||||
# Umgebungsvariablen (wie API Keys) exportieren oder in eine .env Datei in server/ schreiben
|
||||
npm start
|
||||
```
|
||||
Die App ist danach unter `http://localhost:3000` erreichbar.
|
||||
4. Open `http://localhost:3000` in your browser.
|
||||
|
||||
## ☁️ Deployment (Jannik-Cloud)
|
||||
### Docker & Production Setup
|
||||
|
||||
KeySelector ist als nativer Service in die **Jannik-Cloud** integriert.
|
||||
Die Deployment-Files (wie z.B. das Caddy-Routing und das Produktions-`docker-compose.yml`) befinden sich im zentralen Cloud-Infrastruktur-Repository unter `services/keyselector`.
|
||||
Start both the KeySelector app and PostgreSQL database via Docker Compose:
|
||||
|
||||
Sobald Code auf den `main`-Branch dieses Repos gepusht wird, kann der Service in der Jannik-Cloud hochgezogen werden. Er zieht sich automatisch den neuesten Code, baut den Container und geht online unter `keyselector.orfel.de`.
|
||||
```bash
|
||||
docker compose up -d --build
|
||||
```
|
||||
|
||||
## 📚 Dokumentation
|
||||
The web UI will be available at `http://localhost:3030` (container port `3000`).
|
||||
|
||||
Weitere technische Details und Spezifikationen (sowie die initiale Konzept-Idee) findest du im `docs/` Ordner:
|
||||
- `docs/KeySelector_SPEC.md`
|
||||
- `docs/Camelot-Wheel-Chart.png`
|
||||
In **Jannik-Cloud**, KeySelector runs as an integrated service under `keyselector.orfel.de` (configured in the central infrastructure repo under `services/keyselector`).
|
||||
|
||||
---
|
||||
|
||||
## Configuration
|
||||
|
||||
Environment variables defined in `.env.example`, `docker-compose.yml`, and `server/`:
|
||||
|
||||
| Variable | Default | Description |
|
||||
|---|---|---|
|
||||
| `PORT` | `3000` | Port Express listens on inside the container / locally |
|
||||
| `DATABASE_URL` | — | Optional full PostgreSQL connection string (overrides `DB_*` vars) |
|
||||
| `DB_HOST` | `localhost` (`postgres` in Compose) | PostgreSQL host |
|
||||
| `DB_PORT` | `5432` | PostgreSQL port |
|
||||
| `DB_USER` | `postgres` | PostgreSQL user |
|
||||
| `DB_PASSWORD` | `postgres` | PostgreSQL password |
|
||||
| `DB_NAME` | `keyselector` | PostgreSQL database name |
|
||||
| `ACRCLOUD_HOST` | `identify-eu-west-1.acrcloud.com` | ACRCloud identification host |
|
||||
| `ACRCLOUD_ACCESS_KEY` | — | ACRCloud project access key |
|
||||
| `ACRCLOUD_ACCESS_SECRET` | — | ACRCloud project access secret |
|
||||
| `ACRCLOUD_CONSOLE_TOKEN` | — | Optional ACRCloud console token in `.env.example` |
|
||||
| `AUDD_API_TOKEN` | — | AudD API token (`AUDD_API_KEY` also accepted as fallback) |
|
||||
| `GETSONGBPM_API_KEY` | — | Optional GetSongBPM API key for key/BPM lookups |
|
||||
| `LASTFM_API_KEY` | — | Optional Last.fm API key for genre tag enrichment |
|
||||
| `MINIMAX_API_KEY` | — | Optional MiniMax key listed in `.env.example` / `docker-compose.yml` |
|
||||
| `NTFY_URL` | — | Optional ntfy endpoint used by `server/workers/poll-quota.js` |
|
||||
|
||||
### Volumes
|
||||
|
||||
- `pgdata:/var/lib/postgresql/data` (in `docker-compose.yml`) persists the PostgreSQL track catalog and user corrections.
|
||||
|
||||
---
|
||||
|
||||
## Usage
|
||||
|
||||
### Web UI Workflow
|
||||
|
||||
1. **Audio Recognition:** Select an audio source in the top bar (**System Audio**, **Microphone**, or **Specific Device**) and click the microphone status badge (`Bereit`) to start or pause listening. Note: For System Audio, check **"Share audio"** in the browser's screen/tab picker.
|
||||
2. **Manual Search:** Type an artist or track title in the search bar to query the local catalog and Deezer simultaneously.
|
||||
3. **Inspect & Play:** Click the album cover to zoom in, click the play icon on the cover for a 30-second audio preview, or click the Camelot Wheel in the bottom-right of the hero card to expand it full-size.
|
||||
4. **Correct Key / BPM:** Click the **Key** or **BPM** stat box to open the correction modal and save verified values to PostgreSQL.
|
||||
5. **Filter Follow-Up Tracks:** Use the **Mix** pills (`Alle`, `Exakt`, `Quinte (±1)`, `Relativ (A↔B)`, `Energy (+2)`) and **Pitch** pills (`±4% (DJ)`, `±8%`, `Alle BPM`) above the suggestions grid.
|
||||
|
||||
### API Endpoints
|
||||
|
||||
| Method & Path | Description |
|
||||
|---|---|
|
||||
| `POST /api/recognize` | Accepts `multipart/form-data` (`audio` file), identifies via ACRCloud/AudD, enriches from DB |
|
||||
| `GET /api/metadata?track=...&artist=...` | Resolves Camelot key, BPM, cover, preview URL, tags & audio features |
|
||||
| `GET /api/suggestions?key=4B&bpm=120&artist=...&title=...` | Returns harmonically compatible tracks sorted by compatibility level |
|
||||
| `GET /api/search?q=...` | Searches local PostgreSQL + Deezer API |
|
||||
| `POST /api/tracks/correct` | Saves manual `artist`, `title`, `camelotKey`, `bpm` corrections (`is_corrected = TRUE`) |
|
||||
| `GET /api/cover?q=...` | Proxies iTunes Search API for `300x300` album artwork |
|
||||
|
||||
---
|
||||
|
||||
## Project Structure
|
||||
|
||||
```text
|
||||
KeySelector/
|
||||
├── db/
|
||||
│ ├── schema.sql # PostgreSQL schema + 24-key curated seed tracks
|
||||
│ ├── seed-acousticbrainz.sh # Placeholder/mock AcousticBrainz seed script
|
||||
│ └── spotify_songs.csv # 26,000+ track catalog auto-imported on init
|
||||
├── docs/
|
||||
│ ├── Camelot-Wheel-Chart.png
|
||||
│ ├── Camelot-Wheel-Mixed-In-Key-Harmonic-Mixing.png
|
||||
│ └── KeySelector_SPEC.md # Original design specification
|
||||
├── public/
|
||||
│ ├── app.js # Audio capture, UI state & API orchestration
|
||||
│ ├── cover.js # Album cover loading & zoom toggle
|
||||
│ ├── favicon.png
|
||||
│ ├── index.html # Single-page frontend
|
||||
│ ├── search.js # Live search dropdown & Deezer integration
|
||||
│ ├── styles.css # Dark/Light theme styling
|
||||
│ └── wheel.js # Interactive 24-segment SVG Camelot Wheel
|
||||
├── server/
|
||||
│ ├── routes/
|
||||
│ │ ├── cover.js # iTunes cover proxy
|
||||
│ │ ├── metadata.js # Multi-source metadata + ffmpeg audio analyzer
|
||||
│ │ ├── recognize.js # ACRCloud & AudD audio recognition
|
||||
│ │ ├── search.js # Local DB + Deezer hybrid search
|
||||
│ │ ├── suggestions.js # Camelot harmonic matching engine
|
||||
│ │ └── tracks.js # User key/BPM correction endpoint
|
||||
│ ├── workers/
|
||||
│ │ └── poll-quota.js # Daily quota check stub (ntfy)
|
||||
│ ├── db.js # PostgreSQL pool, schema init & in-memory fallback
|
||||
│ ├── importer.js # Bulk CSV catalog importer
|
||||
│ ├── index.js # Express app entrypoint
|
||||
│ └── package.json
|
||||
├── shared/
|
||||
│ ├── camelot-angle.js # Camelot code to SVG angle mapping
|
||||
│ ├── camelot-to-musickey.js # Camelot to standard musical key mapping
|
||||
│ ├── color-matrix.js # Camelot color palette
|
||||
│ └── mixing-rules.js # Mixed In Key compatibility rules & labels
|
||||
├── .env.example
|
||||
├── docker-compose.yml
|
||||
├── Dockerfile
|
||||
├── LIESMICH.md
|
||||
└── README.md
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## License
|
||||
|
||||
Private / Internal Project.
|
||||
Reference in new issue
Block a user