A full-stack web application that analyzes your emotional state and recommends music based on your current situation and mood.
- Spotify Authentication: Secure OAuth flow with Spotify
- Emotion Analysis: Uses Gemini AI to analyze text and extract sentiment/keywords
- Music Recommendation: Automatically finds and plays music based on your mood
- Real-time Emotion Detection: Webcam-based emotion analysis (backend)
- Modern UI: Beautiful Next.js frontend with Tailwind CSS
- Node.js (v18 or higher)
- Python 3.8+
- Spotify Premium account (for playback control)
- MongoDB database
- Google Gemini API key
Create a .env file in the Backend/ directory:
# Spotify API
CLIENT_ID=your_spotify_client_id
CLIENT_SECRET=your_spotify_client_secret
# Google Gemini API
GEM_API_KEY=your_gemini_api_key
# MongoDB
MONGODB_URI=your_mongodb_connection_string
# Flask
SECRET_KEY=your_secret_key_here-
Navigate to the backend directory:
cd Backend -
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Start the Flask server:
python app.py
The backend will run on http://localhost:5000
-
Navigate to the frontend directory:
cd Frontend -
Install dependencies:
npm install
-
Start the development server:
npm run dev
The frontend will run on http://localhost:3000
- Open your browser and go to
http://localhost:3000 - Click "Log in with Spotify" to authenticate
- Enter your current situation in the text input (e.g., "I just got a promotion", "I'm feeling stressed about work")
- Click "Analyze" to get sentiment and keyword analysis
- Click "Play Music" to start playing music that matches your mood
GET /api/auth/spotify- Get Spotify authorization URLGET /callback- Handle Spotify OAuth callbackGET /api/auth/status- Check authentication status
POST /api/analyze-situation- Analyze text for sentiment and keywordsPOST /api/play-music- Play music based on sentiment and keywordGET /api/current-emotion- Get current emotion from webcam
- Frontend: Next.js 14 with TypeScript and Tailwind CSS
- Backend: Flask with Python
- AI: Google Gemini for text analysis
- Music: Spotify Web API for music playback
- Database: MongoDB for storing track reactions
- Authentication: Spotify OAuth 2.0
- Ensure your Spotify app is properly configured in the Spotify Developer Dashboard
- Add your email as a user in your Spotify app settings
- Make sure you have a Spotify Premium account for playback control
- Check that all environment variables are set correctly
- Ensure MongoDB is running and accessible
- Verify that all Python dependencies are installed
- Make sure both frontend and backend servers are running
- Check browser console for any CORS or network errors
- Ensure you're using the correct ports (3000 for frontend, 5000 for backend)
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is licensed under the MIT License.