A full-stack face-driven music player that detects your emotional state through facial expressions and recommends songs that match your mood in real-time.
- Real-Time Mood Detection: Uses MediaPipe Vision to analyze facial expressions and determine emotional state
- User Authentication: Secure sign up and login system with JWT-based authentication
- Profile Management: View username in navbar with quick logout functionality
- Song Upload: Upload MP3 files with mood categorization (Happy, Sad, Surprised)
- Smart Music Player: Manual playback control with full player features (play/pause, seek, volume, speed control)
- Mood-Based Recommendations: Get song suggestions based on your real-time emotional state
- Protected Routes: Secure pages that require authentication
- Redis Caching: Improved performance with Redis-based caching
- Responsive Design: Works seamlessly on desktop and mobile devices
- Runtime: Node.js
- Framework: Express.js
- Database: MongoDB (with Mongoose ODM)
- Caching: Redis (ioredis)
- Authentication: JWT + bcryptjs
- File Upload: ImageKit + Multer
- Metadata Processing: node-id3
- Framework: React 19
- Build Tool: Vite
- Styling: Sass/SCSS
- Routing: React Router v7
- HTTP Client: Axios
- Face Detection: MediaPipe Tasks Vision
- State Management: React Context API
- Form Handling: Two-way data binding with controlled components
- Linting: ESLint
Vizo/
โโโ backend/ # Node.js/Express server
โ โโโ src/
โ โ โโโ app.js # Express app configuration
โ โ โโโ config/ # Database & cache configs
โ โ โโโ controllers/ # Route controllers
โ โ โโโ middlewares/ # Custom middlewares
โ โ โโโ models/ # MongoDB models
โ โ โโโ routes/ # API routes
โ โ โโโ services/ # Business logic & utilities
โ โโโ public/ # Static files
โ โโโ server.js # Server entry point
โ โโโ package.json
โ
โโโ frontend/ # React + Vite application
โโโ src/
โ โโโ โ โโโ components/ # Auth components
โ โ โ โโโ hooks/ # useAuth, useUpload hooks
โ โ โ โโโ pages/ # Login, Register, SongUpload
โ โ โ โโโ services/ # API services
โ โ โ โโโ styles/ # Auth & upload styles
โ โ โ โโโ auth.context.jsx # Auth context
โ โ โ โโโ upload.context.jsx # Upload context
โ โ โโโ Home/ # Home & song features
โ โ โ โโโ components/ # Player component
โ โ โ โโโ hooks/ # useSong hook
โ โ โ โโโ song.context.jsx
โ โ โโโ faceExpressions/ # Facial recognition
โ โ โ โโโ components/ # ExpressionTrack, Navbar
โ โ โ โโโ styles/ # Navbar styles
โ โ โ โโโ utils/ # Face detection utils
โ โ โโโ shared/ # Shared styles
โ โโโ components/ # Shared components (Navbar)eatures
โ โ โโโ faceExpressions/ # Facial recognition
โ โ โโโ shared/ # Shared styles
โ โโโ App.jsx # Main app component
โ โโโ AppRoute.jsx # Route definitions
โ โโโ main.jsx # React entry point
โโโ index.html
โโโ vite.config.js
โโโ package.json
- Node.js (v14 or higher)
- npm or yarn
- MongoDB instance (local or cloud)
- Redis instance (optional, for caching)
- Navigate to the backend directory:
cd backend- Install dependencies:
npm install- Create a
.envfile in the backend directory with the following variables:
PORT=3000
MONGODB_URI=mongodb://localhost:27017/vizo
REDIS_URL=redis://localhost:6379
JWT_SECRET=your_secret_key_here
IMAGEKIT_PUBLIC_KEY=your_imagekit_public_key
IMAGEKIT_PRIVATE_KEY=your_imagekit_private_key
IMAGEKIT_URL_ENDPOINT=your_imagekit_url_endpoint
- Start the backend server:
npm run devThe backend will run on http://localhost:3000
- Navigate to the frontend directory:
cd frontend- Install dependencies:
npm install- Start the development server:
npm run devThe frontend will run on http://localhost:5173
npm run dev- Start development server with hot reload (nodemon)npm test- Run test suite GET /logout` - Logout userGET /get-me- Get current user profile
GET /- Get songs (optionally filtered by mood)POST /upload-song- Upload a new song (MP3 file with mood)- Query params:
mood(happy|sad|surprised),limit(default: 1)
POST /register- Register a new userPOST /login- Login userPOST /logout- Logout userGET /profile- Get current user profile
GET /- Get all songsPOST /upload- Upload a new songGET /:id- Get song detailsDELETE /:id- Delete a songGET /mood/:emotion- Get songs for specific mood
The application uses Google's MediaPipe Vision library to analyze facial expressions in real-time:
- Detects emotional states (happy, sad, angry, neutral, etc.)
- Processes video frames from your webcam
- Recommends songs that match your curresurprised)
- Processes video frames from your webcam
- Real-time camera indicator in navbar
- Recommends songs that match your current mood
Secure user authentication with:
- Password hashing using bcryptjs
- JWT tokens for session management
- Cookie-based token storage
- Protected routes requiring authentication
- User profile display with username in navbar
- One-click logout functionality
Upload songs with comprehensive features:
- File Upload: Drag & drop or click to browse MP3 files
- File Validation:
- Only MP3 files accepted
- Maximum file size: 10MB
- Real-time file size display
- Mood Categorization: Select from Happy ๐, Sad ๐ข, or Surprised ๐ฎ
- Metadata Extraction: Automatic extraction of ID3 tags (title, artist, album art)
- Cloud Storage: Files stored securely using ImageKit CDN
- Two-way Data Binding: Real-time form updates with React state
Full-featured music player with: username, email, and password 2. Login: Access your account with email and password 3. Home Page:
- Enable webcam for facial expression detection
- Click "Detect Face Expression" to analyze your mood
- See your current mood displayed in real-time
- Upload Songs:
- Click "Upload Song" in the navbar
- Drag & drop or browse for an MP3 file (max 10MB)
- Select the mood category
- Click "Upload Song"
- Music Player:
- Songs load based on detected mood
- Click play button to start music (no autoplay)
- Use controls for volume, speed, seek, and navigation
- Profile Management:
- View your username in the navbar
- Click "Logout" to end your session
- Album Art Display: Show song poster/cover image
Create a .env file in the backend directory with:
PORT=3000
MONGODB_URI=your_mongodb_connection_string
REDIS_URL=your_redis_connection_string
JWT_SECRET=your_jwt_secret_key
JWT_EXPIRE=7d
IMAGEKIT_PUBLIC_KEY=your_imagekit_key
IMAGEKIT_PRIVATE_KEY=your_imagekit_private_key
IMAGEKIT_URL_ENDPOINT=your_imagekit_endpoint
Project Highlights ๐
- Context API Architecture: Multiple context providers (Auth, Upload, Song) for state management
- Custom Hooks: Reusable hooks (useAuth, useUpload, useSong) for clean component logic
- Protected Routes: Automatic redirection for unauthenticated users
- Responsive Design: Mobile-first approach with SCSS mixins
- Error Handling: Comprehensive error messages and validation
- Loading States: Visual feedback during async operations
- File Validation: Client-side validation before upload
- Two-Way Binding: Controlled form components with React state
- Sign Up: Create a new account with email and password
- Login: Access your account
- Upload Songs: Add songs to your library
- Enable Webcam: Allow the app to access your camera
- View Mood: See real-time facial expression analysis
- Get Recommendations: Receive song suggestions based on your mood
- Play Music: Enjoy personalized music from your library
- Chrome/Chromium (v90+)
- Firefox (v88+)
- Safari (v14open an issue on GitHub.
- โ Disabled autoplay - songs only play when user clicks play button
- โ Added logout button to navbar with styled design
- โ Added username display in navbar
- โ Created comprehensive song upload form with file validation
- โ Implemented two-way data binding for all form inputs
- โ Added mood selection dropdown (Happy, Sad, Surprised)
- โ Integrated upload context and custom hooks
- โ Added real-time file size display
- โ Implemented drag & drop file upload interface
- โ Added success/error message handling
- Edge (v90+)
Note: Facial expression detection requires camera access and works best on desktop browsers.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the ISC License - see the LICENSE file for details.
- MediaPipe for facial expression detection
- ImageKit for image and file hosting
- MongoDB for database
- Redis for caching
For support, email ritik30@gmail.com or open an issue on GitHub.
Made with โค๏ธ as part of the What's Matter Series