A comprehensive web application that analyzes your YouTube Music listening history to provide detailed insights into your music consumption patterns, favorite artists, top songs, and listening behaviors over time. Features a beautiful "Wrapped" experience similar to Spotify Wrapped!
- π Comprehensive Analytics: Get detailed statistics about your listening habits
- π¨ Interactive Dashboard: Beautiful, responsive dashboard with charts and visualizations
- π Top Artists & Songs: Discover your most played artists and tracks
- π Listening Patterns: Analyze your music consumption over time
- π΅ Song Duration Analysis: Get insights into your preferred song lengths
- π Historical Data: Track your music journey with historical listening data
- π Wrapped Experience: Spotify-style animated year-in-review with shareable slides
- πΌ Music Era Analysis: Discover what decade your music taste belongs to
- π Dark/Light Mode: Seamless theme switching
- π± Mobile Responsive: Optimized for all devices
- π Secure Authentication: Email/password and Google OAuth integration
- βοΈ Cloud Storage: Secure data storage with MongoDB
- π File Upload: Easy Google Takeout data import
- Next.js 16: React 19 framework with App Router
- TypeScript: Type-safe development
- Tailwind CSS v4: Utility-first CSS framework
- Shadcn UI: Beautiful UI components
- Motion (Framer Motion): Smooth animations and transitions
- Recharts: Interactive charts and visualizations
- React Three Fiber: 3D graphics and visual effects
- MongoDB: NoSQL database
- Mongoose: MongoDB object modeling
- Better Auth: Modern authentication system
- Biome: Fast linting and formatting
- pnpm: Package manager
- Turbopack: Lightning-fast bundler
- Node.js 18+
- pnpm (recommended) or npm
- MongoDB instance (local or cloud)
- Google OAuth credentials (optional)
-
Clone the repository
git clone https://github.com/vaaibhavmishra/ytmusic-stats.git cd ytmusic-stats -
Install dependencies
pnpm install
-
Set up environment variables
Create a
.env.localfile in the root directory:# Database MONGODB_URI=mongodb://localhost:27017/ytmusic-stats # Authentication BETTER_AUTH_SECRET=your-secret-key-here BETTER_AUTH_URL=http://localhost:3000 # Google OAuth (optional) GOOGLE_CLIENT_ID=your-google-client-id GOOGLE_CLIENT_SECRET=your-google-client-secret
-
Start the development server
pnpm dev
-
Open your browser
Navigate to http://localhost:3000
- Go to Google Takeout
- Select YouTube and YouTube Music
- Choose JSON format
- Download your data archive
- Extract the
watch-history.jsonfile from the YouTube folder
- Sign up or sign in to the application
- Navigate to the Upload page
- Upload your
watch-history.jsonfile - Wait for processing to complete (this may take a few minutes)
Once processing is complete, explore your personalized dashboard featuring:
- Overview Stats: Total songs, artists, playtime, and more
- Top Artists: Your most listened-to artists with play counts
- Top Songs: Your favorite tracks ranked by play frequency
- Listening Patterns: Charts showing your music consumption over time
- Music Era: Discover what decade defines your music taste
- Wrapped Experience: An animated journey through your listening year
The Wrapped feature provides a Spotify-style animated slideshow of your music year:
- Intro Slide: Welcome and overview of your journey
- Listening Time: Total hours spent listening to music
- Top Artist: Your most played artist with stats
- Top Song: Your most played track
- Music Era: What decade your music taste belongs to
- Fun Facts: Interesting insights about your listening habits
- Summary: Shareable summary of your music year
Navigate using arrow keys, click, or let it autoplay!
βββ app/ # Next.js App Router pages
β βββ api/ # API routes
β βββ auth/ # Authentication pages (signin, signup)
β βββ dashboard/ # Dashboard with stats components
β βββ upload/ # File upload functionality
β βββ wrapped/ # Spotify-style Wrapped experience
β βββ layout.tsx # Root layout
βββ components/ # React components
β βββ ui/ # Shadcn UI components
β βββ ... # App components (Navigation, etc.)
βββ lib/ # Utility libraries
β βββ auth/ # Better Auth configuration
β βββ client/ # Client-side utilities (parser, stats)
β βββ db/ # Database models and connection
β βββ services/ # Business logic services
β βββ types/ # TypeScript type definitions
βββ hooks/ # Custom React hooks
βββ public/ # Static assets
The application uses MongoDB with the following main collections:
- Users: User account information (managed by Better Auth)
- Songs: Song metadata (title, artist, duration, thumbnail, release date)
- UserStats: Aggregated user statistics including:
- Total songs, artists, and playtime
- Top songs and artists with play counts
- Music era analysis and decade distribution
- Daily averages and longest listening sessions
The app supports multiple authentication methods:
- Email/password registration
- Google OAuth integration
Configure these in lib/auth/config.ts and your environment variables.
Google Takeout files are processed client-side with:
- Intelligent song title parsing
- Artist extraction from video metadata
- Duplicate detection and handling
- Total unique songs played
- Total unique artists
- Total playtime (hours/minutes)
- Average song length
- Most played artist and song
- First and last play dates
- Daily listening averages
- Longest listening sessions
- Music era and decade distribution
- Oldest and newest songs in library
- Play count trends over time
- Top artists bar charts
- Top songs rankings
- Decade distribution charts
- Music era insights
- Connect your GitHub repository to Vercel
- Set up environment variables in Vercel dashboard
- Deploy automatically on push to main branch
-
Build the application:
pnpm build
-
Start the production server:
pnpm start
We welcome contributions! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow the existing code style
- Write TypeScript for type safety
- Add tests for new features
- Update documentation as needed
- Use Biome for linting and formatting
File Upload Fails
- Ensure the file is a valid JSON from Google Takeout
- Check that you're uploading the correct
watch-history.jsonfile
Authentication Issues
- Verify MongoDB connection string
- Check Better Auth configuration
- Ensure environment variables are set correctly
Stats Not Loading
- Make sure you've uploaded your data first
- Check browser console for errors
- Verify API routes are working
- Check the Issues page
- Create a new issue with detailed information
- Include error messages and steps to reproduce
This project is licensed under the MIT License - see the LICENSE file for details.
Made with β€οΈ by Vaibhav Mishra