A simple web application that uses Gemini AI with grounding search to analyze songs and reveal their themes, cultural context, and hidden meanings. Features Spotify integration for music previews while you explore the deeper meanings behind your favorite tracks.
- π€ AI-Powered Analysis: Uses Gemini AI with grounding search for accurate, contextual song analysis
- π Share Analysis: Generate shareable links for song analyses with SEO-optimized pages
- πΎ Smart Caching: Database-backed analysis caching to reduce LLM calls and improve performance
- π΅ Enhanced Spotify Integration:
- Smart Search: Search naturally with any keywords (e.g., "Bohemian Rhapsody", "Taylor Swift")
- Multiple Results: Browse up to 15 search results with album art and metadata
- Track Selection: Click any track to automatically start analysis
- 30-second Previews: Play music previews directly in search results
- Auto-Analysis: Selected tracks trigger immediate meaning analysis
- Fallback Support: Graceful handling when previews aren't available
- π¨ Neobrutalism Design: Bold, modern interface inspired by contemporary design trends
- βοΈ Secure API: Server-side API routes keep your API keys safe from client exposure
- β‘ Rate Limited: 5 analysis per IP per day to prevent abuse
- π± Responsive: Works perfectly on desktop and mobile devices
- π Fast: Optimized with caching and performance monitoring
- π‘οΈ Secure: Input validation, sanitization, and security monitoring
Visit the live application: song2meaning.vercel.app
- Frontend: Next.js 15, React 19, TypeScript
- Styling: Tailwind CSS 4 with custom neobrutalism design
- AI: Google Gemini AI with grounding search
- Database: Supabase for analysis caching and sharing
- Music: Spotify Web API integration for track search and previews
- Deployment: Vercel
- Security: Server-side API routes, rate limiting, input validation
- Node.js 18+
- Gemini AI API key (Get one here)
- Spotify Developer Account (Create one here)
- Supabase account for database (Create one here)
- Smart Search Interface: Natural language search - no more "Artist - Song" format required
- Multiple Results Display: Browse up to 15 tracks with rich metadata and album artwork
- Instant Previews: Play 30-second previews directly from search results
- One-Click Analysis: Select any track to automatically trigger meaning analysis
- Debounced Search: Real-time search with 300ms debouncing for optimal performance
- Visual Track Cards: Album art, artist info, duration, and popularity indicators
- Keyboard Navigation: Full keyboard support with escape to close results
- Mobile Optimized: Touch-friendly interface that works perfectly on all devices
- Shareable Links: Every song analysis now generates a unique shareable URL
- SEO Optimized: Share pages include proper metadata for social media previews
- Copy to Clipboard: One-click sharing with automatic clipboard copying
- Persistent Storage: Shared analyses are stored in Supabase for permanent access
- Access Tracking: Monitor how many times your shared analysis has been viewed
- Database-Backed Caching: All analyses are stored in Supabase to prevent duplicate LLM calls
- Intelligent Matching: Normalized search keys ensure variations of the same song are matched
- Performance Boost: Cached results load instantly, saving API costs and improving UX
- Cache Statistics: Track cache hits and performance metrics
- Automatic Updates: Access counts and timestamps are automatically maintained
- Visit Google AI Studio
- Sign in with your Google account
- Click "Create API Key"
- Copy the generated API key
Song2Meaning uses the Client Credentials Flow for Spotify integration, which is perfect for server-side applications that don't require user login.
- Go to the Spotify Developer Dashboard
- Log in with your Spotify account (create one if needed)
- Click "Create app"
- Fill in the app details:
- App name:
Song2Meaning
(or your preferred name) - App description:
AI-powered song analysis with music previews
- Website: Your domain (e.g.,
https://yourdomain.com
) orhttp://localhost:3000
for development - Redirect URI:
http://localhost:3000/callback
(for development) - API/SDKs: Check "Web API"
- App name:
- Accept the terms and click "Save"
- In your newly created app dashboard, you'll see:
- Client ID: A public identifier for your app
- Client Secret: A private key (keep this secure!)
- Click "Show client secret" to reveal it
- Copy both values - you'll need them for your environment variables
For production deployment, update your app settings:
- Go to "Settings" in your Spotify app dashboard
- Update "Redirect URIs" to include your production domain
- Add your production website URL
π Security Note: The Client Secret should never be exposed in client-side code. Song2Meaning handles this securely by using server-side API routes.
- β No user login required - Perfect for public song analysis
- β Server-side security - Client secret stays on your server
- β Simple setup - No complex OAuth flows
- β Rate limit friendly - Suitable for application-level requests
-
Clone the repository
git clone https://github.com/4regab/song2meaning.git cd song2meaning
-
Install dependencies
npm install
-
Set up Supabase database
- Create a new project at supabase.com
- Go to SQL Editor in your Supabase dashboard
- Copy and paste the contents of
supabase/schema.sql
- Run the SQL to create the database schema
-
Set up environment variables
cp .env.local.example .env.local
Edit
.env.local
and add your API keys:# Gemini AI API Configuration GEMINI_API_KEY=your_gemini_api_key_here # Spotify API Configuration SPOTIFY_CLIENT_ID=your_spotify_client_id_here SPOTIFY_CLIENT_SECRET=your_spotify_client_secret_here # Supabase Configuration NEXT_PUBLIC_SUPABASE_URL=your_supabase_project_url NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key SUPABASE_SERVICE_ROLE_KEY=your_supabase_service_role_key # Base URL for share links (optional, defaults to localhost:3000) NEXT_PUBLIC_BASE_URL=https://yourdomain.com
-
Run the development server
npm run dev
-
Open your browser Navigate to http://localhost:3000
-
Push to GitHub
git add . git commit -m "Initial commit" git push origin main
-
Deploy to Vercel
- Go to vercel.com
- Import your GitHub repository
- Add environment variable:
GEMINI_API_KEY
- Deploy!
-
Environment Variables In your Vercel project settings, add:
GEMINI_API_KEY
: Your Gemini AI API keySPOTIFY_CLIENT_ID
: Your Spotify Client IDSPOTIFY_CLIENT_SECRET
: Your Spotify Client SecretNEXT_PUBLIC_SUPABASE_URL
: Your Supabase project URLNEXT_PUBLIC_SUPABASE_ANON_KEY
: Your Supabase anonymous keySUPABASE_SERVICE_ROLE_KEY
: Your Supabase service role keyNEXT_PUBLIC_BASE_URL
: Your production domain (e.g., https://yourdomain.vercel.app)
-
Search naturally - Type any song-related keywords:
"Bohemian Rhapsody"
"Taylor Swift Shake It Off"
"Beatles Yesterday"
"Nirvana Smells Like Teen Spirit"
-
Browse results - See up to 15 tracks with:
- Album artwork and metadata
- Artist names and album information
- Track duration and popularity scores
- Preview availability indicators (green dot)
-
Preview tracks - Click the play button on album art to hear 30-second previews
-
Select your song - Click any track card to automatically start analysis
-
View comprehensive analysis with detailed sections:
- π Overview: Summary of the song's meaning and key themes
- π Deep Dive: Detailed lyrical analysis and interpretation
- π Cultural Context: Historical and cultural background
- π΅ Spotify Player: Continue listening while reading the analysis
-
Share your analysis using the share button to copy a permanent link
-
Enjoy instant results for previously analyzed songs thanks to smart caching
No music previews showing up?
- Verify your
SPOTIFY_CLIENT_ID
andSPOTIFY_CLIENT_SECRET
are correctly set - Check that your Spotify app is properly configured in the Developer Dashboard
- Note: Not all tracks have preview URLs available from Spotify
"Spotify API error" messages?
- Ensure your Spotify app has "Web API" enabled
- Check that your Client Secret hasn't been regenerated (this would invalidate the old one)
- Verify your environment variables are properly loaded
Rate limiting from Spotify?
- The Client Credentials flow has generous rate limits for most use cases
- If you hit limits, the app will gracefully continue without previews
"Service configuration error"?
- Check that all required environment variables are set
- Restart your development server after changing
.env.local
- Verify your API keys are valid and haven't expired
Analysis not working?
- Ensure your
GEMINI_API_KEY
is valid - Check the Gemini API status
- Verify you haven't exceeded your Gemini API quota
POST /api/analyze
- Analyze a song's meaning and themes (with caching and sharing)GET /share/[shareId]
- View shared song analysis with SEO metadataGET /api/health
- System health checkGET /api/stats
- Performance statistics (includes cache metrics)GET /api/rate-limit
- Rate limit statusPOST /api/validate
- Input validationGET /api/spotify/search
- Search for single Spotify track (legacy)GET /api/spotify/search-multiple
- New: Search for multiple Spotify tracks with metadataGET /api/spotify/preview
- Get track preview URLs
- Server-side API: API key never exposed to client
- Rate Limiting: 5 requests per IP per day
- Input Validation: Strict format validation and sanitization
- Error Handling: Comprehensive error management with fallbacks
- Security Monitoring: Request logging and anomaly detection
- Database Caching: Persistent Supabase caching eliminates duplicate LLM calls
- Smart Cache Matching: Normalized search keys for intelligent song matching
- Request Deduplication: Prevents duplicate API calls in real-time
- Performance Monitoring: Real-time metrics and cache statistics
- Optimized Prompts: Efficient AI interactions
- Instant Results: Cached analyses load immediately, improving user experience
The application features a neobrutalism design with:
- Bold black borders and shadows
- High contrast colors
- Chunky, interactive buttons
- Clean typography (Inter + JetBrains Mono)
- Responsive layout
- 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
For issues or questions, visit: GitHub Issues
This project is licensed under the MIT License - see the LICENSE file for details.
- Google Gemini AI for powerful language processing
- Supabase for database and backend services
- Spotify Web API for music integration and previews
- Vercel for seamless deployment
- Next.js for the amazing React framework
- Tailwind CSS for utility-first styling
If you have any questions or issues:
- Check the Issues page
- Create a new issue if needed
- Review the troubleshooting section above
- Check the Spotify Developer Documentation for API-related issues
Made with β€οΈ and AI - Discover the stories behind your favorite songs!