music-and-you

Music & You

A full-stack web application that predicts Big Five personality traits from Spotify and YouTube Music listening patterns using advanced machine learning and music psychology research.

Table of Contents

Overview

What if your playlist could reveal your personality?

Music & You was born from a simple observation: as a Computer Engineering student who listens to everything from Tina Turner to André Rieu’s classical performances, from Ghanaian Hilife to Lewis Capaldi, I noticed that my musical diversity was unusual among my Gen Z peers. This led to a fascinating question: Is there a connection between the songs we choose and who we are?

Unlike static reports like Spotify Wrapped, Music & You provides real-time personality analysis that explores the deeper psychological patterns in your listening habits. The platform combines music psychology research with modern machine learning to offer educational insights into how your musical choices reflect your Big Five personality traits.

The application analyzes users’ music listening patterns to predict personality traits (Openness, Conscientiousness, Extraversion, Agreeableness, and Neuroticism) while being transparent about limitations and respectful of cultural musical diversity.

Features

Core Functionality

Advanced Features

Technical Features

Screenshots

Dashboard and Chat Interface Conversational AI explaining personality insights after Authentication

Analysis Overview Musical personality overview

Musical Personality Analysis Musical personality traits and analysis results

Technology Stack

Backend

Frontend

Infrastructure

Architecture

music-and-you/
├── src/music_and_you/           # Python backend
│   ├── api/                     # FastAPI application
│   │   └── main.py             # API server with endpoints
│   ├── data/                    # Data collection modules
│   │   └── spotify_client.py   # Spotify API integration
│   ├── features/                # Feature engineering
│   │   ├── feature_pipeline.py # Main feature extraction
│   │   ├── temporal_features.py# Time-based analysis
│   │   └── lyrical_features.py # Lyrical content analysis
│   ├── models/                  # ML models
│   │   └── personality_predictor.py # Prediction algorithms
│   └── utils/                   # Utility functions
├── frontend/                    # Next.js frontend
│   ├── src/
│   │   ├── app/                # App router pages
│   │   │   ├── page.tsx        # Landing page
│   │   │   ├── analyze/        # Analysis results
│   │   │   ├── data/           # Music data visualization
│   │   │   └── auth/           # Authentication
│   │   ├── components/         # React components
│   │   │   ├── ChatWidget.tsx  # Conversational interface
│   │   │   ├── PersonalityRadarChart.tsx
│   │   │   └── AudioDNAChart.tsx
│   │   └── lib/                # Utilities and hooks
├── tests/                       # Test suites
├── docs/                        # Documentation
└── docker/                     # Docker configuration

🚀 Quick Start (GitHub Pages Demo)

Try the live demo: https://tmarhguy.github.io/music-and-you

The GitHub Pages version runs in demo mode with sample data to showcase the full functionality without requiring Spotify authentication.

🛠 Development Setup

Prerequisites

Environment Setup

  1. Create a Spotify App:
    • Go to Spotify Developer Dashboard
    • Create a new app
    • Note your Client ID and Client Secret
    • Add redirect URI: http://localhost:3000/auth/callback

📦 Installation

Frontend Setup (GitHub Pages Compatible)

  1. Clone the repository:

    git clone https://github.com/tmarhguy/music-and-you.git
    cd music-and-you
    
  2. Install and run frontend:

    cd frontend
    npm install
    npm run dev
    
  3. Build for GitHub Pages:

    npm run build
    

The frontend will be available at http://localhost:3000

Backend Setup (Separate Repository)

For the full application with real Spotify integration, you’ll need the backend API:

  1. Clone the backend repository:

    git clone https://github.com/tmarhguy/music-and-you-backend.git
    cd music-and-you-backend
    
  2. Follow the backend setup instructions in the backend repository

  3. Configure environment variables:

    cp env.example .env
    # Edit .env with your Spotify credentials
    
  4. Start the backend server:

    uvicorn src.music_and_you.api.main:app --reload --port 8000
    

The application will be available at:

Usage

Basic Workflow

  1. Authentication: Connect your Spotify account through OAuth2
  2. Data Collection: The system automatically fetches your music data
  3. Analysis: Machine learning models process your listening patterns
  4. Results: View your personality insights through interactive dashboard
  5. Exploration: Use the chat interface to understand your results
  6. Discovery: Get personalized music recommendations

API Endpoints

Authentication

GET /auth/login          # Initiate Spotify OAuth
GET /auth/callback       # Handle OAuth callback

Data Collection

POST /analyze           # Start personality analysis
GET /analysis/{id}      # Get analysis results

Chat Interface

POST /chat              # Send message to AI assistant

Example Usage

import requests

# Start analysis
response = requests.post('http://localhost:8003/analyze',
                        headers={'Authorization': 'Bearer YOUR_TOKEN'})

# Get results
analysis_id = response.json()['analysis_id']
results = requests.get(f'http://localhost:8003/analysis/{analysis_id}')

API Documentation

Comprehensive API documentation is available at /docs when running the backend server. The documentation includes:

Contributing

We welcome contributions! Please see our Contributing Guidelines for details.

Documentation

For detailed documentation, please visit the docs/ directory:

Development Setup

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature-name
  3. Make your changes
  4. Add tests for new functionality
  5. Ensure all tests pass: npm test and pytest
  6. Submit a pull request

Code Style

Research Foundation

3. Personality Analysis

4. Data Visualization

🏗 Project Architecture

music-and-you/
├── src/music_and_you/           # Python backend
│   ├── api/                     # FastAPI application
│   │   └── simple_main.py       # Main API server with all endpoints
│   ├── data/                    # Data collection
│   │   └── spotify_client.py    # Spotify API integration
│   ├── features/                # Feature engineering
│   │   ├── feature_pipeline.py  # Main feature extraction pipeline
│   │   ├── temporal_features.py # Time-based analysis
│   │   └── lyrical_features.py  # Lyrical content analysis
│   └── models/                  # ML models and analysis
│       └── personality_predictor.py # Personality prediction algorithms
├── frontend/                    # Next.js frontend
│   ├── src/app/                 # App router pages
│   │   ├── page.tsx            # Main dashboard
│   │   ├── analyze/            # Personality analysis page
│   │   ├── data/               # Music data visualization
│   │   └── auth/               # Authentication handling
│   └── [configuration files]
└── [project configuration]

This project emerged from personal curiosity about musical diversity and psychological patterns, built on validated research in music psychology:

Foundation Research:

Personal Motivation: As someone who rotates between Tina Turner, André Rieu, Afrobeats, and Hilife in a single listening session, I wanted to understand whether musical diversity itself might be a personality indicator. This project explores both established research and new questions about cultural musical preferences.

Technical Implementation: The personality prediction models use 35+ engineered features across multiple dimensions:

License

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


Music & You - Transforming self-discovery through music psychology and AI.

🚀 Getting Started

Prerequisites

Installation

  1. Clone the repository
git clone https://github.com/tmarhguy/music-and-you.git
cd music-and-you
  1. Set up Python environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -r requirements.txt
  1. Set up frontend
cd frontend
npm install
  1. Configure environment
# Copy example environment file
cp .env.example .env
# Add your Spotify credentials to .env
  1. Start the application
# Terminal 1: Start backend
source venv/bin/activate
uvicorn src.music_and_you.api.simple_main:app --reload --port 8000

# Terminal 2: Start frontend
cd frontend
npm run dev -- --port 3001
  1. Access the application

📊 API Endpoints

Authentication

User Data

Analysis

🎨 User Interface

Dashboard

Personality Analysis Page

Data Visualization

🔒 Security & Privacy

🎯 Success Metrics Achieved

📈 Future Enhancements

🤝 Contributing

This project represents a complete implementation of music-based personality analysis. The codebase is well-structured and documented for future enhancements and research applications.

📝 License

This project is for research and educational purposes. Please respect Spotify’s API terms of service and user privacy.


🎵 Discover your musical personality today! Connect your Spotify account and unlock insights about yourself through the music you love.

See RESEARCH_FOUNDATION.md for the complete research background and theoretical framework.

Planned Extensions

Ethical Considerations

Getting Started

[Development in progress]

License

[To be determined]

Citation

[Research paper in preparation]


Note: This is an active research project exploring the intersection of musical diversity and personality psychology. The codebase and methodological approaches continue to evolve as we validate findings about cross-cultural musical preferences and psychological patterns.