This project is a web application built with Next.js that generates personalized Spotify playlists based on the user's musical taste. It integrates with the Spotify API to access user playlists and listening data, and leverages AI powered by OpenAI GPT or similar large language models to analyze and identify the user's music preferences. Based on this analysis, the app generates new playlists tailored to the user's unique taste.
- User authentication via Spotify OAuth.
- Fetch user playlists and track metadata from Spotify.
- Allow users to select one or multiple playlists or the entire library for analysis.
- AI-based musical taste analysis using OpenAI GPT or similar.
- Generate new playlists based on AI recommendations.
- Create and save generated playlists in the user's Spotify account.
- Responsive and intuitive UI for desktop and mobile.
- Graceful error handling for API and AI service failures.
- Secure handling of user data and tokens during sessions.
- Fast load and response times (under 3 seconds for UI, under 10 seconds for AI analysis).
- Scalable architecture to support multiple concurrent users.
- Intuitive and accessible user interface.
- Reliable handling of API rate limits and errors.
- Modular, well-documented, and maintainable codebase.
- Secure storage and transmission of sensitive data.
The system consists of the following main components:
- Frontend (Next.js): Handles user interface, authentication, and interaction with backend services.
- Backend API Routes (Next.js API): Acts as a proxy for Spotify API calls and AI service requests, managing authentication tokens and business logic.
- Spotify API: Provides access to user playlists, track metadata, and playlist creation.
- AI Service (OpenAI GPT or similar): Analyzes user playlists to identify musical taste and generate playlist recommendations.
graph TD
User -->|Login| Frontend
Frontend -->|OAuth Tokens| Backend
Backend -->|Spotify API Calls| SpotifyAPI
Backend -->|AI Analysis Requests| AIService
Backend -->|Playlist Creation| SpotifyAPI
Frontend -->|Display Results| User
graph TD
User -->|Login with Spotify OAuth| Frontend
Frontend -->|Send OAuth Token| Backend
Backend -->|Fetch Playlists & Tracks| SpotifyAPI
Backend -->|Send Playlist Data| AIService
AIService -->|Return Analysis & Recommendations| Backend
Backend -->|Create Playlist| SpotifyAPI
Backend -->|Send Playlist Info| Frontend
Frontend -->|Display Playlists| User
flowchart TD
Start[Start] --> Login[User logs in with Spotify]
Login --> Select[User selects playlists to analyze]
Select --> Analyze[App sends data to AI for analysis]
Analyze --> Generate[AI generates playlist recommendations]
Generate --> Create[App creates playlists on Spotify]
Create --> Display[Display generated playlists to user]
Display --> End[End]
- Bun (version 1.0 or higher) - This project uses Bun as the JavaScript runtime for faster package management and execution.
- Environment variables for Spotify API credentials, OpenAI API key, and other secrets
- Local development with Next.js dev server
SPOTIFY_CLIENT_IDSPOTIFY_CLIENT_SECRETSPOTIFY_REDIRECT_URIOPENAI_API_KEYNEXT_PUBLIC_BASE_URL(for frontend API calls)
- Recommended platform: Vercel (optimized for Next.js)
- Configure environment variables securely in the deployment platform
- Use serverless functions (Next.js API routes) for backend logic
- Enable HTTPS and secure headers
- Set up monitoring and logging for production environment
- Use GitHub Actions or similar for automated testing and deployment
- Run linting, formatting, and tests on pull requests
- Deploy automatically on merge to main branch
This project uses Bun as the JavaScript runtime and package manager for faster performance. To install Bun, follow the instructions at https://bun.sh/docs/installation.
For macOS/Linux:
curl -fsSL https://bun.sh/install | bashFor Windows:
powershell -c "irm bun.sh/install.ps1 | iex"- Clone the repository
- Install dependencies with
bun install - Create a
.env.localfile with required environment variables - Run the development server with
bun run dev - Access the app at
http://localhost:3000
Note: The bun.lock file ensures consistent dependency versions across environments. Always use bun install and bun run commands to maintain compatibility with the project's Bun setup.
This project uses semantic commits with Gitmoji prefixes to improve clarity, consistency, and automation in version control.
<emoji> type(scope): message
✨ feat(frontend): add playlist preview feature
| Type | Emoji | Description |
|---|---|---|
| feat | ✨ | Add a new feature |
| fix | 🐛 | Bug fix |
| docs | 📝 | Documentation update |
| style | 🎨 | Code style changes (no logic) |
| refactor | ♻️ | Code refactor (no feature/bug fix) |
| perf | ⚡ | Performance improvement |
| test | ✅ | Add or update tests |
| build | 📦 | Build-related changes |
| ci | 👷 | CI/CD changes |
| chore | 🔧 | Other minor tasks |
| revert | ⏪ | Revert a previous commit |
For more details, see the commit message conventions documentation.
This project is licensed under the MIT License. See the LICENSE file for details.