A TypeScript/Next.js application that helps you port your iTunes music library to Spotify by matching local tracks with their Spotify equivalents.
- iTunes Library Import: Parse iTunes library metadata into a SQLite database
- Smart Spotify Matching: Search Spotify API with intelligent similarity scoring
- Interactive Review UI: Manually review and confirm matches with confidence scores displayed
- AI-Powered Metadata Fixing: Automatically clean problematic metadata using LLM
- Search Caching: 30-mins cache reduces API calls and improves performance
- Node.js 22+ (see
.nvmrc) - Spotify API credentials (Get them here)
- iTunes library JSON export
# Clone the repository
git clone https://github.com/your-username/itunes-port-to-spotify.git
cd itunes-port-to-spotify
# Install dependencies
npm install
# Set up environment variables
cp .env.example .env.local
# Edit .env.local with your Spotify credentialsCreate a .env.local file with:
# Spotify API (required)
SPOTIFY_CLIENT_ID=your_client_id
SPOTIFY_CLIENT_SECRET=your_client_secret
# Spotify Search Cache (optional)
SPOTIFY_CACHE_TTL_MINUTES=30 # Default: 30 minutes
# Google OAuth (optional, for authentication)
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
AUTH_SECRET=your_nextauth_secret
ALLOWED_EMAIL=your_email@example.com
# AI Metadata Fixer (optional)
GROQ_API_KEY=your_groq_api_key
# Database (local development uses file:./database.db by default)
# TURSO_DATABASE_URL=libsql://your-db.turso.io
# TURSO_AUTH_TOKEN=your_token# Run development server
npm run dev
# Run tests
npm test
# Run linter
npm run lint
# Run database migrations
npm run db:migrateVisit http://localhost:3000/spotify-matcher to start matching songs.
- Uses Drizzle ORM for type-safe database operations
- Local development: SQLite file (
database.db) - Production: Turso (cloud SQLite)
- Schema defined in
lib/schema.ts - Migrations in
drizzle/migrations/
- Modern Spotify Web API SDK (
@spotify/web-api-ts-sdk) - Client credentials flow for authentication
- Smart search with multiple strategies (artist+track, track-only fallback)
- Similarity scoring based on artist, title, and album matching
- Unit tests: Vitest with Polly.js for HTTP recording/replay
- Integration tests: Real API interactions recorded for offline testing
- E2E tests: Playwright for browser automation
- All tests use committed recordings (no API credentials needed in CI)
- Metadata fixing: Groq LLM integration to clean problematic metadata
- Fixes whitespace, featured artists, special characters, typos
- Confidence scoring (high/medium/low)
- In-memory caching to reduce API calls
- OAuth Setup - Google OAuth configuration
- Deployment Guide - Vercel deployment and CI/CD
- AI Features - AI metadata fixer setup and usage
- Testing - Polly.js setup, recording workflow, test organization
- Architecture - Core components, database schema, design patterns
- Stories & Tech Debt - Planned features and refactoring opportunities
This project follows strict Test-Driven Development (TDD):
- Write failing tests first
- Implement minimal code to pass
- Refactor while keeping tests green
- Commit with tests
See CLAUDE.md for detailed development guidelines.
app/ # Next.js pages and components
spotify-matcher/ # Main UI for matching songs
lib/ # Core utilities and business logic
schema.ts # Database schema (Drizzle ORM)
spotify.ts # Spotify API client
spotify-actions.ts # Server actions for database operations
ai-metadata-fixer.ts # AI metadata fixing
drizzle/ # Database migrations
docs/ # Documentation
test/ # Test files
polly/ # Polly.js setup
fixtures/ # Test data
recordings/ # HTTP recordings
- Create a feature branch
- Follow TDD workflow (tests first!)
- Run linter:
npm run lint - Run tests:
npm test - Open a pull request
Pull requests automatically get:
- Isolated Turso database branch
- Preview deployment on Vercel
- Full test suite execution
- Frontend: Next.js 15, React 19, TypeScript, Tailwind CSS
- Database: SQLite (local), Turso (production), Drizzle ORM
- API: Spotify Web API SDK
- AI: Groq (LLaMA 3.3)
- Testing: Vitest, Playwright, Polly.js
- Deployment: Vercel, GitHub Actions
- Auth: NextAuth.js with Google OAuth
MIT
For issues or questions:
- Open an issue on GitHub
- Check documentation in
docs/folder - Review
STORIES.mdfor known issues and planned improvements