Tagline: A Spotify-like music library and player with AI-powered natural language queries.
- Project Overview
- Key Highlights
- Features
- Tech Stack
- Database Schema
- Installation
- Running the Project
- Usage
- AI/LLM Integration
- Project Structure
- API Documentation
- Advanced SQL Demonstrations
- Screenshots
- Use Cases
- Contributing
- License
- Acknowledgments
- Contact
- Project Statistics
-
π Real-Time SQL Query Visualization- Users (
user_id,name,email,password_hash,role)- Built-in SQL Terminal showing all database operations- Artists (
artist_id,stage_name,bio,profile_picture_url)
- Built-in SQL Terminal showing all database operations- Artists (
HarmonyDB is not just another music streaming applicationβit's a comprehensive demonstration of modern full-stack development practices, advanced database management systems (DBMS) concepts, and cutting-edge AI integration. Built from the ground up as a sophisticated educational and practical project, HarmonyDB showcases:
- Full-Stack Excellence: A seamless integration of Django REST Framework backend with a modern React TypeScript frontend
- Advanced Database Operations: Real-world implementation of complex SQL queries, window functions, subqueries, and advanced aggregations
- AI-Powered Interactions: Natural language to SQL query conversion using state-of-the-art LLM models (Groq API)
- Production-Ready Features: JWT authentication, role-based access control, real-time SQL debugging, and comprehensive analytics
- Educational Value: Every component designed to demonstrate DBMS concepts in a practical, real-world application
-
π€ AI-Powered Natural Language Queries
- Ask questions in plain English: "Show me all songs by The Weeknd from the last 30 days"
- Automatic SQL generation and execution
- Support for complex queries including JOINs, subqueries, aggregations, and window functions
- Fallback processing for enhanced reliability
-
π Real-Time SQL Query Visualization
- Built-in SQL Terminal showing all database operations
- Query execution time monitoring
- Beautiful syntax highlighting
- Educational tool for understanding backend operations
-
π Dual-Role System Architecture
- Listeners: Discover music, create playlists, track listening history
- Artists: Upload songs, create albums, manage discography, view analytics
-
π Advanced Analytics Dashboard
- Trending songs with sophisticated scoring algorithms
- User behavior analytics
- Genre distribution analysis
- Play count trends and patterns
-
π Enterprise-Grade Security
- JWT-based authentication with token refresh
- Role-based access control (RBAC)
- Token blacklisting on logout
- Secure password hashing with Django's built-in validators
-
π¨ Modern, Responsive UI/UX
- Sleek design with Tailwind CSS 4.x
- Smooth animations with Framer Motion
- Responsive across all devices
- Intuitive navigation and user experiences
- Song Upload & Streaming: High-quality audio file management with cover images
- Album Organization: Group songs into albums with metadata and artwork
- Genre Categorization: Multi-genre support with custom genre creation
- Advanced Search: Full-text search across songs, artists, albums, and genres
- Audio Player: Feature-rich player with queue management
- Multi-Role Authentication: Separate experiences for Listeners and Artists
- Profile Management: Customizable user profiles with bios and profile pictures
- Playlist Creation: Unlimited public/private playlists
- Favorites System: Like songs, albums, and playlists
- Listening History: Track all played songs with timestamps
- Comments & Engagement: Comment on songs and albums
- Music Upload: Upload songs with detailed metadata
- Album Management: Create and manage album collections
- Analytics Dashboard: View play counts, listener statistics, and trends
- Profile Customization: Stage name, bio, and artist profile picture
- Natural Language Queries: Ask questions in plain English
- SQL Generation: Automatic SQL query generation from natural language
- Query Execution: Safe execution of generated queries
- DBMS Concept Demonstration: Supports all major SQL concepts
- Trending Analysis: Identify trending songs based on recent activity
- User Statistics: Comprehensive stats for both listeners and artists
- Genre Analytics: Distribution and popularity metrics
- Play Count Tracking: Automatic increment on song play
| Technology | Version | Purpose |
|---|---|---|
| Django | 5.2.6 | Core web framework |
| Django REST Framework | Latest | RESTful API development |
| PostgreSQL | 14+ | Primary database |
| djangorestframework-simplejwt | Latest | JWT authentication |
| django-cors-headers | Latest | Cross-origin resource sharing |
| Pillow | Latest | Image processing |
| python-dotenv | Latest | Environment variable management |
| Groq API | Latest | LLM for natural language processing |
| Technology | Version | Purpose |
|---|---|---|
| React | 19.1.1 | UI framework |
| TypeScript | 5.8.3 | Type-safe JavaScript |
| Vite | 7.1.2 | Build tool and dev server |
| Tailwind CSS | 4.1.13 | Utility-first CSS framework |
| Framer Motion | 12.23.15 | Animation library |
| React Router | 7.9.1 | Client-side routing |
| Lucide React | Latest | Icon library |
- ESLint - Code quality and consistency
- TypeScript ESLint - TypeScript-specific linting
- Vite Plugin React - Fast refresh and JSX support
Our database schema follows Third Normal Form (3NF) principles to eliminate data redundancy and ensure data integrity.
Users Table
users (
id: SERIAL PRIMARY KEY,
username: VARCHAR(150) UNIQUE NOT NULL,
email: VARCHAR(254) UNIQUE NOT NULL,
password: VARCHAR(128) NOT NULL,
role: VARCHAR(20) CHECK(role IN ('listener', 'artist')),
email_verified: BOOLEAN DEFAULT FALSE,
profile_picture: VARCHAR(255),
bio: TEXT,
stage_name: VARCHAR(255), -- For artists
birth_date: DATE, -- For listeners
created_at: TIMESTAMP DEFAULT NOW(),
updated_at: TIMESTAMP DEFAULT NOW()
)Songs Table
songs (
id: SERIAL PRIMARY KEY,
title: VARCHAR(255) NOT NULL,
artist_id: INT REFERENCES users(id) ON DELETE CASCADE,
album_id: INT REFERENCES albums(id) ON DELETE SET NULL,
genre_id: INT REFERENCES genres(id) ON DELETE SET NULL,
audio_file: VARCHAR(255) NOT NULL,
cover_image: VARCHAR(255),
duration: FLOAT DEFAULT 0,
play_count: INT DEFAULT 0,
release_date: DATE DEFAULT NOW(),
upload_date: TIMESTAMP DEFAULT NOW(),
approved: BOOLEAN DEFAULT TRUE
)Albums Table
albums (
id: SERIAL PRIMARY KEY,
title: VARCHAR(255) NOT NULL,
artist_id: INT REFERENCES users(id) ON DELETE CASCADE,
cover_image: VARCHAR(255),
release_date: DATE,
created_at: TIMESTAMP DEFAULT NOW(),
updated_at: TIMESTAMP DEFAULT NOW()
)Playlists & Playlist_Songs (M:N)
playlists (
id: SERIAL PRIMARY KEY,
name: VARCHAR(255) NOT NULL,
user_id: INT REFERENCES users(id) ON DELETE CASCADE,
cover_image: VARCHAR(255),
is_public: BOOLEAN DEFAULT TRUE,
created_at: TIMESTAMP DEFAULT NOW()
)
playlist_songs (
id: SERIAL PRIMARY KEY,
playlist_id: INT REFERENCES playlists(id) ON DELETE CASCADE,
song_id: INT REFERENCES songs(id) ON DELETE CASCADE,
added_at: TIMESTAMP DEFAULT NOW(),
order: INT DEFAULT 0,
UNIQUE(playlist_id, song_id)
)Favorites (Polymorphic)
favorites (
id: SERIAL PRIMARY KEY,
user_id: INT REFERENCES users(id) ON DELETE CASCADE,
item_type: VARCHAR(20) CHECK(item_type IN ('song', 'album', 'playlist')),
item_id: INT NOT NULL,
created_at: TIMESTAMP DEFAULT NOW(),
UNIQUE(user_id, item_type, item_id)
)Listening History
listening_history (
id: SERIAL PRIMARY KEY,
user_id: INT REFERENCES users(id) ON DELETE CASCADE,
song_id: INT REFERENCES songs(id) ON DELETE CASCADE,
listened_at: TIMESTAMP DEFAULT NOW()
)AI Integration Tables
ai_prompts (
id: SERIAL PRIMARY KEY,
user_id: INT REFERENCES users(id) ON DELETE CASCADE,
prompt_text: TEXT NOT NULL,
response_text: TEXT,
generated_sql: TEXT,
executed_result: TEXT,
created_at: TIMESTAMP DEFAULT NOW()
)
ai_interactions (
id: SERIAL PRIMARY KEY,
user_id: INT REFERENCES ai_prompts(id) ON DELETE CASCADE,
prompt_id: INT REFERENCES ai_prompts(id) ON DELETE CASCADE,
message_type: VARCHAR(10) CHECK(message_type IN ('user', 'ai')),
message_text: TEXT NOT NULL,
timestamp: TIMESTAMP DEFAULT NOW()
)- User β Songs: One-to-Many (An artist can have many songs)
- User β Albums: One-to-Many (An artist can have many albums)
- User β Playlists: One-to-Many (A user can have many playlists)
- Album β Songs: One-to-Many (An album contains many songs)
- Genre β Songs: One-to-Many (A genre can classify many songs)
- Playlist β Songs: Many-to-Many (through playlist_songs)
- User β Favorites: One-to-Many (Polymorphic relationship)
- User β Listening History: One-to-Many
-- Unique constraints
CREATE UNIQUE INDEX idx_users_username ON users(username);
CREATE UNIQUE INDEX idx_users_email ON users(email);
CREATE UNIQUE INDEX idx_playlist_songs ON playlist_songs(playlist_id, song_id);
-- Performance indexes
CREATE INDEX idx_songs_artist ON songs(artist_id);
CREATE INDEX idx_songs_album ON songs(album_id);
CREATE INDEX idx_songs_genre ON songs(genre_id);
CREATE INDEX idx_songs_playcount ON songs(play_count DESC);
CREATE INDEX idx_listening_history_user ON listening_history(user_id);
CREATE INDEX idx_listening_history_song ON listening_history(song_id);
CREATE INDEX idx_listening_history_date ON listening_history(listened_at DESC);harmonydb/
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ harmonydb-backend/
β Client Layer (Browser) ββ βββ manage.py
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ ββ βββ harmonydb/
β β React 19 + TypeScript + Tailwind CSS + Vite β ββ β βββ __init__.py
β β - Context API (Auth, Player, SQL Debug) β ββ β βββ settings.py
β β - React Router (Client-side routing) β ββ β βββ urls.py
β β - Framer Motion (Animations) β ββ β βββ wsgi.py
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ ββ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ harmonydb-frontend/
ββ βββ src/
β HTTP/HTTPS (JSON)β β βββ components/
β JWT Token Authβ β βββ pages/
βΌβ β βββ App.tsx
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β API Layer (Django REST) ββββ docs/ # ER diagrams, schema docs
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ ββββ media/ # Uploaded music and cover images
β β Django 5.2.6 + Django REST Framework β ββββ requirements.txt
β β - JWT Authentication Middleware β ββββ README.md
β β - CORS Headers Configuration β β```
β β - SQL Debug Middleware β β
β β - Custom Permission Classes β β---
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ## Contributing
β
β ORM / Raw SQL1. Fork the repository.
βΌ2. Create a branch (`git checkout -b feature-name`).
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ3. Make changes, add tests if needed.
β Database Layer β4. Commit (`git commit -m "Add feature"`) and push (`git push origin feature-name`).
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β5. Open a Pull Request.
β β PostgreSQL 14+ β β
β β - 13 Normalized Tables β β---
β β - Complex Relationships (1:1, 1:N, M:N) β β
β β - Indexes and Constraints β β## License
β β - Triggers and Views β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ βThis project is licensed under the MIT License.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β---
β API Calls
βΌ**Created by:** Sarwad Hasan Siddiqui
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ**Course:** Database Systems Laboratory (CSE-3110, KUET)
β AI/LLM Layer β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Groq API (llama-3.3-70b-versatile) β β
β β - Natural Language Understanding β β
β β - SQL Query Generation β β
β β - Intent Classification β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- User Interaction β Client sends HTTP request with JWT token
- Authentication β Django validates JWT and user permissions
- SQL Debug Middleware β Captures all SQL queries for debugging
- Business Logic β Views process request using ORM/Raw SQL
- Database Operations β PostgreSQL executes optimized queries
- AI Processing (if needed) β Groq API converts NL to SQL
- Response Formation β Django serializes data + SQL debug info
- Client Update β React updates UI + SQL Terminal
Our database schema follows Third Normal Form (3NF) principles to eliminate data redundancy and ensure data integrity.
Users Table
users (
id: SERIAL PRIMARY KEY,
username: VARCHAR(150) UNIQUE NOT NULL,
email: VARCHAR(254) UNIQUE NOT NULL,
password: VARCHAR(128) NOT NULL,
role: VARCHAR(20) CHECK(role IN ('listener', 'artist')),
email_verified: BOOLEAN DEFAULT FALSE,
profile_picture: VARCHAR(255),
bio: TEXT,
stage_name: VARCHAR(255), -- For artists
birth_date: DATE, -- For listeners
created_at: TIMESTAMP DEFAULT NOW(),
updated_at: TIMESTAMP DEFAULT NOW()
)Songs Table
songs (
id: SERIAL PRIMARY KEY,
title: VARCHAR(255) NOT NULL,
artist_id: INT REFERENCES users(id) ON DELETE CASCADE,
album_id: INT REFERENCES albums(id) ON DELETE SET NULL,
genre_id: INT REFERENCES genres(id) ON DELETE SET NULL,
audio_file: VARCHAR(255) NOT NULL,
cover_image: VARCHAR(255),
duration: FLOAT DEFAULT 0,
play_count: INT DEFAULT 0,
release_date: DATE DEFAULT NOW(),
upload_date: TIMESTAMP DEFAULT NOW(),
approved: BOOLEAN DEFAULT TRUE
)Albums Table
albums (
id: SERIAL PRIMARY KEY,
title: VARCHAR(255) NOT NULL,
artist_id: INT REFERENCES users(id) ON DELETE CASCADE,
cover_image: VARCHAR(255),
release_date: DATE,
created_at: TIMESTAMP DEFAULT NOW(),
updated_at: TIMESTAMP DEFAULT NOW()
)Playlists & Playlist_Songs (M:N)
playlists (
id: SERIAL PRIMARY KEY,
name: VARCHAR(255) NOT NULL,
user_id: INT REFERENCES users(id) ON DELETE CASCADE,
cover_image: VARCHAR(255),
is_public: BOOLEAN DEFAULT TRUE,
created_at: TIMESTAMP DEFAULT NOW()
)
playlist_songs (
id: SERIAL PRIMARY KEY,
playlist_id: INT REFERENCES playlists(id) ON DELETE CASCADE,
song_id: INT REFERENCES songs(id) ON DELETE CASCADE,
added_at: TIMESTAMP DEFAULT NOW(),
order: INT DEFAULT 0,
UNIQUE(playlist_id, song_id)
)Favorites (Polymorphic)
favorites (
id: SERIAL PRIMARY KEY,
user_id: INT REFERENCES users(id) ON DELETE CASCADE,
item_type: VARCHAR(20) CHECK(item_type IN ('song', 'album', 'playlist')),
item_id: INT NOT NULL,
created_at: TIMESTAMP DEFAULT NOW(),
UNIQUE(user_id, item_type, item_id)
)Listening History
listening_history (
id: SERIAL PRIMARY KEY,
user_id: INT REFERENCES users(id) ON DELETE CASCADE,
song_id: INT REFERENCES songs(id) ON DELETE CASCADE,
listened_at: TIMESTAMP DEFAULT NOW()
)AI Integration Tables
ai_prompts (
id: SERIAL PRIMARY KEY,
user_id: INT REFERENCES users(id) ON DELETE CASCADE,
prompt_text: TEXT NOT NULL,
response_text: TEXT,
generated_sql: TEXT,
executed_result: TEXT,
created_at: TIMESTAMP DEFAULT NOW()
)
ai_interactions (
id: SERIAL PRIMARY KEY,
user_id: INT REFERENCES users(id) ON DELETE CASCADE,
prompt_id: INT REFERENCES ai_prompts(id) ON DELETE CASCADE,
message_type: VARCHAR(10) CHECK(message_type IN ('user', 'ai')),
message_text: TEXT NOT NULL,
timestamp: TIMESTAMP DEFAULT NOW()
)- User β Songs: One-to-Many (An artist can have many songs)
- User β Albums: One-to-Many (An artist can have many albums)
- User β Playlists: One-to-Many (A user can have many playlists)
- Album β Songs: One-to-Many (An album contains many songs)
- Genre β Songs: One-to-Many (A genre can classify many songs)
- Playlist β Songs: Many-to-Many (through playlist_songs)
- User β Favorites: One-to-Many (Polymorphic relationship)
- User β Listening History: One-to-Many
-- Unique constraints
CREATE UNIQUE INDEX idx_users_username ON users(username);
CREATE UNIQUE INDEX idx_users_email ON users(email);
CREATE UNIQUE INDEX idx_playlist_songs ON playlist_songs(playlist_id, song_id);
-- Performance indexes
CREATE INDEX idx_songs_artist ON songs(artist_id);
CREATE INDEX idx_songs_album ON songs(album_id);
CREATE INDEX idx_songs_genre ON songs(genre_id);
CREATE INDEX idx_songs_playcount ON songs(play_count DESC);
CREATE INDEX idx_listening_history_user ON listening_history(user_id);
CREATE INDEX idx_listening_history_song ON listening_history(song_id);
CREATE INDEX idx_listening_history_date ON listening_history(listened_at DESC);HarmonyDB features MeloAI, an intelligent assistant that translates natural language queries into SQL and executes them safely.
User Input (Natural Language)
β
Intent Classification & Entity Extraction
β
SQL Query Generation
β
Query Validation & Safety Check
β
Database Execution
β
Result Formatting & Response
| Category | Examples | SQL Concepts |
|---|---|---|
| Basic Search | "Songs by The Weeknd" | SELECT, WHERE, LIKE |
| Aggregations | "How many songs in Rock genre?" | COUNT, AVG, SUM |
| Sorting & Limiting | "Top 10 most played songs" | ORDER BY, LIMIT |
| Date Filtering | "Songs from last 30 days" | Date functions, BETWEEN |
| Joins | "All songs with their albums" | INNER JOIN, LEFT JOIN |
| Subqueries | "Album with most songs" | Scalar subquery, EXISTS |
| Window Functions | "Rank songs by play count" | ROW_NUMBER, RANK |
| Group By | "Total songs by each artist" | GROUP BY, HAVING |
| User Queries | "My favorite songs" | User-specific filtering |
| Text Search | "Songs containing 'love'" | ILIKE, pattern matching |
# Natural Language β SQL Examples
"Show me all songs by The Weeknd"
β SELECT * FROM songs WHERE artist.stage_name ILIKE '%The Weeknd%' OR artist.username ILIKE '%The Weeknd%'
"How many songs are in the Rock genre?"
β SELECT COUNT(*) FROM songs WHERE genre.name ILIKE '%Rock%'
"Top 5 most played songs"
β SELECT * FROM songs ORDER BY play_count DESC LIMIT 5
"Songs uploaded in the last 30 days"
β SELECT * FROM songs WHERE upload_date >= NOW() - INTERVAL '30 days'
"Show all my favorite songs"
β SELECT songs.* FROM songs JOIN favorites ON songs.id = favorites.item_id
WHERE favorites.user_id = ? AND favorites.item_type = 'song'class GroqAIService:
"""
Processes natural language queries using Groq's LLM API
"""
def process_music_query(user_query: str) -> dict:
# 1. Create structured prompt with DBMS concepts
# 2. Call Groq API (llama-3.3-70b-versatile)
# 3. Parse JSON response
# 4. Generate SQL query
# 5. Return structured data
class MusicQueryProcessor:
"""
Executes structured queries against the database
"""
def execute_query(ai_response: dict, user) -> dict:
# 1. Validate intent and entities
# 2. Build Django ORM query
# 3. Execute with proper joins
# 4. Format results
# 5. Return JSON response- SQL Injection Prevention: All queries use parameterized statements
- Permission Checking: User-specific queries respect authentication
- Query Timeout: Automatic timeout for long-running queries
- Result Limiting: Maximum result set size to prevent memory issues
- Audit Logging: All AI queries logged in
ai_promptstable
Before you begin, ensure you have the following installed:
- Python: 3.10 or higher
- Node.js: 18.x or higher
- PostgreSQL: 14.x or higher
- npm or yarn: Latest version
- Git: For version control
git clone https://github.com/Rockstatata/HarmonyDB.git
cd HarmonyDBCreate and activate a virtual environment:
cd harmonydb-backend
python3 -m venv venv
# On Linux/Mac
source venv/bin/activate
# On Windows
venv\Scripts\activateInstall Python dependencies:
pip install --upgrade pip
pip install -r requirements.txtCreate a .env file in harmonydb-backend/:
# Database Configuration
DB_NAME=harmonydb
DB_USER=postgres
DB_PASSWORD=your_secure_password
DB_HOST=localhost
DB_PORT=5432
# Django Secret Key (Generate a new one for production!)
SECRET_KEY=your-secret-key-here-change-in-production
# Email Configuration (for password reset)
EMAIL_HOST_USER=your-email@gmail.com
EMAIL_HOST_PASSWORD=your-app-specific-password
DEFAULT_FROM_EMAIL=your-email@gmail.com
# Frontend URL
FRONTEND_BASE_URL=http://localhost:5173
BACKEND_BASE_URL=http://localhost:8000
# Groq API Key (for AI features)
GROQ_API_KEY=your-groq-api-key-hereSet up PostgreSQL database:
# Login to PostgreSQL
sudo -u postgres psql
# Create database and user
CREATE DATABASE harmonydb;
CREATE USER harmonyuser WITH PASSWORD 'your_secure_password';
GRANT ALL PRIVILEGES ON DATABASE harmonydb TO harmonyuser;
ALTER USER harmonyuser CREATEDB; # For running tests
\qUpdate harmonydb/settings.py with your database credentials:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'harmonydb',
'USER': 'harmonyuser',
'PASSWORD': 'your_secure_password',
'HOST': 'localhost',
'PORT': '5432',
}
}Run migrations:
python manage.py makemigrations
python manage.py migrateCreate a superuser:
python manage.py createsuperuser
# Follow the prompts to create an admin accountLoad sample data (optional):
python manage.py loaddata fixtures/sample_data.jsonStart the Django development server:
python manage.py runserver
# Backend will be available at http://localhost:8000Open a new terminal and navigate to frontend:
cd harmonydb-frontendInstall Node.js dependencies:
npm install
# or
yarn installCreate a .env file in harmonydb-frontend/:
VITE_API_BASE_URL=http://localhost:8000/apiStart the Vite development server:
npm run dev
# or
yarn dev
# Frontend will be available at http://localhost:5173- Frontend: http://localhost:5173
- Backend API: http://localhost:8000/api
- Django Admin: http://localhost:8000/admin
- Register a new account as either a Listener or Artist
- Verify your email (check console logs in development)
- Login with your credentials
- As a Listener: Browse songs, create playlists, try MeloAI
- As an Artist: Upload songs, create albums, view analytics
HarmonyDB/
β
βββ harmonydb-backend/ # Django Backend
β βββ manage.py # Django management script
β βββ requirements.txt # Python dependencies
β βββ schema.sql # Database schema documentation
β β
β βββ harmonydb/ # Main Django project
β β βββ __init__.py
β β βββ settings.py # Django settings & configuration
β β βββ urls.py # Root URL configuration
β β βββ wsgi.py # WSGI entry point
β β βββ asgi.py # ASGI entry point
β β βββ middleware.py # Custom middleware (SQL Debug)
β β
β βββ users/ # User management app
β β βββ models.py # User model with roles
β β βββ views.py # Authentication views
β β βββ serializers.py # User serializers
β β βββ permissions.py # Custom permissions
β β βββ tokens.py # JWT token handling
β β βββ emails.py # Email verification
β β βββ urls.py # User routes
β β
β βββ songs/ # Music management app
β β βββ models.py # Song, Album, Playlist models
β β βββ views.py # CRUD operations & streaming
β β βββ serializers.py # API serializers
β β βββ analytics.py # Analytics & trending
β β βββ urls.py # Song routes
β β βββ urls_albums.py # Album routes
β β βββ urls_playlists.py # Playlist routes
β β βββ urls_analytics.py # Analytics routes
β β
β βββ meloai/ # AI assistant app
β β βββ models.py # AI interaction models
β β βββ views.py # AI query endpoints
β β βββ services.py # Groq API integration
β β βββ urls.py # AI routes
β β
β βββ media/ # User-uploaded files
β β βββ songs/ # Audio files
β β βββ song_covers/ # Song cover images
β β βββ album_covers/ # Album artwork
β β βββ playlist_covers/ # Playlist covers
β β βββ profile_pictures/ # User avatars
β β
β βββ templates/ # Email templates
β βββ admin/ # Custom admin templates
β
βββ harmonydb-frontend/ # React Frontend
β βββ package.json # Node dependencies
β βββ tsconfig.json # TypeScript configuration
β βββ vite.config.ts # Vite build configuration
β βββ tailwind.config.js # Tailwind CSS configuration
β βββ eslint.config.js # ESLint configuration
β βββ index.html # HTML entry point
β β
β βββ src/
β β βββ main.tsx # React entry point
β β βββ App.tsx # Root component
β β βββ index.css # Global styles
β β β
β β βββ components/ # Reusable components
β β β βββ MediaCard.tsx # Song/Album card
β β β βββ SQLTerminal.tsx # SQL debug terminal
β β β βββ Home/ # Home page components
β β β βββ Intro/ # Landing page components
β β β βββ ui/ # UI primitives
β β β
β β βββ context/ # React Context providers
β β β βββ authContext.tsx # Authentication state
β β β βββ playerContext.tsx # Music player state
β β β βββ sqlDebugContext.tsx # SQL debug state
β β β βββ useSQLDebug.ts # SQL debug hook
β β β
β β βββ pages/ # Page components
β β β βββ auth/ # Login/Register pages
β β β βββ home/ # Main application pages
β β β βββ Intro/ # Landing pages
β β β
β β βββ routes/ # Routing configuration
β β β βββ AllRoutes.tsx # Route definitions
β β β βββ ProtectedRoutes.tsx # Auth guards
β β β
β β βββ services/ # API services
β β β βββ apiServices.ts # HTTP client & endpoints
β β β
β β βββ types/ # TypeScript types
β β β βββ index.ts # Global type definitions
β β β
β β βββ utils/ # Utility functions
β β
β βββ public/ # Static assets
β
βββ screenshots/ # Application screenshots (30+)
β
βββ README.md # This file
Backend:
settings.py: Django configuration, database setup, middleware, CORSmiddleware.py: Custom middleware for SQL query debuggingservices.py(meloai): AI integration with Groq API, query processingmodels.py(songs): Database models for music entitiesviews.py(songs): API endpoints with advanced SQL demonstrations
Frontend:
App.tsx: Root component with provider setupapiServices.ts: Centralized API client with JWT handlingauthContext.tsx: Authentication state managementplayerContext.tsx: Music player state and controlssqlDebugContext.tsx: Real-time SQL query monitoringAllRoutes.tsx: Application routing configuration
POST /api/auth/register/
Content-Type: application/json
{
"username": "johndoe",
"email": "john@example.com",
"password": "SecurePass123!",
"confirm_password": "SecurePass123!",
"role": "listener" // or "artist"
}POST /api/auth/login/
Content-Type: application/json
{
"username": "johndoe",
"password": "SecurePass123!"
}
Response:
{
"access": "eyJ0eXAiOiJKV1QiLCJhbGc...",
"refresh": "eyJ0eXAiOiJKV1QiLCJhbGc...",
"user": {
"id": 1,
"username": "johndoe",
"email": "john@example.com",
"role": "listener"
}
}POST /api/auth/token/refresh/
Content-Type: application/json
{
"refresh": "eyJ0eXAiOiJKV1QiLCJhbGc..."
}GET /api/songs/?search=weeknd&min_duration=180&max_duration=300
Authorization: Bearer <access_token>
Response includes SQL debug info in headers:
X-SQL-Debug-Count: 3
X-SQL-Debug-Time: 0.045POST /api/songs/
Authorization: Bearer <access_token>
Content-Type: multipart/form-data
FormData:
- title: "Blinding Lights"
- audio_file: <file>
- cover_image: <file>
- album: 5
- genre: 2
- duration: 200.5GET /api/songs/stream/<song_id>/
Authorization: Bearer <access_token>
Response: Audio file streamPOST /api/meloai/query/
Authorization: Bearer <access_token>
Content-Type: application/json
{
"query": "Show me all songs by The Weeknd from the last 30 days"
}
Response:
{
"prompt_id": 123,
"query": "Show me all songs by The Weeknd...",
"intent": "search_songs",
"entities": {
"artist_name": "The Weeknd",
"date_range": "last_30_days"
},
"ai_response": "I'll search for songs by The Weeknd...",
"result_type": "songs",
"results": [...],
"count": 5,
"sql_query": "SELECT * FROM songs_song WHERE...",
"success": true
}HarmonyDB showcases real-world implementations of advanced database concepts:
# Rank songs by play count within each genre
Song.objects.annotate(
genre_rank=Window(
expression=Rank(),
partition_by=[F('genre')],
order_by=F('play_count').desc()
)
)
# SQL Generated:
# SELECT *,
# RANK() OVER (PARTITION BY genre_id ORDER BY play_count DESC) as genre_rank
# FROM songs_song# Find albums with more than 10 songs
Album.objects.annotate(
song_count=Subquery(
Song.objects.filter(album=OuterRef('pk'))
.values('album')
.annotate(count=Count('id'))
.values('count')
)
).filter(song_count__gt=10)
# SQL Generated:
# SELECT * FROM songs_album
# WHERE (SELECT COUNT(*) FROM songs_song
# WHERE songs_song.album_id = songs_album.id) > 10# Total play count by genre
Genre.objects.annotate(
total_plays=Sum('song__play_count'),
avg_duration=Avg('song__duration'),
song_count=Count('song')
).order_by('-total_plays')
# SQL Generated:
# SELECT genre_id,
# SUM(play_count) as total_plays,
# AVG(duration) as avg_duration,
# COUNT(*) as song_count
# FROM songs_song
# GROUP BY genre_id
# ORDER BY total_plays DESC# Songs with artist and album info (LEFT JOINs)
Song.objects.select_related('artist', 'album', 'genre')\
.prefetch_related('listening_history', 'in_playlists')
# SQL Generated (simplified):
# SELECT s.*, a.*, al.*, g.*
# FROM songs_song s
# INNER JOIN users_user a ON s.artist_id = a.id
# LEFT OUTER JOIN songs_album al ON s.album_id = al.id
# LEFT OUTER JOIN songs_genre g ON s.genre_id = g.id# Trending songs: recent plays with exponential decay
from django.utils import timezone
from datetime import timedelta
now = timezone.now()
week_ago = now - timedelta(days=7)
Song.objects.annotate(
recent_plays=Count(
'listening_history',
filter=Q(listening_history__listened_at__gte=week_ago)
),
trending_score=F('recent_plays') * 10 + F('play_count') / 100
).order_by('-trending_score')
# SQL Generated:
# SELECT *,
# COUNT(CASE WHEN listened_at >= '2024-10-22' THEN 1 END) as recent_plays,
# (recent_plays * 10 + play_count / 100) as trending_score
# FROM songs_song
# ORDER BY trending_score DESC# Categorize songs by popularity
Song.objects.annotate(
popularity_tier=Case(
When(play_count__gte=1000, then=Value('viral')),
When(play_count__gte=100, then=Value('popular')),
When(play_count__gte=10, then=Value('rising')),
default=Value('new'),
output_field=CharField()
)
)
# SQL Generated:
# SELECT *,
# CASE
# WHEN play_count >= 1000 THEN 'viral'
# WHEN play_count >= 100 THEN 'popular'
# WHEN play_count >= 10 THEN 'rising'
# ELSE 'new'
# END as popularity_tier
# FROM songs_song![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
|
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
- Database Systems Course: Comprehensive demonstration of DBMS concepts
- Web Development: Full-stack architecture with modern frameworks
- API Design: RESTful API best practices
- SQL Learning: Real-world SQL query examples
- AI Integration: Practical LLM application
- Portfolio Project: Showcase full-stack capabilities
- Learning Resource: Study modern React + Django integration
- Architecture Reference: Clean, scalable codebase structure
- API Template: JWT authentication patterns
- Real-time Features: SQL debugging implementation
- Personal Music Library: Organize your music collection
- Playlist Management: Create and share playlists
- Discovery: Explore new artists and genres
- Analytics: Track listening habits
Contributions are welcome! Whether it's bug fixes, new features, or documentation improvements, your help makes HarmonyDB better.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes - Follow existing code style and add comments
- Test your changes - Ensure everything works properly
- Commit your changes (
git commit -m "Add some amazing feature") - Push to your fork (
git push origin feature/amazing-feature) - Open a Pull Request - Describe your changes and reference any related issues
- Code Style: Follow PEP 8 for Python, ESLint for TypeScript
- Commits: Use descriptive commit messages
- Documentation: Update README for new features
- Testing: Add tests for new functionality
- Security: Never commit sensitive data (.env files)
This project is licensed under the MIT License. You are free to use, modify, and distribute this software.
- Course: Database Systems Laboratory (CSE-3110)
- Institution: Khulna University of Engineering & Technology (KUET)
- Academic Year: 2024-2025
- Django & Django REST Framework - Backend framework
- React & TypeScript - Frontend framework
- PostgreSQL - Database system
- Groq API - LLM integration
- Tailwind CSS - Styling framework
- Framer Motion - Animation library
- Vite - Build tool
- Spotify - UI/UX inspiration
- YouTube Music - Feature ideas
- Database Management Systems by Raghu Ramakrishnan - Theoretical foundation
- Django for APIs by William S. Vincent - API design patterns
- Stack Overflow community for debugging help
- Django & React documentation teams
- Open-source contributors worldwide
Sarwad Hasan Siddiqui
- GitHub: @Rockstatata
- Course: Database Systems Laboratory (CSE-3110, KUET)
- Repository: https://github.com/Rockstatata/HarmonyDB
- Issues: Report a Bug
If you find this project helpful, consider:
- β Starring the repository
- π Reporting bugs and issues
- π‘ Suggesting new features
- π Improving documentation
- π€ Contributing code
π Total Files: 150+
π Lines of Code: 25,000+
ποΈ Database Tables: 13
π API Endpoints: 40+
πΈ Screenshots: 30+
β±οΈ Development Time: 200+ hours
π Concepts Covered: 30+ DBMS concepts























