Splitify is a Next.js app that routes a large Spotify playlist into smaller curated playlists using an adaptable AI agent. It reads the user's Spotify playlists, asks the agent for a structured split plan, lets the user edit the preview, and then creates private playlists back in Spotify.
- Next.js App Router, React, TypeScript, Tailwind CSS
- NextAuth.js with Spotify OAuth
- Prisma with SQLite for local development
- Configurable AI agent model
- Vitest for focused unit tests
-
Install dependencies:
corepack pnpm install
-
Create
.env.localfrom.env.exampleand fill the values:DATABASE_URL="file:./dev.db" NEXTAUTH_SECRET="replace-with-a-long-random-secret" NEXTAUTH_URL="http://localhost:3000" SPOTIFY_CLIENT_ID="" SPOTIFY_CLIENT_SECRET="" AI_AGENT_API_KEY="" AI_AGENT_MODEL=""
-
In the Spotify Developer Dashboard, add this redirect URI:
http://localhost:3000/api/auth/callback/spotify -
Generate Prisma Client and apply the schema:
corepack pnpm prisma:generate corepack pnpm prisma:migrate
-
Start the app:
corepack pnpm dev
The Spotify OAuth provider requests:
playlist-read-privateplaylist-read-collaborativeplaylist-modify-privateplaylist-modify-publicuser-read-emailuser-read-private
Access and refresh tokens are stored server-side by NextAuth in Prisma's Account table. API routes refresh expired Spotify access tokens before calling Spotify.
- Sign in with Spotify.
- Select a source playlist.
- Choose prompt, manual categories, or both.
- Choose whether songs can overlap across generated playlists.
- Generate an AI agent preview.
- Rename categories, move tracks, or remove tracks.
- Create private Spotify playlists with the configured prefix.
corepack pnpm dev
corepack pnpm build
corepack pnpm lint
corepack pnpm typecheck
corepack pnpm test
corepack pnpm prisma:generate
corepack pnpm prisma:migrate
corepack pnpm prisma:studio- Spotify's restricted/deprecated Audio Features and Audio Analysis endpoints are not used. Splitify only sends compact track metadata to the AI agent: track ID, title, artists, and album.
- Large playlists are processed in chunks and then consolidated into one editable plan.
SplitAssignment.trackMetadatais stored as a JSON string for SQLite compatibility.