Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

38 Commits
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

VIZO ๐ŸŽต

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.

Features โœจ

  • 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

Tech Stack ๐Ÿ› ๏ธ

Backend

  • 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

Frontend

  • 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

Project Structure ๐Ÿ“

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

Getting Started ๐Ÿš€

Prerequisites

  • Node.js (v14 or higher)
  • npm or yarn
  • MongoDB instance (local or cloud)
  • Redis instance (optional, for caching)

Backend Setup

  1. Navigate to the backend directory:
cd backend
  1. Install dependencies:
npm install
  1. Create a .env file 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
  1. Start the backend server:
npm run dev

The backend will run on http://localhost:3000

Frontend Setup

  1. Navigate to the frontend directory:
cd frontend
  1. Install dependencies:
npm install
  1. Start the development server:
npm run dev

The frontend will run on http://localhost:5173

Available Scripts ๐Ÿ“

Backend

  • npm run dev - Start development server with hot reload (nodemon)
  • npm test - Run test suite GET /logout` - Logout user
  • GET /get-me - Get current user profile

Songs (/api/songs)

  • 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)

Authentication (/api/auth)

  • POST /register - Register a new user
  • POST /login - Login user
  • POST /logout - Logout user
  • GET /profile - Get current user profile

Songs (/api/songs)

  • GET / - Get all songs
  • POST /upload - Upload a new song
  • GET /:id - Get song details
  • DELETE /:id - Delete a song
  • GET /mood/:emotion - Get songs for specific mood

Features in Detail ๐ŸŽฏ

Mood Detection

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

Authentication & User Management

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

Song Upload & Management

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

Music Player

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
  1. 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"
  2. Music Player:
    • Songs load based on detected mood
    • Click play button to start music (no autoplay)
    • Use controls for volume, speed, seek, and navigation
  3. 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

Usage ๐Ÿ’ก

  1. Sign Up: Create a new account with email and password
  2. Login: Access your account
  3. Upload Songs: Add songs to your library
  4. Enable Webcam: Allow the app to access your camera
  5. View Mood: See real-time facial expression analysis
  6. Get Recommendations: Receive song suggestions based on your mood
  7. Play Music: Enjoy personalized music from your library

Browser Compatibility ๐ŸŒ

  • Chrome/Chromium (v90+)
  • Firefox (v88+)
  • Safari (v14open an issue on GitHub.

Recent Updates ๐Ÿ†•

  • โœ… 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.

Contributing ๐Ÿค

Contributions are welcome! Please feel free to submit a Pull Request.

License ๐Ÿ“„

This project is licensed under the ISC License - see the LICENSE file for details.

Acknowledgments ๐Ÿ™

Support ๐Ÿ’ฌ

For support, email ritik30@gmail.com or open an issue on GitHub.


Made with โค๏ธ as part of the What's Matter Series

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages