An intelligent DJ assistant that recommends tracks based on harmonic compatibility, BPM matching, and energy flow โ using real DJ mixing principles.
Note: Song recommendations are currently limited to the ~90,000 tracks in the Maharishi Dataset from Hugging Face.
- Automatically maps Spotify key/mode data to the Camelot Wheel notation (1A-12A, 1B-12B)
- Recommends tracks that are harmonically compatible for smooth transitions
- Supports same key, relative key, and adjacent key matching with configurable thresholds
- Intelligent tempo matching with configurable tolerance (default ยฑ7%)
- Half-time/double-time detection โ seamlessly mix 70 BPM with 140 BPM tracks
- Direction controls:
faster,maintain, orslowerfor building or dropping energy
- Control the energy trajectory of your set with
build,maintain, ordropmodes - Separate control for energy levels independent of other audio features
- Smart scoring that accounts for edge cases (can't build when already at max)
Fine-tune recommendations using Spotify's audio analysis features:
| Feature | Description |
|---|---|
| Danceability | How suitable for dancing (rhythm, tempo, beat strength) |
| Valence | Musical positiveness (happy vs sad) |
| Acousticness | Likelihood of being acoustic |
| Instrumentalness | Predicts if track has no vocals |
| Speechiness | Presence of spoken words |
| Liveness | Presence of live audience |
| Loudness | Overall loudness in dB |
Each feature supports directional control: build, maintain, or drop.
- Genre similarity engine using audio feature centroids
- Automatically suggests similar genres based on your current track
- Explainable results: "Similar energy (0.78 vs 0.81) and tempo (128 vs 126 BPM)"
- Filter recommendations by specific genres
- Deck A & Deck B for professional DJ-style workflow
- Build separate playlists for each deck
- Toggle recommendation source between decks
- Preview tracks before committing to your set
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Frontend (React + Vite) โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Deck A โ โ Deck B โ โ Recommendations โ โ
โ โ (Preview) โ โ (Preview) โ โ (Scored & Filtered) โ โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ FastAPI Backend (api.py) โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ /search โ โ /recommend โ โ /genres/{genre}/similarโ โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Core Engine (src/) โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Camelot โ โ Scoring โ โ Genre Similarity โ โ
โ โ Wheel โ โ Engine โ โ (Euclidean dist) โ โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Recommender โ โ TrackDatabase (HuggingFace) โ โ
โ โ Engine โ โ 114k+ Spotify Tracks โ โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
- Python 3.10+
- Node.js 18+ (for frontend)
git clone https://github.com/KTB2110/dj-assistant.git
cd dj-assistant
# Create virtual environment
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Set up environment variables (for Spotify API features)
cp .env.example .env
# Edit .env with your Spotify API credentialsuvicorn api:app --reloadThe API will be available at http://127.0.0.1:8000
cd frontend
npm install
npm run devThe frontend will be available at http://localhost:5173
GET /search?query=daft+punk&limit=10GET /track/{track_id}POST /recommend
Content-Type: application/json
{
"track": { ... }, // Current track object
"bpm_direction": "maintain", // "faster" | "maintain" | "slower"
"energy_direction": "build", // "build" | "maintain" | "drop"
"feature_directions": { // Optional advanced controls
"danceability": "maintain",
"valence": "build",
"loudness": "drop"
},
"limit": 10,
"genre_filter": ["house", "tech-house"],
"camelot_threshold": 0.7
}GET /genresGET /genres/{genre}/similar?top_k=10dj-assistant/
โโโ api.py # FastAPI backend server
โโโ app.py # Streamlit app (alternative UI)
โโโ requirements.txt # Python dependencies
โ
โโโ src/ # Core Python modules
โ โโโ camelot.py # Camelot wheel & harmonic mixing
โ โโโ scoring.py # BPM, energy, loudness compatibility
โ โโโ recommender.py # Main DJRecommender engine
โ โโโ database.py # Track database (HuggingFace dataset)
โ โโโ genres.py # Genre similarity engine
โ โโโ config.py # Configuration & environment
โ
โโโ frontend/ # React + Vite frontend
โ โโโ src/
โ โ โโโ App.jsx # Main dual-deck interface
โ โ โโโ ...
โ โโโ package.json
โ โโโ vite.config.js
โ
โโโ notebooks/ # Jupyter notebooks for exploration
โ โโโ genre_analysis.ipynb # Genre similarity development
โ โโโ spotipy_analysis.ipynb
โ
โโโ data/ # Data files
โ โโโ raw/
โ โโโ processed/
โ โโโ cache/
โ
โโโ tests/ # Unit tests
โโโ test_recommender.py
โโโ test_dataset.py
โโโ ...
The recommendation engine uses a weighted scoring system:
| Component | Weight | Description |
|---|---|---|
| BPM | 35% | Tempo compatibility |
| Energy | 35% | Energy level match |
| Features | 30% | Audio feature similarity |
When custom feature weights are applied:
| Component | Weight |
|---|---|
| BPM | 27.5% |
| Energy | 27.5% |
| Features | 45% |
| Relationship | Score |
|---|---|
| Same key | 1.0 |
| Relative key (same number, AโB) | 0.95 |
| Adjacent key (ยฑ1, same mode) | 0.85 |
| Adjacent key (ยฑ1, different mode) | 0.75 |
| 2 steps apart | 0.5 |
| 3-4 steps apart | 0.25 |
| 5+ steps apart | 0.1 |
Create a .env file in the root directory:
SPOTIFY_CLIENT_ID=your_client_id
SPOTIFY_CLIENT_SECRET=your_client_secretYou can customize the scoring weights when calling the recommender:
from src.recommender import DJRecommender
recommender.recommend(
current_track=track,
master_weights={
'bpm': 0.4,
'energy': 0.4,
'features': 0.2
},
feature_weights={
'danceability': 1.5, # Prioritize danceability
'valence': 0.5, # De-prioritize mood
}
)pytest tests/ -v- Spotify OAuth integration for library access
- Audio preview playback
- Setlist export (M3U, CSV)
- BPM/key analysis for local files
- Transition suggestions between tracks
- Machine learning personalization
MIT License โ feel free to use this for your own DJ projects!
- Dataset: Spotify Tracks Dataset by Maharshi Pandya
- Camelot Wheel concept by Mark Davis
Built with โค๏ธ for DJs who love data