A modern, sleek web application for real-time personal Spotify analytics. Discover your music DNA with beautiful visualizations and insights.
- Overview Dashboard: Get a quick snapshot of your music taste with stats cards, currently playing widget, and top tracks/artists
- Top Tracks: View your most played tracks with time range filters (4 weeks, 6 months, all time) and audio feature visualizations
- Top Artists: Discover your favorite artists with genre distribution and popularity metrics
- Audio Analysis: Deep dive into your music's characteristics with radar charts, key distribution, and mood analysis
- Listening History: Calendar heatmap showing daily activity, hour-of-day patterns, and recent play timeline
- Currently Playing: Real-time view of what you're listening to right now
- Spotify OAuth authentication
- Real-time currently playing updates (every 5 seconds)
- Beautiful dark mode UI inspired by Spotify
- Responsive design (desktop, tablet, mobile)
- Interactive charts and visualizations
- Audio feature analysis (danceability, energy, valence, etc.)
- Activity heatmaps and listening patterns
- Time range selectors for historical data
- Framework: Next.js 15 (App Router)
- Language: TypeScript
- Styling: Tailwind CSS
- Authentication: NextAuth.js with Spotify Provider
- Charts: Recharts
- Icons: Lucide React
- Date Utilities: date-fns
- Node.js 18+ installed
- A Spotify account
- Spotify Developer Account (for API credentials)
git clone https://github.com/yourusername/spolitics.git
cd spoliticsnpm install- Go to Spotify Developer Dashboard
- Log in with your Spotify account
- Click "Create an App"
- Fill in the details:
- App Name: Spolitics (or your preferred name)
- App Description: Personal Spotify Analytics Dashboard
- After creating, you'll see your Client ID and Client Secret
- Click "Edit Settings"
- Add the following to Redirect URIs:
http://localhost:3000/api/auth/callback/spotify - Save your settings
π For detailed explanation of all environment variables, see ENV_VARIABLES_GUIDE.md
Create a .env.local file in the root directory:
cp .env.local.example .env.localEdit .env.local and add your credentials:
# Spotify API Credentials
SPOTIFY_CLIENT_ID=your_client_id_here
SPOTIFY_CLIENT_SECRET=your_client_secret_here
# NextAuth Configuration
# NEXTAUTH_URL determines the callback URL: {NEXTAUTH_URL}/api/auth/callback/spotify
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=your_secret_key_hereNote: The redirect URI in Spotify settings must match {NEXTAUTH_URL}/api/auth/callback/spotify
To generate a secure NEXTAUTH_SECRET, run:
openssl rand -base64 32npm run devOpen http://localhost:3000 in your browser.
- Click "Connect with Spotify"
- Authorize the app to access your Spotify data
- You'll be redirected to the dashboard
spolitics/
βββ app/
β βββ api/
β β βββ auth/
β β βββ [...nextauth]/
β β βββ route.ts # NextAuth configuration
β βββ dashboard/
β β βββ analysis/
β β β βββ page.tsx # Audio Analysis page
β β βββ artists/
β β β βββ page.tsx # Top Artists page
β β βββ history/
β β β βββ page.tsx # Listening History page
β β βββ playing/
β β β βββ page.tsx # Currently Playing page
β β βββ tracks/
β β β βββ page.tsx # Top Tracks page
β β βββ layout.tsx # Dashboard layout with sidebar
β β βββ page.tsx # Overview dashboard
β βββ globals.css # Global styles
β βββ layout.tsx # Root layout
β βββ page.tsx # Login page
βββ components/
β βββ AnimatedBackground.tsx # Canvas animation for login
β βββ ArtistCard.tsx # Artist card component
β βββ CurrentlyPlaying.tsx # Currently playing widget
β βββ EmptyState.tsx # Empty state component
β βββ LoadingState.tsx # Loading skeleton
β βββ Providers.tsx # Session provider wrapper
β βββ Sidebar.tsx # Navigation sidebar
β βββ StatCard.tsx # Stat card component
β βββ TimeRangeSelector.tsx # Time range filter
β βββ TrackCard.tsx # Track card component
βββ lib/
β βββ spotify.ts # Spotify API client
βββ types/
β βββ next-auth.d.ts # NextAuth type extensions
β βββ spotify.ts # Spotify data types
βββ .env.local.example # Environment variables template
βββ next.config.ts # Next.js configuration
βββ package.json # Dependencies
βββ tailwind.config.ts # Tailwind configuration
βββ tsconfig.json # TypeScript configuration
npm run dev- Start development servernpm run build- Build for productionnpm start- Start production servernpm run lint- Run ESLint
- Background:
#121212(spotify-black),#181818(spotify-darkgray) - Primary:
#1DB954(spotify-green) - Text:
#FFFFFF(white),#B3B3B3(gray) - Accents: Purple, Pink, Blue gradients for charts
- Font: Inter (system fallback: system-ui, sans-serif)
All components follow a dark theme with:
- Rounded corners (lg, xl)
- Subtle borders (
border-spotify-lightgray/20) - Hover effects (scale, color transitions)
- Smooth animations
The app requests the following Spotify scopes:
user-read-email- Read user emailuser-read-private- Read user profileuser-top-read- Read top artists and tracksuser-read-recently-played- Read recently played tracksuser-read-currently-playing- Read currently playing trackuser-read-playback-state- Read playback stateplaylist-read-private- Read private playlistsplaylist-read-collaborative- Read collaborative playlists
- Push your code to GitHub
- Import project to Vercel
- Add environment variables in Vercel dashboard
- Update Spotify redirect URI to include your production URL:
https://your-domain.vercel.app/api/auth/callback/spotify - Deploy!
Make sure to:
- Set all environment variables
- Update Spotify redirect URIs
- Build the project with
npm run build
Make sure the redirect URI in your Spotify app settings matches exactly:
http://localhost:3000/api/auth/callback/spotify
- Make sure you've been using Spotify regularly
- Some endpoints require listening history
- Try different time ranges
- Check that your Client ID and Client Secret are correct
- Verify NEXTAUTH_SECRET is set
- Clear cookies and try again
Contributions are welcome! Please feel free to submit a Pull Request.
MIT License - feel free to use this project for personal or commercial purposes.
- Inspired by stats.fm and Spotify's own analytics
- Built with Spotify Web API
- Design inspired by Spotify's UI/UX
If you encounter any issues or have questions:
- Check the Troubleshooting section
- Open an issue on GitHub
- Check Spotify API documentation
Made with love and TypeScript | Powered by Spotify API