Repository: rishabh-hub/rocket-league-music
Pull request #1: Feature/music recs
Author: login: rishabh-hub
Created: 2025-05-30T11:46:50Z | Merged: 2025-05-30T12:06:29Z

1. Integrated custom built and hosted music recommendation api
2. Added spotify iframe embedding, for playing recommended song

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

- **New Features**
  - Added a "Song Recommendations" tab to replay details pages, allowing users to generate and view personalized song suggestions based on player data.
  - Introduced interactive components for displaying song recommendations and detailed Spotify song cards, including embedded Spotify players and match criteria badges.
  - Enabled fetching of Spotify track details within the app.
  - Integrated backend API routes for song recommendation and Spotify authentication.

- **Improvements**
  - Updated environment variable documentation to support Spotify and song recommendation API integration.
  - Enhanced workspace appearance with custom editor color themes.

- **Documentation**
  - Added comments clarifying the status of environment variable validation.

- **Dependencies**
  - Updated "framer-motion" to a newer version for improved animations.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->


Diff:
diff --git a/.env.example b/.env.example
index f990f28..3879c69 100644
--- a/.env.example
+++ b/.env.example
@@ -15,3 +15,11 @@ STRIPE_SECRET_KEY='your stripe secret key' ## required for stripe
 STRIPE_WEBHOOK_SECRET_KEY='your webhook secret key' ## required for stripe
 STRIPE_SUBSCRIPTION_PRICE_ID='your subscription price id' ## required for stripe
 NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY='your stripe publishable key' ## required for stripe
+
+
+####################### SPOTIFY API #######################
+NEXT_PUBLIC_SPOTIFY_CLIENT_ID=your_spotify_client_id_here
+SPOTIFY_CLIENT_SECRET=your_spotify_client_secret_here
+
+####################### SONG RECOMMEND API #######################
+PYTHON_API_URL='https://replay-rythms-recs.onrender.com'
\ No newline at end of file
diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 0000000..9ac07c7
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,7 @@
+{
+    "workbench.colorCustomizations": {
+        "activityBar.background": "#2C300C",
+        "titleBar.activeBackground": "#3D4411",
+        "titleBar.activeForeground": "#FAFBEF"
+    }
+}
\ No newline at end of file
diff --git a/package-lock.json b/package-lock.json
index 1a29398..3955f7d 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -34,7 +34,7 @@
         "class-variance-authority": "^0.7.1",
         "clsx": "^2.1.1",
         "form-data": "^4.0.2",
-        "framer-motion": "^12.11.0",
+        "framer-motion": "^12.15.0",
         "fs-extra": "^11.3.0",
         "lucide-react": "^0.473.0",
         "motion": "^12.11.1",
@@ -3586,7 +3586,7 @@
       "version": "1.49.1",
       "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.49.1.tgz",
       "integrity": "sha512-Ky+BVzPz8pL6PQxHqNRW1k3mIyv933LML7HktS8uik0bUXNCdPhoS/kLihiO1tMf/egaJb4IutXd7UywvXEW+g==",
-      "dev": true,
+      "devOptional": true,
       "dependencies": {
         "playwright": "1.49.1"
       },
@@ -3618,13 +3618,13 @@
       "version": "6.2.1",
       "resolved": "https://registry.npmjs.org/@prisma/debug/-/debug-6.2.1.tgz",
       "integrity": "sha512-0KItvt39CmQxWkEw6oW+RQMD6RZ43SJWgEUnzxN8VC9ixMysa7MzZCZf22LCK5DSooiLNf8vM3LHZm/I/Ni7bQ==",
-      "dev": true
+      "devOptional": true
     },
     "node_modules/@prisma/engines": {
       "version": "6.2.1",
       "resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-6.2.1.tgz",
       "integrity": "sha512-lTBNLJBCxVT9iP5I7Mn6GlwqAxTpS5qMERrhebkUhtXpGVkBNd/jHnNJBZQW4kGDCKaQg/r2vlJYkzOHnAb7ZQ==",
-      "dev": true,
+      "devOptional": true,
       "hasInstallScript": true,
       "dependencies": {
         "@prisma/debug": "6.2.1",
@@ -3637,13 +3637,13 @@
       "version": "6.2.0-14.4123509d24aa4dede1e864b46351bf2790323b69",
       "resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-6.2.0-14.4123509d24aa4dede1e864b46351bf2790323b69.tgz",
       "integrity": "sha512-7tw1qs/9GWSX6qbZs4He09TOTg1ff3gYsB3ubaVNN0Pp1zLm9NC5C5MZShtkz7TyQjx7blhpknB7HwEhlG+PrQ==",
-      "dev": true
+      "devOptional": true
     },
     "node_modules/@prisma/fetch-engine": {
       "version": "6.2.1",
       "resolved": "https://registry.npmjs.org/@prisma/fetch-engine/-/fetch-engine-6.2.1.tgz",
       "integrity": "sha512-OO7O9d6Mrx2F9i+Gu1LW+DGXXyUFkP7OE5aj9iBfA/2jjDXEJjqa9X0ZmM9NZNo8Uo7ql6zKm6yjDcbAcRrw1A==",
-      "dev": true,
+      "devOptional": true,
       "dependencies": {
         "@prisma/debug": "6.2.1",
         "@prisma/engines-version": "6.2.0-14.4123509d24aa4dede1e864b46351bf2790323b69",
@@ -3654,7 +3654,7 @@
       "version": "6.2.1",
       "resolved": "https://registry.npmjs.org/@prisma/get-platform/-/get-platform-6.2.1.tgz",
       "integrity": "sha512-zp53yvroPl5m5/gXYLz7tGCNG33bhG+JYCm74ohxOq1pPnrL47VQYFfF3RbTZ7TzGWCrR3EtoiYMywUBw7UK6Q==",
-      "dev": true,
+      "devOptional": true,
       "dependencies": {
         "@prisma/debug": "6.2.1"
       }
@@ -5879,6 +5879,27 @@
         }
       }
     },
+    "node_modules/@testing-library/dom": {
+      "version": "10.4.0",
+      "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-10.4.0.tgz",
+      "integrity": "sha512-pemlzrSESWbdAloYml3bAJMEfNh1Z7EduzqPKprCH5S341frlpYnUEW0H72dLxa6IsYr+mPno20GiSm+h9dEdQ==",
+      "dev": true,
+      "license": "MIT",
+      "peer": true,
+      "dependencies": {
+        "@babel/code-frame": "^7.10.4",
+        "@babel/runtime": "^7.12.5",
+        "@types/aria-query": "^5.0.1",
+        "aria-query": "5.3.0",
+        "chalk": "^4.1.0",
+        "dom-accessibility-api": "^0.5.9",
+        "lz-string": "^1.5.0",
+        "pretty-format": "^27.0.2"
+      },
+      "engines": {
+        "node": ">=18"
+      }
+    },
     "node_modules/@testing-library/jest-dom": {
       "version": "6.6.3",
       "resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-6.6.3.tgz",
@@ -5961,6 +5982,14 @@
       "dev": true,
       "license": "MIT"
     },
+    "node_modules/@types/aria-query": {
+      "version": "5.0.4",
+      "resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-5.0.4.tgz",
+      "integrity": "sha512-rfT93uj5s0PRL7EzccGMs3brplhcrghnDoV26NqKhCAS1hVo+WdNsPvE/yb6ilfr5hi2MEk6d5EWJTKdxg8jVw==",
+      "dev": true,
+      "license": "MIT",
+      "peer": true
+    },
     "node_modules/@types/aws-lambda": {
       "version": "8.10.147",
       "resolved": "https://registry.npmjs.org/@types/aws-lambda/-/aws-lambda-8.10.147.tgz",
@@ -6152,7 +6181,7 @@
       "version": "19.0.7",
       "resolved": "https://registry.npmjs.org/@types/react/-/react-19.0.7.tgz",
       "integrity": "sha512-MoFsEJKkAtZCrC1r6CM8U22GzhG7u2Wir8ons/aCKH6MBdD1ibV24zOSSkdZVUKqN5i396zG5VKLYZ3yaUZdLA==",
-      "dev": true,
+      "devOptional": true,
       "dependencies": {
         "csstype": "^3.0.2"
       }
@@ -6161,7 +6190,7 @@
       "version": "19.0.3",
       "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-19.0.3.tgz",
       "integrity": "sha512-0Knk+HJiMP/qOZgMyNFamlIjw9OFCsyC2ZbigmEEyXXixgre6IQpm/4V+r3qH4GC1JPvRJKInw+on2rV6YZLeA==",
-      "dev": true,
+      "devOptional": true,
       "peerDependencies": {
         "@types/react": "^19.0.0"
       }
@@ -8121,6 +8150,14 @@
         "node": ">=0.10.0"
       }
     },
+    "node_modules/dom-accessibility-api": {
+      "version": "0.5.16",
+      "resolved": "https://registry.npmjs.org/dom-accessibility-api/-/dom-accessibility-api-0.5.16.tgz",
+      "integrity": "sha512-X7BJ2yElsnOJ30pZF4uIIDfBEVgF4XEBxL9Bxhy6dnrm5hkzqmsWHGTiHqRiITNhMyFLyAiWndIJP7Z1NTteDg==",
+      "dev": true,
+      "license": "MIT",
+      "peer": true
+    },
     "node_modules/dom-serializer": {
       "version": "2.0.0",
       "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz",
@@ -9262,13 +9299,13 @@
       }
     },
     "node_modules/framer-motion": {
-      "version": "12.11.1",
-      "resolved": "https://registry.npmjs.org/framer-motion/-/framer-motion-12.11.1.tgz",
-      "integrity": "sha512-k8SlrjoDesLTBklizQ2BSW7Pb99cHDoZe51Tff9ZjmWHQ/N5DLly949veBnwNfeH4d0E/h02RKuul/6D+5u9Bg==",
+      "version": "12.15.0",
+      "resolved": "https://registry.npmjs.org/framer-motion/-/framer-motion-12.15.0.tgz",
+      "integrity": "sha512-XKg/LnKExdLGugZrDILV7jZjI599785lDIJZLxMiiIFidCsy0a4R2ZEf+Izm67zyOuJgQYTHOmodi7igQsw3vg==",
       "license": "MIT",
       "dependencies": {
-        "motion-dom": "^12.11.0",
-        "motion-utils": "^12.9.4",
+        "motion-dom": "^12.15.0",
+        "motion-utils": "^12.12.1",
         "tslib": "^2.4.0"
       },
       "peerDependencies": {
@@ -12203,6 +12240,17 @@
         "react": "^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0"
       }
     },
+    "node_modules/lz-string": {
+      "version": "1.5.0",
+      "resolved": "https://registry.npmjs.org/lz-string/-/lz-string-1.5.0.tgz",
+      "integrity": "sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==",
+      "dev": true,
+      "license": "MIT",
+      "peer": true,
+      "bin": {
+        "lz-string": "bin/bin.js"
+      }
+    },
     "node_modules/make-dir": {
       "version": "4.0.0",
       "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz",
@@ -12391,18 +12439,18 @@
       }
     },
     "node_modules/motion-dom": {
-      "version": "12.11.0",
-      "resolved": "https://registry.npmjs.org/motion-dom/-/motion-dom-12.11.0.tgz",
-      "integrity": "sha512-CItkGYJenn5ZsbzTX0D9mE0UWdjdd9r535FrxEXhzR8Kwa9I2dLr1uhEJgQPWbgaIJ6i0sNFnf2T9NvVDWQVBw==",
+      "version": "12.15.0",
+      "resolved": "https://registry.npmjs.org/motion-dom/-/motion-dom-12.15.0.tgz",
+      "integrity": "sha512-D2ldJgor+2vdcrDtKJw48k3OddXiZN1dDLLWrS8kiHzQdYVruh0IoTwbJBslrnTXIPgFED7PBN2Zbwl7rNqnhA==",
       "license": "MIT",
       "dependencies": {
-        "motion-utils": "^12.9.4"
+        "motion-utils": "^12.12.1"
       }
     },
     "node_modules/motion-utils": {
-      "version": "12.9.4",
-      "resolved": "https://registry.npmjs.org/motion-utils/-/motion-utils-12.9.4.tgz",
-      "integrity": "sha512-BW3I65zeM76CMsfh3kHid9ansEJk9Qvl+K5cu4DVHKGsI52n76OJ4z2CUJUV+Mn3uEP9k1JJA3tClG0ggSrRcg==",
+      "version": "12.12.1",
+      "resolved": "https://registry.npmjs.org/motion-utils/-/motion-utils-12.12.1.tgz",
+      "integrity": "sha512-f9qiqUHm7hWSLlNW8gS9pisnsN7CRFRD58vNjptKdsqFLpkVnX00TNeD6Q0d27V9KzT7ySFyK1TZ/DShfVOv6w==",
       "license": "MIT"
     },
     "node_modules/ms": {
@@ -13096,7 +13144,7 @@
       "version": "1.49.1",
       "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.49.1.tgz",
       "integrity": "sha512-VYL8zLoNTBxVOrJBbDuRgDWa3i+mfQgDTrL8Ah9QXZ7ax4Dsj0MSq5bYgytRnDVVe+njoKnfsYkH3HzqVj5UZA==",
-      "dev": true,
+      "devOptional": true,
       "dependencies": {
         "playwright-core": "1.49.1"
       },
@@ -13114,7 +13162,7 @@
       "version": "1.49.1",
       "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.49.1.tgz",
       "integrity": "sha512-BzmpVcs4kE2CH15rWfzpjzVGhWERJfmnXmniSyKeRZUs9Ws65m+RGIi7mjJK/euCegfn3i7jvqWeWyHe9y3Vgg==",
-      "dev": true,
+      "devOptional": true,
       "bin": {
         "playwright-core": "cli.js"
       },
@@ -13364,11 +13412,49 @@
         "node": ">=6.0.0"
       }
     },
+    "node_modules/pretty-format": {
+      "version": "27.5.1",
+      "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-27.5.1.tgz",
+      "integrity": "sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==",
+      "dev": true,
+      "license": "MIT",
+      "peer": true,
+      "dependencies": {
+        "ansi-regex": "^5.0.1",
+        "ansi-styles": "^5.0.0",
+        "react-is": "^17.0.1"
+      },
+      "engines": {
+        "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0"
+      }
+    },
+    "node_modules/pretty-format/node_modules/ansi-styles": {
+      "version": "5.2.0",
+      "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz",
+      "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==",
+      "dev": true,
+      "license": "MIT",
+      "peer": true,
+      "engines": {
+        "node": ">=10"
+      },
+      "funding": {
+        "url": "https://github.com/chalk/ansi-styles?sponsor=1"
+      }
+    },
+    "node_modules/pretty-format/node_modules/react-is": {
+      "version": "17.0.2",
+      "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz",
+      "integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==",
+      "dev": true,
+      "license": "MIT",
+      "peer": true
+    },
     "node_modules/prisma": {
       "version": "6.2.1",
       "resolved": "https://registry.npmjs.org/prisma/-/prisma-6.2.1.tgz",
       "integrity": "sha512-hhyM0H13pQleQ+br4CkzGizS5I0oInoeTw3JfLw1BRZduBSQxPILlJLwi+46wZzj9Je7ndyQEMGw/n5cN2fknA==",
-      "dev": true,
+      "devOptional": true,
       "hasInstallScript": true,
       "dependencies": {
         "@prisma/engines": "6.2.1"
@@ -15036,7 +15122,7 @@
       "version": "5.7.3",
       "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.3.tgz",
       "integrity": "sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw==",
-      "dev": true,
+      "devOptional": true,
       "bin": {
         "tsc": "bin/tsc",
         "tsserver": "bin/tsserver"
diff --git a/package.json b/package.json
index c54eee8..06b8566 100644
--- a/package.json
+++ b/package.json
@@ -56,7 +56,7 @@
     "class-variance-authority": "^0.7.1",
     "clsx": "^2.1.1",
     "form-data": "^4.0.2",
-    "framer-motion": "^12.11.0",
+    "framer-motion": "^12.15.0",
     "fs-extra": "^11.3.0",
     "lucide-react": "^0.473.0",
     "motion": "^12.11.1",
diff --git a/src/app/api/recommendations/route.ts b/src/app/api/recommendations/route.ts
new file mode 100644
index 0000000..7343601
--- /dev/null
+++ b/src/app/api/recommendations/route.ts
@@ -0,0 +1,134 @@
+// app/api/recommendations/route.ts
+import { NextRequest, NextResponse } from 'next/server';
+
+// const PYTHON_API_URL = 'https://replay-rythms-recs.onrender.com';
+
+export async function POST(request: NextRequest) {
+  try {
+    const body = await request.json();
+
+    // Validate required fields
+    if (!body.player_id) {
+      return NextResponse.json(
+        { success: false, error: 'Missing required field: player_id' },
+        { status: 400 }
+      );
+    }
+
+    // Forward the request to your Python API
+    const response = await fetch(`${process.env.PYTHON_API_URL}/recommend`, {
+      method: 'POST',
+      headers: {
+        'Content-Type': 'application/json',
+      },
+      body: JSON.stringify({
+        player_id: body.player_id,
+        replay_data: body.replay_data || null,
+        top_n: body.top_n || 5,
+      }),
+    });
+
+    // Handle non-200 responses
+    if (!response.ok) {
+      const errorText = await response.text();
+      console.error(`Python API error (${response.status}):`, errorText);
+
+      return NextResponse.json(
+        {
+          success: false,
+          error: `API request failed: ${response.status} ${response.statusText}`,
+          details: errorText,
+        },
+        { status: response.status }
+      );
+    }
+
+    const data = await response.json();
+
+    // Return the response from Python API
+    return NextResponse.json(data);
+  } catch (error) {
+    console.error('Error proxying to Python API:', error);
+
+    // Handle network errors (like if Render service is sleeping)
+    if (error instanceof Error && error.message.includes('fetch')) {
+      return NextResponse.json(
+        {
+          success: false,
+          error:
+            'Unable to connect to recommendation service. The service may be starting up - please try again in a moment.',
+          technical_error: error.message,
+        },
+        { status: 503 } // Service Unavailable
+      );
+    }
+
+    return NextResponse.json(
+      {
+        success: false,
+        error: 'Internal server error',
+        technical_error:
+          error instanceof Error ? error.message : 'Unknown error',
+      },
+      { status: 500 }
+    );
+  }
+}
+
+export async function GET(request: NextRequest) {
+  try {
+    const { searchParams } = new URL(request.url);
+    const playerId =
+      searchParams.get('player_id') || 'ce45140fcd644755b01660aa2dc6977b';
+    const topN = searchParams.get('top_n') || '5';
+
+    // Forward the request to your Python API test endpoint
+    const response = await fetch(
+      `${process.env.PYTHON_API_URL}/recommend/test?player_id=${playerId}&top_n=${topN}`,
+      {
+        method: 'GET',
+      }
+    );
+
+    if (!response.ok) {
+      const errorText = await response.text();
+      console.error(`Python API error (${response.status}):`, errorText);
+
+      return NextResponse.json(
+        {
+          success: false,
+          error: `API request failed: ${response.status} ${response.statusText}`,
+          details: errorText,
+        },
+        { status: response.status }
+      );
+    }
+
+    const data = await response.json();
+    return NextResponse.json(data);
+  } catch (error) {
+    console.error('Error proxying to Python API (GET):', error);
+
+    if (error instanceof Error && error.message.includes('fetch')) {
+      return NextResponse.json(
+        {
+          success: false,
+          error:
+            'Unable to connect to recommendation service. The service may be starting up - please try again in a moment.',
+          technical_error: error.message,
+        },
+        { status: 503 }
+      );
+    }
+
+    return NextResponse.json(
+      {
+        success: false,
+        error: 'Internal server error',
+        technical_error:
+          error instanceof Error ? error.message : 'Unknown error',
+      },
+      { status: 500 }
+    );
+  }
+}
diff --git a/src/app/api/spotify/auth/route.ts b/src/app/api/spotify/auth/route.ts
new file mode 100644
index 0000000..ff74ef9
--- /dev/null
+++ b/src/app/api/spotify/auth/route.ts
@@ -0,0 +1,50 @@
+// app/api/spotify/auth/route.ts
+import { NextResponse } from 'next/server';
+
+export async function POST() {
+  try {
+    const client_id = process.env.NEXT_PUBLIC_SPOTIFY_CLIENT_ID;
+    const client_secret = process.env.SPOTIFY_CLIENT_SECRET;
+
+    console.log('Spotify Auth - Client ID exists:', !!client_id);
+    console.log('Spotify Auth - Client Secret exists:', !!client_secret);
+
+    if (!client_id || !client_secret) {
+      console.error('Missing Spotify credentials:', {
+        client_id: !!client_id,
+        client_secret: !!client_secret,
+      });
+      return NextResponse.json(
+        { error: 'Spotify credentials not configured' },
+        { status: 500 }
+      );
+    }
+
+    // Get access token using Client Credentials flow (for public data only)
+    const response = await fetch('https://accounts.spotify.com/api/token', {
+      method: 'POST',
+      headers: {
+        'Content-Type': 'application/x-www-form-urlencoded',
+        Authorization: `Basic ${Buffer.from(`${client_id}:${client_secret}`).toString('base64')}`,
+      },
+      body: 'grant_type=client_credentials',
+    });
+
+    if (!response.ok) {
+      throw new Error(`Spotify auth failed: ${response.status}`);
+    }
+
+    const data = await response.json();
+
+    return NextResponse.json({
+      access_token: data.access_token,
+      expires_in: data.expires_in,
+    });
+  } catch (error) {
+    console.error('Spotify auth error:', error);
+    return NextResponse.json(
+      { error: 'Failed to authenticate with Spotify' },
+      { status: 500 }
+    );
+  }
+}
diff --git a/src/app/api/spotify/track/route.ts b/src/app/api/spotify/track/route.ts
new file mode 100644
index 0000000..2707d9e
--- /dev/null
+++ b/src/app/api/spotify/track/route.ts
@@ -0,0 +1,96 @@
+// app/api/spotify/track/route.ts
+import { NextRequest, NextResponse } from 'next/server';
+
+export async function GET(request: NextRequest) {
+  try {
+    const { searchParams } = new URL(request.url);
+    const trackId = searchParams.get('id');
+    const spotifyUrl = searchParams.get('url');
+
+    if (!trackId && !spotifyUrl) {
+      return NextResponse.json(
+        { error: 'Track ID or Spotify URL required' },
+        { status: 400 }
+      );
+    }
+
+    // Extract track ID from Spotify URL if provided
+    let finalTrackId = trackId;
+    if (spotifyUrl && !trackId) {
+      const match = spotifyUrl.match(/track\/([a-zA-Z0-9]+)/);
+      if (match) {
+        finalTrackId = match[1];
+      }
+    }
+
+    if (!finalTrackId) {
+      return NextResponse.json(
+        { error: 'Invalid track ID or URL' },
+        { status: 400 }
+      );
+    }
+
+    // Get Spotify access token - construct the URL properly
+    const baseUrl =
+      process.env.NEXTAUTH_URL ||
+      (typeof window !== 'undefined'
+        ? window.location.origin
+        : 'http://localhost:3000');
+
+    const authResponse = await fetch(`${baseUrl}/api/spotify/auth`, {
+      method: 'POST',
+      headers: {
+        'Content-Type': 'application/json',
+      },
+    });
+
+    if (!authResponse.ok) {
+      const errorText = await authResponse.text();
+      console.error('Auth response error:', errorText);
+      throw new Error(`Failed to get Spotify token: ${authResponse.status}`);
+    }
+
+    const authData = await authResponse.json();
+    const { access_token } = authData;
+
+    // Fetch track data from Spotify
+    const trackResponse = await fetch(
+      `https://api.spotify.com/v1/tracks/${finalTrackId}`,
+      {
+        headers: {
+          Authorization: `Bearer ${access_token}`,
+        },
+      }
+    );
+
+    if (!trackResponse.ok) {
+      if (trackResponse.status === 404) {
+        return NextResponse.json({ error: 'Track not found' }, { status: 404 });
+      }
+      throw new Error(`Spotify API error: ${trackResponse.status}`);
+    }
+
+    const trackData = await trackResponse.json();
+
+    // Return formatted track data
+    return NextResponse.json({
+      id: trackData.id,
+      name: trackData.name,
+      artists: trackData.artists.map((artist: any) => artist.name),
+      album: {
+        name: trackData.album.name,
+        images: trackData.album.images,
+      },
+      preview_url: trackData.preview_url, // 30-second preview (free tier)
+      duration_ms: trackData.duration_ms,
+      external_urls: trackData.external_urls,
+      popularity: trackData.popularity,
+    });
+  } catch (error) {
+    console.error('Spotify track error:', error);
+    return NextResponse.json(
+      { error: 'Failed to fetch track data' },
+      { status: 500 }
+    );
+  }
+}
diff --git a/src/app/replays/[id]/page.tsx b/src/app/replays/[id]/page.tsx
index 5aac75f..62e005e 100644
--- a/src/app/replays/[id]/page.tsx
+++ b/src/app/replays/[id]/page.tsx
@@ -14,6 +14,7 @@ import {
   ChevronRight,
   Loader2,
   Share2,
+  Music,
 } from 'lucide-react';
 import { Progress } from '@/components/ui/progress';
 import ReplayStats from '@/components/ReplayStats';
@@ -22,6 +23,7 @@ import LoadingSpinner from '@/components/LoadingSpinner';
 import { motion } from 'motion/react';
 import VisibilityToggle from '@/components/VisibilityToggle';
 import { Badge } from '@/components/ui/badge';
+import SongRecommendations from '@/components/SongRecommendations';
 
 interface ReplayData {
   id: string;
@@ -405,6 +407,13 @@ export default function ReplayDetailsPage() {
           <TabsTrigger value="players">Player Stats</TabsTrigger>
           <TabsTrigger value="boost">Boost Analysis</TabsTrigger>
           <TabsTrigger value="positioning">Positioning</TabsTrigger>
+          <TabsTrigger
+            value="recommendations"
+            className="flex items-center gap-2"
+          >
+            <Music className="h-4 w-4" />
+            Song Recommendations
+          </TabsTrigger>
         </TabsList>
 
         <TabsContent value="overview">
@@ -422,6 +431,9 @@ export default function ReplayDetailsPage() {
         <TabsContent value="positioning">
           <PlayerStats replayData={replay} statType="positioning" />
         </TabsContent>
+        <TabsContent value="recommendations">
+          <SongRecommendations replayData={replay} />
+        </TabsContent>
       </Tabs>
     </motion.div>
   );
diff --git a/src/components/SongRecommendations.tsx b/src/components/SongRecommendations.tsx
new file mode 100644
index 0000000..636390a
--- /dev/null
+++ b/src/components/SongRecommendations.tsx
@@ -0,0 +1,387 @@
+// components/SongRecommendations.tsx
+'use client';
+
+import { useState } from 'react';
+import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
+import { Button } from '@/components/ui/button';
+import { Badge } from '@/components/ui/badge';
+import { useToast } from '@/components/ui/use-toast';
+import {
+  Music,
+  Loader2,
+  Zap,
+  Users,
+  Trophy,
+  Target,
+  RefreshCw,
+} from 'lucide-react';
+import { motion, AnimatePresence } from 'motion/react';
+import SpotifySongCard from './SpotifySongCard';
+// Replace the interface definitions at the top with this import:
+import { RecommendationResult, Player } from '../types/spotify';
+
+interface SongRecommendationsProps {
+  replayData: any;
+  className?: string;
+}
+
+export default function SongRecommendations({
+  replayData,
+  className,
+}: SongRecommendationsProps) {
+  const [recommendations, setRecommendations] =
+    useState<RecommendationResult | null>(null);
+  const [loading, setLoading] = useState(false);
+  const [selectedPlayer, setSelectedPlayer] = useState<Player | null>(null);
+  const [error, setError] = useState<string>('');
+  const [currentlyPlaying, setCurrentlyPlaying] = useState<number | null>(null);
+  const { toast } = useToast();
+
+  // Extract players from replay data
+  const getPlayersFromReplay = (): Player[] => {
+    const players: Player[] = [];
+
+    if (replayData?.metrics?.teams?.blue?.players) {
+      players.push(...replayData.metrics.teams.blue.players);
+    }
+
+    if (replayData?.metrics?.teams?.orange?.players) {
+      players.push(...replayData.metrics.teams.orange.players);
+    }
+
+    return players;
+  };
+
+  const players = getPlayersFromReplay();
+
+  const generateRecommendations = async (
+    playerId: string,
+    playerName: string
+  ) => {
+    setLoading(true);
+    setError('');
+
+    try {
+      const response = await fetch('/api/recommendations', {
+        method: 'POST',
+        headers: {
+          'Content-Type': 'application/json',
+        },
+        body: JSON.stringify({
+          player_id: playerId,
+          replay_data: replayData?.metrics || null, // Send actual replay data
+          top_n: 5,
+        }),
+      });
+
+      if (!response.ok) {
+        throw new Error(
+          `API request failed: ${response.status} ${response.statusText}`
+        );
+      }
+
+      const result: RecommendationResult = await response.json();
+
+      if (result.success) {
+        console.log('API Response:', result); // Log the entire response for debugging purposes
+        setRecommendations(result);
+        setSelectedPlayer({ id: playerId, name: playerName });
+        toast({
+          title: 'Recommendations Generated!',
+          description: `Found ${result.recommendations.length} songs for ${playerName}`,
+        });
+      } else {
+        throw new Error(result.error || 'Failed to generate recommendations');
+      }
+    } catch (err) {
+      const errorMessage =
+        err instanceof Error ? err.message : 'Unknown error occurred';
+      setError(errorMessage);
+      toast({
+        variant: 'destructive',
+        title: 'Error',
+        description: errorMessage,
+      });
+    } finally {
+      setLoading(false);
+    }
+  };
+
+  const testWithSampleData = async () => {
+    setLoading(true);
+    setError('');
+
+    try {
+      const response = await fetch('/api/recommendations', {
+        method: 'POST',
+        headers: {
+          'Content-Type': 'application/json',
+        },
+        body: JSON.stringify({
+          player_id: 'ce45140fcd644755b01660aa2dc6977b',
+          top_n: 3,
+        }),
+      });
+
+      if (!response.ok) {
+        console.error('API request failed:', response.status); // Log the status code for debugging purposes
+        throw new Error(`API request failed: ${response.status}`);
+      }
+
+      const result: RecommendationResult = await response.json();
+
+      if (result.success) {
+        setRecommendations(result);
+        setSelectedPlayer({ id: 'sample', name: 'Sample Player' });
+        toast({
+          title: 'Sample Recommendations Generated!',
+          description: `Using sample replay data`,
+        });
+      } else {
+        console.error('API request failed:', response.status); // Log the status code for debugging purposes
+        throw new Error(
+          result.error || 'Failed to generate sample recommendations'
+        );
+      }
+    } catch (err) {
+      console.error('API request failed:', err); // Log the status code for debugging purposes
+      const errorMessage =
+        err instanceof Error ? err.message : 'Unknown error occurred';
+      setError(errorMessage);
+      toast({
+        variant: 'destructive',
+        title: 'Error',
+        description: errorMessage,
+      });
+    } finally {
+      setLoading(false);
+    }
+  };
+
+  const getCategoryColor = (category: string) => {
+    switch (category.toLowerCase()) {
+      case 'high':
+      case 'excellent':
+        return 'bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-100';
+      case 'medium':
+      case 'good':
+        return 'bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-100';
+      case 'low':
+      case 'poor':
+        return 'bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-100';
+      default:
+        return 'bg-gray-100 text-gray-800 dark:bg-gray-900 dark:text-gray-100';
+    }
+  };
+
+  const getCategoryIcon = (type: string) => {
+    switch (type) {
+      case 'intensity':
+        return <Zap className="h-4 w-4" />;
+      case 'performance':
+        return <Trophy className="h-4 w-4" />;
+      case 'teamwork':
+        return <Users className="h-4 w-4" />;
+      case 'closeness':
+        return <Target className="h-4 w-4" />;
+      default:
+        return null;
+    }
+  };
+
+  return (
+    <div className={className}>
+      <Card>
+        <CardHeader>
+          <CardTitle className="flex items-center gap-2">
+            <Music className="h-5 w-5" />
+            Song Recommendations
+          </CardTitle>
+        </CardHeader>
+        <CardContent>
+          {/* Player Selection */}
+          {players.length > 0 && (
+            <div className="mb-6">
+              <h3 className="font-medium mb-3">
+                Select a player to generate recommendations:
+              </h3>
+              <div className="grid grid-cols-1 sm:grid-cols-2 gap-2">
+                {players.map((player) => (
+                  <Button
+                    key={player.id}
+                    variant="outline"
+                    onClick={() =>
+                      generateRecommendations(player.id, player.name)
+                    }
+                    disabled={loading}
+                    className="flex items-center justify-between p-3 h-auto"
+                  >
+                    <div className="flex items-center gap-2">
+                      <span className="font-medium">{player.name}</span>
+                      {player.mvp && (
+                        <Badge variant="secondary" className="text-xs">
+                          MVP
+                        </Badge>
+                      )}
+                    </div>
+                    <div className="text-xs text-muted-foreground">
+                      {player.goals || 0}G {player.saves || 0}S{' '}
+                      {player.assists || 0}A
+                    </div>
+                  </Button>
+                ))}
+              </div>
+            </div>
+          )}
+
+          {/* Test Button */}
+          <div className="mb-6">
+            <Button
+              variant="secondary"
+              onClick={testWithSampleData}
+              disabled={loading}
+              className="flex items-center gap-2"
+            >
+              {loading ? (
+                <Loader2 className="h-4 w-4 animate-spin" />
+              ) : (
+                <RefreshCw className="h-4 w-4" />
+              )}
+              Test with Sample Data
+            </Button>
+          </div>
+
+          {/* Loading State */}
+          {loading && (
+            <div className="flex items-center justify-center py-8">
+              <div className="flex items-center gap-2">
+                <Loader2 className="h-5 w-5 animate-spin" />
+                <span>Generating recommendations...</span>
+              </div>
+            </div>
+          )}
+
+          {/* Error State */}
+          {error && (
+            <div className="bg-red-50 border border-red-200 rounded-lg p-4 mb-6">
+              <p className="text-red-800">{error}</p>
+            </div>
+          )}
+
+          {/* Recommendations Display */}
+          <AnimatePresence>
+            {recommendations && (
+              <motion.div
+                initial={{ opacity: 0, y: 20 }}
+                animate={{ opacity: 1, y: 0 }}
+                exit={{ opacity: 0, y: -20 }}
+                transition={{ duration: 0.3 }}
+              >
+                {/* Player Profile */}
+                <div className="mb-6">
+                  <h3 className="font-semibold text-lg mb-3">
+                    Recommendations for {selectedPlayer?.name}
+                  </h3>
+
+                  {/* Performance Categories */}
+                  <div className="grid grid-cols-2 md:grid-cols-4 gap-3 mb-4">
+                    {Object.entries(recommendations.profile.categories).map(
+                      ([key, value]) => (
+                        <div key={key} className="text-center">
+                          <div className="flex items-center justify-center gap-1 mb-1">
+                            {getCategoryIcon(key)}
+                            <span className="text-sm font-medium capitalize">
+                              {key}
+                            </span>
+                          </div>
+                          <Badge
+                            className={getCategoryColor(value)}
+                            variant="secondary"
+                          >
+                            {value}
+                          </Badge>
+                        </div>
+                      )
+                    )}
+                  </div>
+
+                  {/* Metrics */}
+                  <div className="grid grid-cols-1 md:grid-cols-3 gap-4 mb-4 text-sm">
+                    <div className="text-center">
+                      <div className="font-medium">Intensity Score</div>
+                      <div className="text-2xl font-bold text-blue-600">
+                        {recommendations.profile.metrics.intensity_score}
+                      </div>
+                    </div>
+                    <div className="text-center">
+                      <div className="font-medium">Performance Score</div>
+                      <div className="text-2xl font-bold text-green-600">
+                        {recommendations.profile.metrics.performance_score}
+                      </div>
+                    </div>
+                    <div className="text-center">
+                      <div className="font-medium">Teamwork Factor</div>
+                      <div className="text-2xl font-bold text-purple-600">
+                        {recommendations.profile.metrics.teamwork_factor}
+                      </div>
+                    </div>
+                  </div>
+                </div>
+
+                {/* Song Recommendations */}
+                <div>
+                  <h4 className="font-semibold mb-3 flex items-center gap-2">
+                    <Music className="h-4 w-4" />
+                    Recommended Songs
+                    <Badge variant="outline" className="text-xs">
+                      {recommendations.recommendations.length} tracks
+                    </Badge>
+                  </h4>
+
+                  {recommendations.recommendations.length > 0 ? (
+                    <div className="space-y-4">
+                      {recommendations.recommendations.map((song, index) => (
+                        <SpotifySongCard
+                          key={index}
+                          song={song}
+                          index={index}
+                          isPlaying={currentlyPlaying === index}
+                          onPlayStateChange={(isPlaying, songIndex) => {
+                            if (isPlaying) {
+                              setCurrentlyPlaying(songIndex);
+                            } else {
+                              setCurrentlyPlaying(null);
+                            }
+                          }}
+                        />
+                      ))}
+                    </div>
+                  ) : (
+                    <div className="text-center py-8 text-muted-foreground">
+                      <Music className="h-12 w-12 mx-auto mb-2 opacity-50" />
+                      <p>No song recommendations found</p>
+                    </div>
+                  )}
+                </div>
+                {/* Metadata */}
+                {recommendations.metadata && (
+                  <div className="mt-4 text-xs text-muted-foreground">
+                    {recommendations.metadata.used_sample_data && (
+                      <p>⚠️ Using sample data for demonstration</p>
+                    )}
+                    <p>
+                      Generated at:{' '}
+                      {new Date(
+                        recommendations.metadata.processed_at
+                      ).toLocaleString()}
+                    </p>
+                  </div>
+                )}
+              </motion.div>
+            )}
+          </AnimatePresence>
+        </CardContent>
+      </Card>
+    </div>
+  );
+}
diff --git a/src/components/SpotifySongCard.tsx b/src/components/SpotifySongCard.tsx
new file mode 100644
index 0000000..ced56c0
--- /dev/null
+++ b/src/components/SpotifySongCard.tsx
@@ -0,0 +1,274 @@
+// components/SpotifySongCard.tsx
+'use client';
+
+import { useState, useEffect } from 'react';
+import { Card } from '@/components/ui/card';
+import { Button } from '@/components/ui/button';
+import { Badge } from '@/components/ui/badge';
+import { ExternalLink, Music, Maximize2, Minimize2 } from 'lucide-react';
+import { motion } from 'motion/react';
+import { Song } from '../types/spotify';
+
+interface SpotifySongCardProps {
+  song: Song;
+  index: number;
+  isPlaying?: boolean;
+  onPlayStateChange?: (isPlaying: boolean, songIndex: number) => void;
+}
+
+export default function SpotifySongCard({
+  song,
+  index,
+  isPlaying = false,
+  onPlayStateChange,
+}: SpotifySongCardProps) {
+  const [isExpanded, setIsExpanded] = useState(false);
+  const [trackId, setTrackId] = useState<string | null>(null);
+
+  // Extract Spotify track ID from URL
+  useEffect(() => {
+    if (song.source_url) {
+      const match = song.source_url.match(/track\/([a-zA-Z0-9]+)/);
+      if (match) {
+        setTrackId(match[1]);
+      }
+    }
+  }, [song.source_url]);
+
+  // Helper function to normalize energy value
+  const normalizeEnergy = (energy: string | number): string => {
+    if (typeof energy === 'string') {
+      return energy;
+    }
+    if (typeof energy === 'number') {
+      if (energy >= 0.7) return 'High';
+      if (energy >= 0.4) return 'Medium';
+      return 'Low';
+    }
+    return 'N/A';
+  };
+
+  // Helper function to check if a mood/theme matches the criteria
+  const isMatchedCriteria = (item: string): boolean => {
+    const matchedText = (song.matched_criteria_details || [])
+      .join(' ')
+      .toLowerCase();
+    return matchedText.includes(item.toLowerCase());
+  };
+
+  // Helper function to get badge styling based on match status
+  const getBadgeVariant = (item: string, isTheme: boolean = false) => {
+    if (isMatchedCriteria(item)) {
+      return isTheme ? 'default' : 'default'; // Highlighted style for matches
+    }
+    return isTheme ? 'secondary' : 'outline'; // Normal style for non-matches
+  };
+
+  const getBadgeClassName = (item: string, isTheme: boolean = false) => {
+    if (isMatchedCriteria(item)) {
+      return isTheme
+        ? 'text-xs bg-gradient-to-r from-purple-500 to-pink-500 text-white border-0 shadow-md hover:shadow-lg transition-all duration-200'
+        : 'text-xs bg-gradient-to-r from-green-500 to-emerald-500 text-white border-0 shadow-md hover:shadow-lg transition-all duration-200';
+    }
+    return 'text-xs';
+  };
+
+  const toggleExpanded = () => {
+    setIsExpanded(!isExpanded);
+    // Notify parent about play state when expanding
+    if (!isExpanded && onPlayStateChange) {
+      onPlayStateChange(true, index);
+    }
+  };
+
+  // Also update your getSpotifyEmbedUrl function to force dark theme:
+  const getSpotifyEmbedUrl = (trackId: string, compact: boolean = true) => {
+    const baseUrl = 'https://open.spotify.com/embed/track/';
+    const params = new URLSearchParams({
+      utm_source: 'generator',
+      theme: '0', // Force dark theme
+    });
+
+    return `${baseUrl}${trackId}?${params.toString()}`;
+  };
+
+  return (
+    <motion.div
+      initial={{ opacity: 0, x: -20 }}
+      animate={{ opacity: 1, x: 0 }}
+      transition={{ delay: index * 0.1 }}
+      className="group"
+    >
+      <Card
+        className={`transition-all duration-300 hover:shadow-lg ${
+          isPlaying ? 'ring-2 ring-green-500 shadow-lg' : ''
+        }`}
+      >
+        <div className="p-4">
+          {/* Song Info Header */}
+          <div className="flex justify-between items-start mb-3">
+            <div className="min-w-0 flex-grow">
+              <h5 className="font-semibold truncate">{song.title}</h5>
+              <p className="text-muted-foreground text-sm truncate">
+                by {song.artist}
+              </p>
+            </div>
+
+            <div className="text-right flex-shrink-0 ml-4">
+              <div className="text-sm font-medium">
+                Match: {song.match_score}%
+              </div>
+              <div className="text-xs text-muted-foreground">
+                {song.bpm} BPM • {normalizeEnergy(song.energy)}
+              </div>
+            </div>
+          </div>
+
+          {/* Single Animated Spotify Player with Border Fix */}
+          {trackId && (
+            <motion.div
+              className="mb-3 overflow-hidden rounded-xl bg-gray-900 dark:bg-gray-800 shadow-lg"
+              animate={{
+                height: isExpanded ? 352 : 152,
+              }}
+              transition={{
+                duration: 0.4,
+                ease: 'easeInOut',
+              }}
+            >
+              <iframe
+                src={getSpotifyEmbedUrl(trackId, !isExpanded)}
+                width="100%"
+                height={isExpanded ? 352 : 152}
+                frameBorder="0"
+                allowFullScreen
+                allow="autoplay; clipboard-write; encrypted-media; fullscreen; picture-in-picture"
+                loading="lazy"
+                className="block border-none bg-transparent"
+                style={{
+                  borderRadius: '0.5rem',
+                  border: 'none',
+                  background: 'transparent',
+                }}
+                key={`player-${trackId}-${isExpanded}`} // Force reload when size changes
+              />
+            </motion.div>
+          )}
+          {/* No Spotify URL Fallback */}
+          {!trackId && (
+            <div className="mb-3 p-4 bg-gray-100 dark:bg-gray-800 rounded-lg text-center">
+              <Music className="h-8 w-8 mx-auto mb-2 text-gray-400" />
+              <p className="text-sm text-gray-600 dark:text-gray-300">
+                No Spotify preview available
+              </p>
+            </div>
+          )}
+          {/* Enhanced Moods and Themes */}
+          <div className="flex flex-wrap gap-1 mb-3">
+            {/* Moods */}
+            {(song.moods || []).slice(0, 4).map((mood, idx) => {
+              const isMatched = (song.matched_criteria_details || [])
+                .join(' ')
+                .toLowerCase()
+                .includes(mood.toLowerCase());
+
+              return (
+                <Badge
+                  key={`mood-${idx}`}
+                  variant={isMatched ? 'default' : 'outline'}
+                  className={`text-xs ${isMatched ? 'bg-green-600 hover:bg-green-700 text-white border-green-600' : ''}`}
+                >
+                  {mood}
+                  {isMatched && <span className="ml-1">✓</span>}
+                </Badge>
+              );
+            })}
+
+            {/* Themes */}
+            {(song.themes || []).slice(0, 3).map((theme, idx) => {
+              const isMatched = (song.matched_criteria_details || [])
+                .join(' ')
+                .toLowerCase()
+                .includes(theme.toLowerCase());
+
+              return (
+                <Badge
+                  key={`theme-${idx}`}
+                  variant={isMatched ? 'default' : 'secondary'}
+                  className={`text-xs ${isMatched ? 'bg-blue-600 hover:bg-blue-700 text-white border-blue-600' : ''}`}
+                >
+                  {theme}
+                  {isMatched && <span className="ml-1">★</span>}
+                </Badge>
+              );
+            })}
+          </div>
+          {/* Match Criteria */}
+          {(song.matched_criteria_details || []).length > 0 && (
+            <div className="text-xs text-muted-foreground mb-3">
+              Matched: {song.matched_criteria_details.slice(0, 2).join(', ')}
+            </div>
+          )}
+          {/* Actions */}
+          <div className="flex justify-between items-center">
+            <div className="flex gap-2">
+              {trackId && (
+                <Button
+                  size="sm"
+                  variant="outline"
+                  onClick={toggleExpanded}
+                  className="flex items-center gap-1"
+                >
+                  {isExpanded ? (
+                    <>
+                      <Minimize2 className="h-3 w-3" />
+                      Compact
+                    </>
+                  ) : (
+                    <>
+                      <Maximize2 className="h-3 w-3" />
+                      Full Player
+                    </>
+                  )}
+                </Button>
+              )}
+
+              {song.source_url && (
+                <Button variant="ghost" size="sm" asChild>
+                  <a
+                    href={song.source_url}
+                    target="_blank"
+                    rel="noopener noreferrer"
+                    className="flex items-center gap-1"
+                  >
+                    <ExternalLink className="h-3 w-3" />
+                    Open Spotify
+                  </a>
+                </Button>
+              )}
+            </div>
+
+            {/* Song Quality Indicator */}
+            <div className="flex items-center gap-1">
+              {song.match_score >= 80 && (
+                <Badge variant="default" className="text-xs bg-green-500">
+                  Perfect Match
+                </Badge>
+              )}
+              {song.match_score >= 60 && song.match_score < 80 && (
+                <Badge variant="default" className="text-xs bg-yellow-500">
+                  Good Match
+                </Badge>
+              )}
+              {song.match_score < 60 && (
+                <Badge variant="outline" className="text-xs">
+                  Fair Match
+                </Badge>
+              )}
+            </div>
+          </div>
+        </div>
+      </Card>
+    </motion.div>
+  );
+}
diff --git a/src/env.mjs b/src/env.mjs
index 2d792e3..8d71453 100644
--- a/src/env.mjs
+++ b/src/env.mjs
@@ -1,6 +1,7 @@
 import { createEnv } from '@t3-oss/env-nextjs';
 import { z } from 'zod';
-
+// TODO: THIS IS OLD, NOT USED. UPDATE THE ENVIRONMENT VARIABLES TO MAKE THIS USEFUL
+// IT IS MOST PROBABLY A VALIDATION LAYER FOR THE ENVIRONMENT VARIABLES
 export const env = createEnv({
   server: {
     DATABASE_URL: z.string().min(1),
diff --git a/src/types/spotify.ts b/src/types/spotify.ts
new file mode 100644
index 0000000..aa38d2a
--- /dev/null
+++ b/src/types/spotify.ts
@@ -0,0 +1,66 @@
+// types/spotify.ts
+export interface Song {
+  title: string;
+  artist: string;
+  match_score: number;
+  bpm: number;
+  energy: string | number; // Allow both string ("High") and number (0.8)
+  moods: string[];
+  themes: string[];
+  matched_criteria_details: string[];
+  source_url?: string;
+}
+
+export interface RecommendationProfile {
+  player_name: string;
+  metrics: {
+    intensity_score: number;
+    performance_score: number;
+    teamwork_factor: number;
+    game_outcome: any;
+  };
+  categories: {
+    intensity: string;
+    performance: string;
+    teamwork: string;
+    closeness: string;
+  };
+  desired_song_profile: any;
+}
+
+export interface RecommendationResult {
+  success: boolean;
+  profile: RecommendationProfile;
+  recommendations: Song[];
+  player_id: string;
+  metadata: {
+    used_sample_data: boolean;
+    timestamp: string;
+    request_id: string;
+    processed_at: string;
+  };
+  error?: string;
+}
+
+export interface Player {
+  id: string;
+  name: string;
+  goals?: number;
+  saves?: number;
+  assists?: number;
+  mvp?: boolean;
+}
+
+export interface SpotifyTrackData {
+  id: string;
+  name: string;
+  artists: string[];
+  album: {
+    name: string;
+    images: Array<{ url: string; height: number; width: number }>;
+  };
+  preview_url: string | null;
+  duration_ms: number;
+  external_urls: { spotify: string };
+  popularity: number;
+}


Reviews:
user: login: gemini-code-assist[bot]
body: Hello @rishabh-hub, I'm Gemini Code Assist[^1]! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

## Summary of Changes
Hello team,

Gemini here, providing a summary of this pull request titled "Feature/music recs".

This PR introduces a significant new feature: **Music Recommendations** based on replay data. The core functionality involves integrating with a custom-built and hosted Python API that generates song recommendations. Additionally, it adds the capability to embed Spotify iframes directly within the application to allow users to listen to recommended songs.

The changes span across adding new API routes to handle communication with the external recommendation service and Spotify, updating dependencies, and implementing new frontend components to display the recommendations and the embedded Spotify player on the replay details page.

### Highlights
* **Music Recommendation API Integration**: New Next.js API routes (`/api/recommendations`) are added to act as a proxy to a custom Python API hosted externally. This route handles both POST requests (sending replay data to get recommendations) and GET requests (for testing with sample data), including basic error handling for API communication.
* **Spotify API Integration**: New Next.js API routes (`/api/spotify/auth` and `/api/spotify/track`) are implemented to handle Spotify authentication (using the Client Credentials flow for public data) and fetching specific track details based on ID or URL. This allows the frontend to get necessary information for embedding and linking.
* **New 'Song Recommendations' Tab**: A new tab is added to the replay details page (`src/app/replays/[id]/page.tsx`) specifically for displaying song recommendations. This tab uses a new `SongRecommendations` component.
* **Frontend Components for Recommendations**: Two new React components (`SongRecommendations.tsx` and `SpotifySongCard.tsx`) are introduced. `SongRecommendations` fetches and displays recommendations for selected players from the replay, including player profile metrics and categories. `SpotifySongCard` renders individual song recommendations, including details, matched criteria, and an interactive Spotify iframe embed.
* **Dependency Updates and Configuration**: The PR includes updates to `package.json` and `package-lock.json`, notably updating `framer-motion` and adding several testing/utility dependencies. The `.env.example` file is updated to include necessary environment variables for Spotify API credentials and the Python API URL.

### Changelog
<details>
<summary>Click here to see the changelog</summary>

* **.env.example**
  * Added placeholders for `NEXT_PUBLIC_SPOTIFY_CLIENT_ID`, `SPOTIFY_CLIENT_SECRET`, and `PYTHON_API_URL`.
* **.vscode/settings.json**
  * Added VS Code workbench color customizations (activityBar, titleBar).
* **package-lock.json**
  * Updated `framer-motion` version from `^12.11.0` to `^12.15.0`.
  * Changed `dev: true` to `devOptional: true` for several `@prisma` and `@playwright` related dependencies.
  * Added entries for `@testing-library/dom`, `@types/aria-query`, `dom-accessibility-api`, `lz-string`, `pretty-format` and their sub-dependencies.
* **package.json**
  * Updated `framer-motion` dependency version to `^12.15.0`.
* **src/app/api/recommendations/route.ts**
  * Added a new API route to proxy POST requests (with replay data) and GET requests (for testing) to the external Python recommendation API.
  * Includes validation for required `player_id` in POST requests.
  * Implements error handling for failed API requests and network issues (like service startup delays).
* **src/app/api/spotify/auth/route.ts**
  * Added a new API route to handle Spotify Client Credentials flow authentication.
  * Fetches an access token using `NEXT_PUBLIC_SPOTIFY_CLIENT_ID` and `SPOTIFY_CLIENT_SECRET`.
* **src/app/api/spotify/track/route.ts**
  * Added a new API route to fetch Spotify track details.
  * Accepts `id` or `url` query parameters.
  * Calls the internal `/api/spotify/auth` route to get an access token.
  * Fetches track data from the Spotify API and returns formatted information.
* **src/app/replays/[id]/page.tsx**
  * Imported the `Music` icon from `lucide-react`.
  * Imported the new `SongRecommendations` component.
  * Added a new `TabsTrigger` for 'Song Recommendations' with a music icon.
  * Added a new `TabsContent` section to render the `SongRecommendations` component, passing the `replayData`.
* **src/components/SongRecommendations.tsx**
  * Added a new client-side React component to display song recommendations.
  * Provides buttons to select a player from the replay or use sample data.
  * Calls the `/api/recommendations` route to fetch data.
  * Displays loading and error states.
  * Shows player performance profile metrics and categories.
  * Renders a list of recommended songs using `SpotifySongCard`.
  * Manages the state for recommendations, loading, selected player, errors, and currently playing song index.
* **src/components/SpotifySongCard.tsx**
  * Added a new client-side React component to display individual song details.
  * Extracts Spotify track ID from the source URL.
  * Displays song title, artist, match score, BPM, energy, moods, and themes.
  * Highlights matched criteria using different badge styles.
  * Embeds a Spotify iframe player with toggleable compact/full views.
  * Provides a link to open the song on Spotify.
  * Includes basic quality indicators based on match score.
* **src/env.mjs**
  * Added a comment indicating the file is old and the environment variable validation needs updating.
* **src/types/spotify.ts**
  * Added a new file defining TypeScript interfaces for `Song`, `RecommendationProfile`, `RecommendationResult`, `Player`, and `SpotifyTrackData`.

</details>

<details>
<summary><b>Using Gemini Code Assist</b></summary>
<br>

The full guide for Gemini Code Assist can be found on our [documentation page](https://developers.google.com/gemini-code-assist/docs/review-github-code), here are some quick tips.

<b>Invoking Gemini</b>

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either `/gemini <command>` or `@gemini-code-assist <command>`. Below is a summary of the supported commands.

Feature | Command | Description
--- | --- | ---
Code Review | `/gemini review` | Performs a code review for the current pull request in its current state.
Pull Request Summary | `/gemini summary` | Provides a summary of the current pull request in its current state.
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments.
Help | `/gemini help` | Displays a list of available commands.

<b>Customization</b>

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a `.gemini/` folder in the base of the repository. Detailed instructions can be found [here](https://developers.google.com/gemini-code-assist/docs/customize-gemini-behavior-github).

<b>Limitations & Feedback</b>

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with :thumbsup: and :thumbsdown: on @gemini-code-assist comments to provide feedback.
</details>


<b>You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the [Gemini Code Assist IDE Extension](https://cloud.google.com/products/gemini/code-assist).</b>


[^1]: Review the [Privacy Notices](https://policies.google.com/privacy), [Generative AI Prohibited Use Policy](https://policies.google.com/terms/generative-ai/use-policy), [Terms of Service](https://policies.google.com/terms), and learn how to configure Gemini Code Assist in GitHub [here](https://developers.google.com/gemini-code-assist/docs/review-github-code). Gemini can make mistakes, so double check it and [use code with caution](https://support.google.com/legal/answer/13505487).

---

> Replay data flows,
> Music recommendations bloom,
> A new tab appears.


state: COMMENTED
author_association: NONE
submitted_at: 2025-05-30T11:47:13Z
user: login: gemini-code-assist[bot]
body: ## Code Review
This pull request introduces a music recommendation feature, integrating a custom Python API and Spotify for song embedding. The changes include new API routes, React components, and updates to environment variables and type definitions. Overall, the feature implementation is comprehensive and well-structured. I've provided some suggestions for improvement, primarily around environment variable management and type safety.

### Summary of Findings
* **Environment Variable Validation**: The `src/env.mjs` file, responsible for environment variable validation, has a TODO indicating it's outdated. New environment variables introduced in this PR are not included in its validation schema. This is critical for ensuring the application has all necessary configurations at runtime.
* **Type Safety**: Several instances of `any` type are used for props (e.g., `replayData` in `SongRecommendations.tsx`) and within type definitions (e.g., `game_outcome`, `desired_song_profile` in `src/types/spotify.ts`, and for Spotify API response mapping). Using more specific types would improve code robustness and maintainability.
* **Base URL Construction in API Route**: The method for constructing the `baseUrl` in `src/app/api/spotify/track/route.ts` for server-side internal API calls could be more reliable, especially for production environments.
* **Default Value Behavior**: In `src/app/api/recommendations/route.ts`, the logic `top_n: body.top_n || 5` might incorrectly default `top_n` to 5 if `body.top_n` is `0` and `0` is a meaningful input. This was not commented on due to review settings.
* **Debugging Logs**: Several `console.log` and `console.error` statements are present, likely for debugging. These should be reviewed and potentially removed or made conditional for production builds. This was not commented on due to review settings.
* **Component Styling Logic**: In `src/components/SpotifySongCard.tsx`, the badge styling logic using both `variant` and `className` for `isMatched` states could potentially be simplified. This was not commented on due to review settings.

### Merge Readiness
The pull request introduces an exciting new feature and is largely well-implemented. However, due to the high-severity issue regarding environment variable validation in `src/env.mjs` and several medium-severity issues related to type safety, I recommend addressing these concerns before merging. Ensuring robust configuration and type safety will significantly benefit the long-term health of the codebase. I am not authorized to approve pull requests, so please ensure these changes are reviewed and approved by the appropriate maintainers after addressing the feedback.
state: CHANGES_REQUESTED
author_association: NONE
submitted_at: 2025-05-30T11:49:17Z
user: login: coderabbitai[bot]
body: **Actionable comments posted: 7**

<details>
<summary>🧹 Nitpick comments (7)</summary><blockquote>

<details>
<summary>.vscode/settings.json (1)</summary><blockquote>

`1-7`: **Consider removing VS Code workspace settings from repository.**

The `.vscode/settings.json` file contains personal editor preferences that typically shouldn't be committed to the repository as they override individual developer settings and preferences.



Consider either:
1. Removing this file from the repository
2. Renaming it to `.vscode/settings.json.example` for optional use
3. Adding `.vscode/settings.json` to `.gitignore` and providing documentation about recommended settings

If the custom colors are important for the project's development workflow, document them in the README instead.

</blockquote></details>
<details>
<summary>src/app/api/spotify/auth/route.ts (3)</summary><blockquote>

`6-7`: **Consider security implications of environment variable naming.**

The use of `NEXT_PUBLIC_` prefix for the Spotify client ID makes it accessible on the client-side, which may not be necessary for a server-side authentication flow. Consider using `SPOTIFY_CLIENT_ID` instead unless the client ID specifically needs to be public.



```diff
-    const client_id = process.env.NEXT_PUBLIC_SPOTIFY_CLIENT_ID;
+    const client_id = process.env.SPOTIFY_CLIENT_ID;
```

---

`9-10`: **Avoid logging sensitive credential existence in production.**

While logging credential existence can be helpful for debugging, it could provide information to potential attackers about the application's configuration. Consider using a debug-only logging approach.



```diff
-    console.log('Spotify Auth - Client ID exists:', !!client_id);
-    console.log('Spotify Auth - Client Secret exists:', !!client_secret);
+    if (process.env.NODE_ENV === 'development') {
+      console.log('Spotify Auth - Client ID exists:', !!client_id);
+      console.log('Spotify Auth - Client Secret exists:', !!client_secret);
+    }
```

---

`33-35`: **Enhance error handling with response details.**

Consider including the response status text and any error details from Spotify for better debugging capabilities.



```diff
-    if (!response.ok) {
-      throw new Error(`Spotify auth failed: ${response.status}`);
-    }
+    if (!response.ok) {
+      const errorText = await response.text();
+      throw new Error(`Spotify auth failed: ${response.status} ${response.statusText} - ${errorText}`);
+    }
```

</blockquote></details>
<details>
<summary>src/app/api/spotify/track/route.ts (1)</summary><blockquote>

`79-79`: **Add type safety for artist mapping.**

The `any` type for the artist parameter reduces type safety. Consider using a proper interface or inline type.



```diff
-      artists: trackData.artists.map((artist: any) => artist.name),
+      artists: trackData.artists.map((artist: { name: string }) => artist.name),
```

</blockquote></details>
<details>
<summary>src/app/api/recommendations/route.ts (2)</summary><blockquote>

`4-4`: **Remove commented hardcoded URL.**

The commented hardcoded URL should be removed to avoid confusion and potential security risks if accidentally uncommented.



```diff
-// const PYTHON_API_URL = 'https://replay-rythms-recs.onrender.com';
```

---

`78-134`: **Consider refactoring to reduce code duplication.**

The GET and POST methods share significant error handling logic. Consider extracting common functionality into helper functions.



Create a helper function for common error handling:

```typescript
function handleApiError(error: unknown, context: string) {
  console.error(`Error proxying to Python API (${context}):`, error);
  
  if (error instanceof Error && error.message.includes('fetch')) {
    return NextResponse.json(
      {
        success: false,
        error: 'Unable to connect to recommendation service. The service may be starting up - please try again in a moment.',
        technical_error: error.message,
      },
      { status: 503 }
    );
  }

  return NextResponse.json(
    {
      success: false,
      error: 'Internal server error',
      technical_error: error instanceof Error ? error.message : 'Unknown error',
    },
    { status: 500 }
  );
}
```

</blockquote></details>

</blockquote></details>

<details>
<summary>📜 Review details</summary>

**Configuration used: CodeRabbit UI**
**Review profile: CHILL**
**Plan: Pro**


<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 04ba593c61931ba59ea96f9139b1158946e6c6bc and 04290b1f83d0e59ae60b72ecd3c43d3c9867d8f5.

</details>

<details>
<summary>⛔ Files ignored due to path filters (1)</summary>

* `package-lock.json` is excluded by `!**/package-lock.json`

</details>

<details>
<summary>📒 Files selected for processing (11)</summary>

* `.env.example` (1 hunks)
* `.vscode/settings.json` (1 hunks)
* `package.json` (1 hunks)
* `src/app/api/recommendations/route.ts` (1 hunks)
* `src/app/api/spotify/auth/route.ts` (1 hunks)
* `src/app/api/spotify/track/route.ts` (1 hunks)
* `src/app/replays/[id]/page.tsx` (4 hunks)
* `src/components/SongRecommendations.tsx` (1 hunks)
* `src/components/SpotifySongCard.tsx` (1 hunks)
* `src/env.mjs` (1 hunks)
* `src/types/spotify.ts` (1 hunks)

</details>

<details>
<summary>🧰 Additional context used</summary>

<details>
<summary>🧬 Code Graph Analysis (2)</summary>

<details>
<summary>src/app/api/spotify/auth/route.ts (1)</summary><blockquote>

<details>
<summary>src/app/api/recommendations/route.ts (1)</summary>

* `POST` (6-76)

</details>

</blockquote></details>
<details>
<summary>src/components/SpotifySongCard.tsx (4)</summary><blockquote>

<details>
<summary>src/types/spotify.ts (1)</summary>

* `Song` (2-12)

</details>
<details>
<summary>src/components/ui/card.tsx (1)</summary>

* `Card` (80-80)

</details>
<details>
<summary>src/components/ui/badge.tsx (1)</summary>

* `Badge` (36-36)

</details>
<details>
<summary>src/components/ui/button.tsx (1)</summary>

* `Button` (56-56)

</details>

</blockquote></details>

</details><details>
<summary>🪛 GitHub Actions: Code check</summary>

<details>
<summary>src/components/SpotifySongCard.tsx</summary>

[warning] 60-85: ESLint: Multiple variables assigned but never used: 'getBadgeVariant', 'getBadgeClassName', 'compact'. (@typescript-eslint/no-unused-vars)

---

[warning] 110-117: TailwindCSS: Classnames 'flex-grow' and 'flex-shrink-0' should be updated to 'grow' and 'shrink-0' respectively in Tailwind CSS v3! (tailwindcss/migration-from-tailwind-2)

---

[error] 139-139: ESLint: <iframe> elements must have a unique title property. (jsx-a11y/iframe-has-title)

</details>

</details>

</details>

<details>
<summary>🔇 Additional comments (25)</summary><blockquote>

<details>
<summary>package.json (1)</summary>

`59-59`: **LGTM! Dependency update supports new features.**

The framer-motion version update from "^12.11.0" to "^12.15.0" appropriately supports the new animated song recommendation components being introduced.

</details>
<details>
<summary>src/app/replays/[id]/page.tsx (4)</summary>

`17-17`: **LGTM! Clean import addition.**

The Music icon import is properly added and will be used in the new song recommendations tab.

---

`410-416`: **LGTM! Well-structured tab implementation.**

The new song recommendations tab follows the existing pattern with proper icon integration and flex layout for alignment.

---

`434-436`: **LGTM! Consistent TabsContent implementation.**

The TabsContent properly passes the replay data to the SongRecommendations component, following the same pattern as other tabs.

---

`26-26`: <details>
<summary>✅ Verification successful</summary>

**Verify SongRecommendations component exists.**

The import looks correct, but ensure the SongRecommendations component is properly implemented and can handle the replay data structure.

---

🏁 Script executed:

```shell
#!/bin/bash
# Description: Verify SongRecommendations component exists and check its interface

# Check if the SongRecommendations component file exists
fd "SongRecommendations" --type f --extension tsx --extension ts

# Check the component's props interface
ast-grep --pattern 'interface $_ {
  replayData: $_
  $$$
}'

# Check for the component's default export
ast-grep --pattern 'export default function SongRecommendations($_) {
  $$$
}'
```

Length of output: 28991

---



</details>

**SongRecommendations component verified**

The `SongRecommendations` component exists at `src/components/SongRecommendations.tsx`, exports a default function matching the import in `src/app/replays/[id]/page.tsx`, and its props interface (`SongRecommendationsProps`) accepts `replayData` (typed as `any`) alongside an optional `className`. It correctly reads from `replayData.metrics.teams` to extract player data, so the import and usage are valid.

</details>
<details>
<summary>src/app/api/spotify/auth/route.ts (1)</summary>

`23-31`: **LGTM! Proper implementation of Spotify Client Credentials flow.**

The authentication implementation correctly follows the OAuth2 Client Credentials flow with proper encoding of credentials and appropriate headers. The use of `Buffer.from().toString('base64')` for Basic authentication is secure and standard.

</details>
<details>
<summary>src/app/api/spotify/track/route.ts (2)</summary>

`10-15`: **LGTM! Clear parameter validation.**

The validation logic correctly handles both track ID and Spotify URL parameters with appropriate error messages.

---

`75-88`: **LGTM! Comprehensive track data transformation.**

The response structure is well-designed and includes all essential track information for the application's needs, including preview URLs and album artwork.

</details>
<details>
<summary>src/app/api/recommendations/route.ts (1)</summary>

`6-49`: **LGTM! Robust POST implementation with proper error handling.**

The POST method implementation correctly validates required fields, forwards requests to the external API, and handles various error scenarios appropriately. The error response structure is consistent and informative.

</details>
<details>
<summary>src/types/spotify.ts (4)</summary>

`2-12`: **LGTM! Well-designed Song interface with flexible energy typing.**

The Song interface appropriately handles the energy field as both string and number, which accommodates different data sources. The structure captures all necessary song metadata for recommendations.

---

`31-43`: **LGTM! Comprehensive recommendation result structure.**

The RecommendationResult interface provides excellent traceability with metadata fields and proper error handling through the optional error field.

---

`45-52`: **LGTM! Clean Player interface design.**

The Player interface appropriately uses optional fields for statistics while keeping essential identifiers required.

---

`54-66`: **LGTM! Accurate SpotifyTrackData interface.**

The interface correctly models the Spotify Web API response structure with appropriate types for all fields, including the nullable preview_url.

</details>
<details>
<summary>src/components/SpotifySongCard.tsx (7)</summary>

`60-74`: **Unused helper functions trigger lint warnings**

`getBadgeVariant` and `getBadgeClassName` are defined but never used, producing ESLint noise and dead code.

Either delete them or use them where the hard-coded inline logic currently lives (lines 176-204).

```diff
-  const getBadgeVariant = (item: string, isTheme: boolean = false) => {
-    ...
-  };
-
-  const getBadgeClassName = (item: string, isTheme: boolean = false) => {
-    ...
-  };
```
[ suggest_optional_refactor ]

<details>
<summary>🧰 Tools</summary>

<details>
<summary>🪛 GitHub Actions: Code check</summary>

[warning] 60-85: ESLint: Multiple variables assigned but never used: 'getBadgeVariant', 'getBadgeClassName', 'compact'. (@typescript-eslint/no-unused-vars)

</details>

</details>

---

`28-36`: **Regex fails when URL has querystring / locale**

`/track\/([a-zA-Z0-9]+)/` stops at the first non-alphanumeric char, so URLs like  
`https://open.spotify.com/track/1abcDEF?si=123` yield `"1abcDEF?si"` ➜ broken embed.

```diff
-const match = song.source_url.match(/track\/([a-zA-Z0-9]+)/);
+const match = song.source_url.match(/track\/([a-zA-Z0-9]+)(?=[?&/]|$)/);
```
[ suggest_essential_refactor ]

---

`85-93`: **Parameter `compact` is unused → ESLint “no-unused-vars”**

You added `compact` but never switch the embed layout with it.  
Either incorporate it (`&height=...`) or remove it:

```diff
-const getSpotifyEmbedUrl = (trackId: string, compact: boolean = true) => {
+const getSpotifyEmbedUrl = (trackId: string) => {
```
[ suggest_optional_refactor ]

---

`139-154`: **Iframe accessibility & security**

1. ESLint error: iframe requires a unique `title`.
2. Consider `sandbox` to restrict capabilities.

```diff
-<iframe
+<iframe
+  title={`spotify-track-${trackId}`}
   src={getSpotifyEmbedUrl(trackId, !isExpanded)}
   ...
-  allow="autoplay; clipboard-write; encrypted-media; fullscreen; picture-in-picture"
+  sandbox="allow-same-origin allow-popups allow-scripts"
+  allow="autoplay; clipboard-write; encrypted-media; fullscreen; picture-in-picture"
```
[ raise_critical_issue ]

<details>
<summary>🧰 Tools</summary>

<details>
<summary>🪛 GitHub Actions: Code check</summary>

[error] 139-139: ESLint: <iframe> elements must have a unique title property. (jsx-a11y/iframe-has-title)

</details>

</details>

---

`110-117`: **Tailwind v3 class name migration**

`flex-grow` ⟶ `grow`, `flex-shrink-0` ⟶ `shrink-0`.

```diff
-<div className="min-w-0 flex-grow">
+<div className="min-w-0 grow">
 ...
-<div className="text-right flex-shrink-0 ml-4">
+<div className="text-right shrink-0 ml-4">
```
[ suggest_nitpick ]

<details>
<summary>🧰 Tools</summary>

<details>
<summary>🪛 GitHub Actions: Code check</summary>

[warning] 110-117: TailwindCSS: Classnames 'flex-grow' and 'flex-shrink-0' should be updated to 'grow' and 'shrink-0' respectively in Tailwind CSS v3! (tailwindcss/migration-from-tailwind-2)

</details>

</details>

---

`176-204`: **Duplicate match-detection logic**

Both mood and theme rendering duplicate five lines of `isMatched` logic.  Extract a helper to avoid drift:

```diff
-const isItemMatched = (item: string) =>
-  (song.matched_criteria_details || []).join(' ').toLowerCase().includes(item.toLowerCase());
```

Then reuse in both `.map` calls.
[ suggest_optional_refactor ]

---

`253-267`: **Badge colouring logic can be simplified & centralised**

Three mutually exclusive conditions → use a small helper:

```typescript
const matchQuality = (score: number) =>
  score >= 80 ? ['Perfect', 'green'] :
  score >= 60 ? ['Good', 'yellow'] :
  ['Fair', 'slate'];
```

This removes repetition and eases future tuning.
[ suggest_nitpick ]

</details>
<details>
<summary>src/components/SongRecommendations.tsx (5)</summary>

`57-108`: **AbortController to prevent race conditions**

If a user clicks two players quickly, the slower request can overwrite the newer results.  Wrap each fetch with an `AbortController` and cancel the previous one when `generateRecommendations` is re-invoked.

[ suggest_essential_refactor ]

---

`114-159`: **Duplicate request logic in `testWithSampleData`**

`testWithSampleData` duplicates almost all error-handling from `generateRecommendations`.  Extract a shared `fetchRecommendations(body)` helper to reduce maintenance surface.

[ suggest_optional_refactor ]

---

`209-233`: **`index` used as React key**

Using the array index as a key harms list reconciliation when recommendations update.  Prefer a stable identifier (e.g., Spotify track ID).

```diff
- key={index}
+ key={song.source_url ?? index}
```
[ suggest_nitpick ]

---

`161-175`: **Category colour map mixes semantic & visual classes**

Storing full `bg-… text-…` strings couples data to Tailwind classes.  Consider returning just a semantic token (`"good" | "poor"`) and mapping to classes in the JSX to improve portability and theming.

[ offer_architecture_advice ]

---

`193-386`: **Component is becoming monolithic (~350 lines)**

`SongRecommendations` handles data fetching, error reporting, player profile display, and song list rendering.  Splitting it into smaller components (e.g., `PlayerSelector`, `ProfileSummary`, `RecommendationsList`) will improve readability and testability.

[ suggest_optional_refactor ]

</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->
state: COMMENTED
author_association: NONE
submitted_at: 2025-05-30T11:51:47Z

Review comments:
diff_hunk: @@ -1,6 +1,7 @@
 import { createEnv } from '@t3-oss/env-nextjs';
 import { z } from 'zod';
-
+// TODO: THIS IS OLD, NOT USED. UPDATE THE ENVIRONMENT VARIABLES TO MAKE THIS USEFUL
+// IT IS MOST PROBABLY A VALIDATION LAYER FOR THE ENVIRONMENT VARIABLES
path: src/env.mjs
user: login: gemini-code-assist[bot]
body: ![high](https://img.shields.io/badge/priority-high-orange)

This TODO comment indicates that the environment variable validation setup with `createEnv` might be outdated. Given that new environment variables like `NEXT_PUBLIC_SPOTIFY_CLIENT_ID`, `SPOTIFY_CLIENT_SECRET`, and `PYTHON_API_URL` have been added in `.env.example`, it's important to ensure they are also defined and validated here in `env.mjs`.

Could you update this file to include schemas for the new environment variables and confirm that this validation layer is active and correctly used throughout the application? This will help catch configuration errors early.
created_at: 2025-05-30T11:49:16Z
author_association: NONE
diff_hunk: @@ -0,0 +1,96 @@
+// app/api/spotify/track/route.ts
+import { NextRequest, NextResponse } from 'next/server';
+
+export async function GET(request: NextRequest) {
+  try {
+    const { searchParams } = new URL(request.url);
+    const trackId = searchParams.get('id');
+    const spotifyUrl = searchParams.get('url');
+
+    if (!trackId && !spotifyUrl) {
+      return NextResponse.json(
+        { error: 'Track ID or Spotify URL required' },
+        { status: 400 }
+      );
+    }
+
+    // Extract track ID from Spotify URL if provided
+    let finalTrackId = trackId;
+    if (spotifyUrl && !trackId) {
+      const match = spotifyUrl.match(/track\/([a-zA-Z0-9]+)/);
+      if (match) {
+        finalTrackId = match[1];
+      }
+    }
+
+    if (!finalTrackId) {
+      return NextResponse.json(
+        { error: 'Invalid track ID or URL' },
+        { status: 400 }
+      );
+    }
+
+    // Get Spotify access token - construct the URL properly
+    const baseUrl =
+      process.env.NEXTAUTH_URL ||
+      (typeof window !== 'undefined'
+        ? window.location.origin
+        : 'http://localhost:3000');
path: src/app/api/spotify/track/route.ts
user: login: gemini-code-assist[bot]
body: ![medium](https://img.shields.io/badge/priority-medium-yellow)

The `baseUrl` construction for server-side API calls could be more robust. Currently, `typeof window !== 'undefined'` will always be false in an API route (server-side), meaning the fallback `window.location.origin` is never used, and it defaults to `'http://localhost:3000'` if `process.env.NEXTAUTH_URL` is not set.

Consider a more reliable way to determine the application's base URL on the server, especially for production environments. You might want to use `process.env.VERCEL_URL` (if deploying on Vercel and it's available at build/runtime) or a general `APP_URL` environment variable that you set for your deployment.

What are your thoughts on using a dedicated `APP_URL` environment variable for constructing internal API call URLs?

```typescript
    const appUrl = process.env.APP_URL || process.env.NEXTAUTH_URL || (process.env.VERCEL_URL ? `https://${process.env.VERCEL_URL}` : 'http://localhost:3000');

    const authResponse = await fetch(`${appUrl}/api/spotify/auth`, {
```
created_at: 2025-05-30T11:49:16Z
author_association: NONE
diff_hunk: @@ -0,0 +1,96 @@
+// app/api/spotify/track/route.ts
+import { NextRequest, NextResponse } from 'next/server';
+
+export async function GET(request: NextRequest) {
+  try {
+    const { searchParams } = new URL(request.url);
+    const trackId = searchParams.get('id');
+    const spotifyUrl = searchParams.get('url');
+
+    if (!trackId && !spotifyUrl) {
+      return NextResponse.json(
+        { error: 'Track ID or Spotify URL required' },
+        { status: 400 }
+      );
+    }
+
+    // Extract track ID from Spotify URL if provided
+    let finalTrackId = trackId;
+    if (spotifyUrl && !trackId) {
+      const match = spotifyUrl.match(/track\/([a-zA-Z0-9]+)/);
+      if (match) {
+        finalTrackId = match[1];
+      }
+    }
+
+    if (!finalTrackId) {
+      return NextResponse.json(
+        { error: 'Invalid track ID or URL' },
+        { status: 400 }
+      );
+    }
+
+    // Get Spotify access token - construct the URL properly
+    const baseUrl =
+      process.env.NEXTAUTH_URL ||
+      (typeof window !== 'undefined'
+        ? window.location.origin
+        : 'http://localhost:3000');
+
+    const authResponse = await fetch(`${baseUrl}/api/spotify/auth`, {
+      method: 'POST',
+      headers: {
+        'Content-Type': 'application/json',
+      },
+    });
+
+    if (!authResponse.ok) {
+      const errorText = await authResponse.text();
+      console.error('Auth response error:', errorText);
+      throw new Error(`Failed to get Spotify token: ${authResponse.status}`);
+    }
+
+    const authData = await authResponse.json();
+    const { access_token } = authData;
+
+    // Fetch track data from Spotify
+    const trackResponse = await fetch(
+      `https://api.spotify.com/v1/tracks/${finalTrackId}`,
+      {
+        headers: {
+          Authorization: `Bearer ${access_token}`,
+        },
+      }
+    );
+
+    if (!trackResponse.ok) {
+      if (trackResponse.status === 404) {
+        return NextResponse.json({ error: 'Track not found' }, { status: 404 });
+      }
+      throw new Error(`Spotify API error: ${trackResponse.status}`);
+    }
+
+    const trackData = await trackResponse.json();
+
+    // Return formatted track data
+    return NextResponse.json({
+      id: trackData.id,
+      name: trackData.name,
+      artists: trackData.artists.map((artist: any) => artist.name),
path: src/app/api/spotify/track/route.ts
user: login: gemini-code-assist[bot]
body: ![medium](https://img.shields.io/badge/priority-medium-yellow)

The type for `artist` here is `any`. Could we use a more specific type for the `artist` object from the Spotify API response? This would improve type safety and make it clearer what properties are available on an artist object.

Perhaps the `SpotifyTrackData` interface in `src/types/spotify.ts` could be expanded or a new interface for the raw Spotify track response could be created to type `trackData` more accurately.

```typescript
      artists: trackData.artists.map((artist: { name: string }) => artist.name),
```
created_at: 2025-05-30T11:49:16Z
author_association: NONE
diff_hunk: @@ -0,0 +1,387 @@
+// components/SongRecommendations.tsx
+'use client';
+
+import { useState } from 'react';
+import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
+import { Button } from '@/components/ui/button';
+import { Badge } from '@/components/ui/badge';
+import { useToast } from '@/components/ui/use-toast';
+import {
+  Music,
+  Loader2,
+  Zap,
+  Users,
+  Trophy,
+  Target,
+  RefreshCw,
+} from 'lucide-react';
+import { motion, AnimatePresence } from 'motion/react';
+import SpotifySongCard from './SpotifySongCard';
+// Replace the interface definitions at the top with this import:
+import { RecommendationResult, Player } from '../types/spotify';
+
+interface SongRecommendationsProps {
+  replayData: any;
path: src/components/SongRecommendations.tsx
user: login: gemini-code-assist[bot]
body: ![medium](https://img.shields.io/badge/priority-medium-yellow)

The `replayData` prop is currently typed as `any`. To improve type safety and code clarity, could this be typed more specifically? 

For instance, you could import and use the `ReplayData` interface from `src/app/replays/[id]/page.tsx` (perhaps by moving `ReplayData` to a shared types file if it's used in multiple places). If only a subset of `replayData` (like `metrics`) is used, you could type it to that specific structure.

This would also help in ensuring that `replayData?.metrics` (used on line 72) is accessed safely based on a defined type.
created_at: 2025-05-30T11:49:17Z
author_association: NONE
diff_hunk: @@ -0,0 +1,66 @@
+// types/spotify.ts
+export interface Song {
+  title: string;
+  artist: string;
+  match_score: number;
+  bpm: number;
+  energy: string | number; // Allow both string ("High") and number (0.8)
+  moods: string[];
+  themes: string[];
+  matched_criteria_details: string[];
+  source_url?: string;
+}
+
+export interface RecommendationProfile {
+  player_name: string;
+  metrics: {
+    intensity_score: number;
+    performance_score: number;
+    teamwork_factor: number;
+    game_outcome: any;
path: src/types/spotify.ts
user: login: gemini-code-assist[bot]
body: ![medium](https://img.shields.io/badge/priority-medium-yellow)

The `game_outcome` property in `RecommendationProfile.metrics` is typed as `any`. If the structure or possible types for `game_outcome` are known (e.g., string, number, or a specific object structure), could we define a more specific type for it? This would enhance type safety.
created_at: 2025-05-30T11:49:17Z
author_association: NONE
diff_hunk: @@ -0,0 +1,66 @@
+// types/spotify.ts
+export interface Song {
+  title: string;
+  artist: string;
+  match_score: number;
+  bpm: number;
+  energy: string | number; // Allow both string ("High") and number (0.8)
+  moods: string[];
+  themes: string[];
+  matched_criteria_details: string[];
+  source_url?: string;
+}
+
+export interface RecommendationProfile {
+  player_name: string;
+  metrics: {
+    intensity_score: number;
+    performance_score: number;
+    teamwork_factor: number;
+    game_outcome: any;
+  };
+  categories: {
+    intensity: string;
+    performance: string;
+    teamwork: string;
+    closeness: string;
+  };
+  desired_song_profile: any;
path: src/types/spotify.ts
user: login: gemini-code-assist[bot]
body: ![medium](https://img.shields.io/badge/priority-medium-yellow)

Similarly, `desired_song_profile` in `RecommendationProfile` is typed as `any`. If there's a known structure for this profile (even if it's complex or varies slightly), providing a more specific type or a union of possible types would be beneficial for type safety and understanding the data structure.
created_at: 2025-05-30T11:49:17Z
author_association: NONE
diff_hunk: @@ -1,6 +1,7 @@
 import { createEnv } from '@t3-oss/env-nextjs';
 import { z } from 'zod';
-
+// TODO: THIS IS OLD, NOT USED. UPDATE THE ENVIRONMENT VARIABLES TO MAKE THIS USEFUL
+// IT IS MOST PROBABLY A VALIDATION LAYER FOR THE ENVIRONMENT VARIABLES
path: src/env.mjs
user: login: coderabbitai[bot]
body: _⚠️ Potential issue_

**Critical: Update environment validation for new Spotify API variables.**

The TODO comment indicates this validation layer is outdated, but this PR introduces new environment variables (`NEXT_PUBLIC_SPOTIFY_CLIENT_ID`, `SPOTIFY_CLIENT_SECRET`, `PYTHON_API_URL`) that aren't being validated. This could lead to runtime errors if these variables aren't properly configured.



Consider updating the validation schema to include the new environment variables:

```diff
  server: {
    DATABASE_URL: z.string().min(1),
    APP_URL: z.string().url().min(1),
+   SPOTIFY_CLIENT_SECRET: z.string().min(1),
+   PYTHON_API_URL: z.string().url().min(1),
    // ... existing variables
  },
  client: {
    NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY: z.string().min(1),
+   NEXT_PUBLIC_SPOTIFY_CLIENT_ID: z.string().min(1),
  },
  runtimeEnv: {
    // ... existing mappings
+   SPOTIFY_CLIENT_SECRET: process.env.SPOTIFY_CLIENT_SECRET,
+   PYTHON_API_URL: process.env.PYTHON_API_URL,
+   NEXT_PUBLIC_SPOTIFY_CLIENT_ID: process.env.NEXT_PUBLIC_SPOTIFY_CLIENT_ID,
  },
```


<!-- suggestion_start -->

<details>
<summary>📝 Committable suggestion</summary>

> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

```suggestion
// src/env.mjs

export const env = {
  server: {
    DATABASE_URL: z.string().min(1),
    APP_URL:     z.string().url().min(1),
    SPOTIFY_CLIENT_SECRET: z.string().min(1),
    PYTHON_API_URL:        z.string().url().min(1),
    // ... existing variables
  },
  client: {
    NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY: z.string().min(1),
    NEXT_PUBLIC_SPOTIFY_CLIENT_ID:      z.string().min(1),
  },
  runtimeEnv: {
    // ... existing mappings
    SPOTIFY_CLIENT_SECRET:    process.env.SPOTIFY_CLIENT_SECRET,
    PYTHON_API_URL:           process.env.PYTHON_API_URL,
    NEXT_PUBLIC_SPOTIFY_CLIENT_ID: process.env.NEXT_PUBLIC_SPOTIFY_CLIENT_ID,
  },
};
```

</details>

<!-- suggestion_end -->

<details>
<summary>🤖 Prompt for AI Agents</summary>

```
In src/env.mjs around lines 3 to 4, the environment variable validation is
outdated and does not include the new Spotify API variables introduced in this
PR. Update the validation schema to add checks for
NEXT_PUBLIC_SPOTIFY_CLIENT_ID, SPOTIFY_CLIENT_SECRET, and PYTHON_API_URL to
ensure these variables are present and valid, preventing runtime errors due to
missing or misconfigured environment variables.
```

</details>

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-05-30T11:51:46Z
author_association: NONE
diff_hunk: @@ -15,3 +15,11 @@ STRIPE_SECRET_KEY='your stripe secret key' ## required for stripe
 STRIPE_WEBHOOK_SECRET_KEY='your webhook secret key' ## required for stripe
 STRIPE_SUBSCRIPTION_PRICE_ID='your subscription price id' ## required for stripe
 NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY='your stripe publishable key' ## required for stripe
+
+
+####################### SPOTIFY API #######################
+NEXT_PUBLIC_SPOTIFY_CLIENT_ID=your_spotify_client_id_here
+SPOTIFY_CLIENT_SECRET=your_spotify_client_secret_here
+
+####################### SONG RECOMMEND API #######################
+PYTHON_API_URL='https://replay-rythms-recs.onrender.com'
path: .env.example
user: login: coderabbitai[bot]
body: _🛠️ Refactor suggestion_

**Replace hardcoded API URL with placeholder.**

The Spotify API credentials look good, but the `PYTHON_API_URL` contains a hardcoded production URL which is inappropriate for an example file.



```diff
 ####################### SONG RECOMMEND API #######################
-PYTHON_API_URL='https://replay-rythms-recs.onrender.com'
+PYTHON_API_URL='your_song_recommendation_api_url_here'
```

Example files should contain placeholder values, not actual production URLs, to ensure proper configuration across different environments (development, staging, production).


<!-- suggestion_start -->

<details>
<summary>📝 Committable suggestion</summary>

> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

```suggestion
####################### SPOTIFY API #######################
NEXT_PUBLIC_SPOTIFY_CLIENT_ID=your_spotify_client_id_here
SPOTIFY_CLIENT_SECRET=your_spotify_client_secret_here

####################### SONG RECOMMEND API #######################
PYTHON_API_URL='your_song_recommendation_api_url_here'
```

</details>

<!-- suggestion_end -->

<details>
<summary>🤖 Prompt for AI Agents</summary>

```
In the .env.example file around lines 20 to 25, replace the hardcoded production
URL assigned to PYTHON_API_URL with a generic placeholder value. This change
ensures the example file contains only placeholder values for environment
variables, avoiding exposure of actual production URLs and promoting proper
configuration in different environments.
```

</details>

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-05-30T11:51:46Z
author_association: NONE
diff_hunk: @@ -0,0 +1,96 @@
+// app/api/spotify/track/route.ts
+import { NextRequest, NextResponse } from 'next/server';
+
+export async function GET(request: NextRequest) {
+  try {
+    const { searchParams } = new URL(request.url);
+    const trackId = searchParams.get('id');
+    const spotifyUrl = searchParams.get('url');
+
+    if (!trackId && !spotifyUrl) {
+      return NextResponse.json(
+        { error: 'Track ID or Spotify URL required' },
+        { status: 400 }
+      );
+    }
+
+    // Extract track ID from Spotify URL if provided
+    let finalTrackId = trackId;
+    if (spotifyUrl && !trackId) {
+      const match = spotifyUrl.match(/track\/([a-zA-Z0-9]+)/);
+      if (match) {
+        finalTrackId = match[1];
+      }
+    }
+
+    if (!finalTrackId) {
+      return NextResponse.json(
+        { error: 'Invalid track ID or URL' },
+        { status: 400 }
+      );
+    }
+
+    // Get Spotify access token - construct the URL properly
+    const baseUrl =
+      process.env.NEXTAUTH_URL ||
+      (typeof window !== 'undefined'
+        ? window.location.origin
+        : 'http://localhost:3000');
+
path: src/app/api/spotify/track/route.ts
user: login: coderabbitai[bot]
body: _⚠️ Potential issue_

**Fix base URL construction logic.**

The `typeof window !== 'undefined'` check will always be false in a server-side API route, making this fallback ineffective. Also, relying on window.location.origin in server context is problematic.



```diff
-    const baseUrl =
-      process.env.NEXTAUTH_URL ||
-      (typeof window !== 'undefined'
-        ? window.location.origin
-        : 'http://localhost:3000');
+    const baseUrl = process.env.NEXTAUTH_URL || 'http://localhost:3000';
```

Consider using the request headers to construct the base URL dynamically:

```diff
-    const baseUrl = process.env.NEXTAUTH_URL || 'http://localhost:3000';
+    const baseUrl = process.env.NEXTAUTH_URL || 
+      `${request.headers.get('x-forwarded-proto') || 'http'}://${request.headers.get('host')}`;
```


<!-- suggestion_start -->

<details>
<summary>📝 Committable suggestion</summary>

> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

```suggestion
    const baseUrl = process.env.NEXTAUTH_URL || 
      `${request.headers.get('x-forwarded-proto') || 'http'}://${request.headers.get('host')}`;
```

</details>

<!-- suggestion_end -->

<details>
<summary>🤖 Prompt for AI Agents</summary>

```
In src/app/api/spotify/track/route.ts around lines 34 to 39, the base URL
construction incorrectly uses a client-side check (typeof window !==
'undefined') which is always false in server-side API routes, making the
fallback ineffective. To fix this, remove the window check and instead
dynamically construct the base URL using the request headers (such as the 'host'
header) available in the server context, falling back to a default like
'http://localhost:3000' if headers are missing.
```

</details>

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-05-30T11:51:46Z
author_association: NONE
diff_hunk: @@ -0,0 +1,96 @@
+// app/api/spotify/track/route.ts
+import { NextRequest, NextResponse } from 'next/server';
+
+export async function GET(request: NextRequest) {
+  try {
+    const { searchParams } = new URL(request.url);
+    const trackId = searchParams.get('id');
+    const spotifyUrl = searchParams.get('url');
+
+    if (!trackId && !spotifyUrl) {
+      return NextResponse.json(
+        { error: 'Track ID or Spotify URL required' },
+        { status: 400 }
+      );
+    }
+
+    // Extract track ID from Spotify URL if provided
+    let finalTrackId = trackId;
+    if (spotifyUrl && !trackId) {
+      const match = spotifyUrl.match(/track\/([a-zA-Z0-9]+)/);
+      if (match) {
+        finalTrackId = match[1];
+      }
+    }
+
+    if (!finalTrackId) {
+      return NextResponse.json(
+        { error: 'Invalid track ID or URL' },
+        { status: 400 }
+      );
+    }
path: src/app/api/spotify/track/route.ts
user: login: coderabbitai[bot]
body: _🛠️ Refactor suggestion_

**Improve URL parsing robustness.**

The regex pattern for extracting track IDs is too restrictive and may not handle all valid Spotify track ID formats. Spotify track IDs are typically 22 characters long and use base62 encoding.



```diff
-      const match = spotifyUrl.match(/track\/([a-zA-Z0-9]+)/);
+      const match = spotifyUrl.match(/track\/([a-zA-Z0-9]{22})/);
```

Additionally, consider handling URL variations more robustly:

```diff
-      const match = spotifyUrl.match(/track\/([a-zA-Z0-9]{22})/);
+      const match = spotifyUrl.match(/track\/([a-zA-Z0-9]{22})(?:\?|$)/);
```


<!-- suggestion_start -->

<details>
<summary>📝 Committable suggestion</summary>

> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

```suggestion
    // Extract track ID from Spotify URL if provided
    let finalTrackId = trackId;
    if (spotifyUrl && !trackId) {
      const match = spotifyUrl.match(/track\/([a-zA-Z0-9]{22})(?:\?|$)/);
      if (match) {
        finalTrackId = match[1];
      }
    }

    if (!finalTrackId) {
      return NextResponse.json(
        { error: 'Invalid track ID or URL' },
        { status: 400 }
      );
    }
```

</details>

<!-- suggestion_end -->

<details>
<summary>🤖 Prompt for AI Agents</summary>

```
In src/app/api/spotify/track/route.ts around lines 17 to 31, the regex used to
extract the track ID from the Spotify URL is too restrictive and does not
account for the full 22-character base62 encoded track IDs. Update the regex
pattern to match exactly 22 alphanumeric characters (including uppercase,
lowercase, and digits) after "track/". Also, enhance the URL parsing to handle
possible variations such as query parameters or trailing slashes by making the
regex more flexible and robust.
```

</details>

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-05-30T11:51:46Z
author_association: NONE
diff_hunk: @@ -0,0 +1,134 @@
+// app/api/recommendations/route.ts
+import { NextRequest, NextResponse } from 'next/server';
+
+// const PYTHON_API_URL = 'https://replay-rythms-recs.onrender.com';
+
+export async function POST(request: NextRequest) {
+  try {
+    const body = await request.json();
+
+    // Validate required fields
+    if (!body.player_id) {
+      return NextResponse.json(
+        { success: false, error: 'Missing required field: player_id' },
+        { status: 400 }
+      );
+    }
+
+    // Forward the request to your Python API
+    const response = await fetch(`${process.env.PYTHON_API_URL}/recommend`, {
+      method: 'POST',
+      headers: {
+        'Content-Type': 'application/json',
+      },
+      body: JSON.stringify({
+        player_id: body.player_id,
+        replay_data: body.replay_data || null,
+        top_n: body.top_n || 5,
+      }),
+    });
+
+    // Handle non-200 responses
+    if (!response.ok) {
+      const errorText = await response.text();
+      console.error(`Python API error (${response.status}):`, errorText);
+
+      return NextResponse.json(
+        {
+          success: false,
+          error: `API request failed: ${response.status} ${response.statusText}`,
+          details: errorText,
+        },
+        { status: response.status }
+      );
+    }
+
+    const data = await response.json();
+
+    // Return the response from Python API
+    return NextResponse.json(data);
+  } catch (error) {
+    console.error('Error proxying to Python API:', error);
+
+    // Handle network errors (like if Render service is sleeping)
+    if (error instanceof Error && error.message.includes('fetch')) {
+      return NextResponse.json(
+        {
+          success: false,
+          error:
+            'Unable to connect to recommendation service. The service may be starting up - please try again in a moment.',
+          technical_error: error.message,
+        },
+        { status: 503 } // Service Unavailable
+      );
+    }
+
+    return NextResponse.json(
+      {
+        success: false,
+        error: 'Internal server error',
+        technical_error:
+          error instanceof Error ? error.message : 'Unknown error',
+      },
+      { status: 500 }
+    );
+  }
+}
+
+export async function GET(request: NextRequest) {
+  try {
+    const { searchParams } = new URL(request.url);
+    const playerId =
+      searchParams.get('player_id') || 'ce45140fcd644755b01660aa2dc6977b';
+    const topN = searchParams.get('top_n') || '5';
path: src/app/api/recommendations/route.ts
user: login: coderabbitai[bot]
body: _🛠️ Refactor suggestion_

**Hardcoded default player ID in production code.**

The hardcoded player ID in the GET method should not be used in production. Consider requiring the player_id parameter or using a more generic approach.



```diff
-    const playerId =
-      searchParams.get('player_id') || 'ce45140fcd644755b01660aa2dc6977b';
+    const playerId = searchParams.get('player_id');
+    
+    if (!playerId) {
+      return NextResponse.json(
+        { success: false, error: 'Missing required parameter: player_id' },
+        { status: 400 }
+      );
+    }
```

<details>
<summary>🤖 Prompt for AI Agents</summary>

```
In src/app/api/recommendations/route.ts around lines 81 to 83, remove the
hardcoded default player ID from the playerId assignment. Instead, make the
player_id parameter required by validating its presence and returning an error
if missing, or implement a generic fallback mechanism that does not rely on a
specific hardcoded ID.
```

</details>

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-05-30T11:51:46Z
author_association: NONE
diff_hunk: @@ -0,0 +1,66 @@
+// types/spotify.ts
+export interface Song {
+  title: string;
+  artist: string;
+  match_score: number;
+  bpm: number;
+  energy: string | number; // Allow both string ("High") and number (0.8)
+  moods: string[];
+  themes: string[];
+  matched_criteria_details: string[];
+  source_url?: string;
+}
+
+export interface RecommendationProfile {
+  player_name: string;
+  metrics: {
+    intensity_score: number;
+    performance_score: number;
+    teamwork_factor: number;
+    game_outcome: any;
path: src/types/spotify.ts
user: login: coderabbitai[bot]
body: _🛠️ Refactor suggestion_

**Replace 'any' types with specific interfaces.**

The use of `any` for `game_outcome` and `desired_song_profile` reduces type safety. Consider defining specific interfaces for these fields.



```diff
export interface RecommendationProfile {
  player_name: string;
  metrics: {
    intensity_score: number;
    performance_score: number;
    teamwork_factor: number;
-    game_outcome: any;
+    game_outcome: {
+      result: 'win' | 'loss' | 'draw';
+      score?: string;
+      duration?: number;
+    };
  };
  categories: {
    intensity: string;
    performance: string;
    teamwork: string;
    closeness: string;
  };
-  desired_song_profile: any;
+  desired_song_profile: {
+    energy_range: [number, number];
+    preferred_moods: string[];
+    bpm_range?: [number, number];
+  };
}
```


Also applies to: 28-28

<details>
<summary>🤖 Prompt for AI Agents</summary>

```
In src/types/spotify.ts at lines 20 and 28, the fields game_outcome and
desired_song_profile are typed as any, which reduces type safety. Define
specific interfaces that accurately represent the expected structure of these
fields and replace the any type annotations with these interfaces to improve
type safety and code clarity.
```

</details>

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-05-30T11:51:47Z
author_association: NONE
diff_hunk: @@ -0,0 +1,274 @@
+// components/SpotifySongCard.tsx
+'use client';
+
+import { useState, useEffect } from 'react';
+import { Card } from '@/components/ui/card';
+import { Button } from '@/components/ui/button';
+import { Badge } from '@/components/ui/badge';
+import { ExternalLink, Music, Maximize2, Minimize2 } from 'lucide-react';
+import { motion } from 'motion/react';
+import { Song } from '../types/spotify';
path: src/components/SpotifySongCard.tsx
user: login: coderabbitai[bot]
body: _⚠️ Potential issue_

**Incorrect import path for animation library**

You updated `framer-motion` to `^12.15.0` in *package.json*, but the code imports from `"motion/react"`.  
Unless you intentionally installed `@motionone/react` (published as `motion`) this will fail at build-time with: *“Cannot resolve module 'motion/react'”*.

```diff
-import { motion } from 'motion/react';
+// If you meant framer-motion (very likely):
+import { motion } from 'framer-motion';
+
+// OR, if you really use Motion One, ensure the dep exists:
+// import { motion } from '@motionone/react';
```



<!-- suggestion_start -->

<details>
<summary>📝 Committable suggestion</summary>

> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

```suggestion
// If you meant framer-motion (very likely):
import { motion } from 'framer-motion';

// OR, if you really use Motion One, ensure the dep exists:
// import { motion } from '@motionone/react';
import { Song } from '../types/spotify';
```

</details>

<!-- suggestion_end -->

<details>
<summary>🤖 Prompt for AI Agents</summary>

```
In src/components/SpotifySongCard.tsx around lines 9 to 10, the import statement
for the animation library incorrectly uses 'motion/react' instead of
'framer-motion'. To fix this, change the import path from 'motion/react' to
'framer-motion' to match the updated package version and avoid build errors.
```

</details>

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-05-30T11:51:47Z
author_association: NONE

PR comments:
user: login: vercel[bot]
created_at: 2025-05-30T11:46:54Z
body: [vc]: #6JFakrOIDZNQIGEmtPk30xnBFHF7DnS1KSTm8/syCp4=:eyJpc01vbm9yZXBvIjp0cnVlLCJ0eXBlIjoiZ2l0aHViIiwicHJvamVjdHMiOlt7Im5hbWUiOiJyb2NrZXQtbGVhZ3VlLW11c2ljIiwibGl2ZUZlZWRiYWNrIjp7InJlc29sdmVkIjowLCJ1bnJlc29sdmVkIjowLCJ0b3RhbCI6MCwibGluayI6InJvY2tldC1sZWFndWUtbXVzaWMtZ2l0LWMxYTgyMi1yaXNoYWJoLXNpbmdocy1wcm9qZWN0cy0yZTZhMmVlNi52ZXJjZWwuYXBwIn0sImluc3BlY3RvclVybCI6Imh0dHBzOi8vdmVyY2VsLmNvbS9yaXNoYWJoLXNpbmdocy1wcm9qZWN0cy0yZTZhMmVlNi9yb2NrZXQtbGVhZ3VlLW11c2ljL0JYV2VjRWZXR3h6eUJhRUdMNGo2Q2tKcnpKdTIiLCJwcmV2aWV3VXJsIjoicm9ja2V0LWxlYWd1ZS1tdXNpYy1naXQtYzFhODIyLXJpc2hhYmgtc2luZ2hzLXByb2plY3RzLTJlNmEyZWU2LnZlcmNlbC5hcHAiLCJuZXh0Q29tbWl0U3RhdHVzIjoiREVQTE9ZRUQifV19
**The latest updates on your projects**. Learn more about [Vercel for Git ↗︎](https://vercel.link/github-learn-more)

| Name | Status | Preview | Comments | Updated (UTC) |
| :--- | :----- | :------ | :------- | :------ |
| **rocket-league-music** | ✅ Ready ([Inspect](https://vercel.com/rishabh-singhs-projects-2e6a2ee6/rocket-league-music/BXWecEfWGxzyBaEGL4j6CkJrzJu2)) | [Visit Preview](https://rocket-league-music-git-c1a822-rishabh-singhs-projects-2e6a2ee6.vercel.app) | 💬 [**Add feedback**](https://vercel.live/open-feedback/rocket-league-music-git-c1a822-rishabh-singhs-projects-2e6a2ee6.vercel.app?via=pr-comment-feedback-link) | May 30, 2025 11:46am |


author_association: NONE
user: login: coderabbitai[bot]
created_at: 2025-05-30T11:46:56Z
body: <!-- This is an auto-generated comment: summarize by coderabbit.ai -->
<!-- walkthrough_start -->

## Walkthrough

This update introduces a song recommendation feature integrated with Spotify. It adds new API routes for fetching recommendations and Spotify track details, updates environment variable examples, and introduces React components for displaying song recommendations and Spotify song cards. Supporting TypeScript interfaces and editor settings are also added, along with a dependency update.

## Changes

| File(s)                                                         | Change Summary                                                                                                                     |
|------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------|
| `.env.example`                                                   | Added Spotify and song recommendation API environment variable placeholders.                                                        |
| `.vscode/settings.json`                                          | Added VSCode workspace color theme settings.                                                                                       |
| `package.json`                                                   | Updated "framer-motion" dependency version.                                                                                        |
| `src/app/api/recommendations/route.ts`                           | Added new API route for song recommendations (POST/GET handlers, external API integration, error handling).                        |
| `src/app/api/spotify/auth/route.ts`                              | Added new POST API route for Spotify authentication (Client Credentials flow).                                                     |
| `src/app/api/spotify/track/route.ts`                             | Added new GET API route to fetch Spotify track details by ID or URL.                                                               |
| `src/app/replays/[id]/page.tsx`                                  | Added "Song Recommendations" tab and corresponding UI to replay details page.                                                      |
| `src/components/SongRecommendations.tsx`                         | Added new React component for generating and displaying song recommendations per player.                                            |
| `src/components/SpotifySongCard.tsx`                             | Added new React component for displaying detailed Spotify song information with embedded player.                                    |
| `src/env.mjs`                                                    | Added a comment indicating outdated environment variable validation.                                                                |
| `src/types/spotify.ts`                                           | Added TypeScript interfaces for Song, RecommendationProfile, RecommendationResult, Player, and SpotifyTrackData.                   |

## Sequence Diagram(s)

```mermaid
sequenceDiagram
    participant User
    participant ReplayPage
    participant SongRecommendations
    participant RecommendationsAPI
    participant PythonAPI
    participant SpotifyAuthAPI
    participant SpotifyTrackAPI
    participant Spotify

    User->>ReplayPage: Selects "Song Recommendations" tab
    ReplayPage->>SongRecommendations: Passes replay data
    SongRecommendations->>RecommendationsAPI: POST /api/recommendations (player_id, replay_data)
    RecommendationsAPI->>PythonAPI: POST /recommend (player_id, replay_data)
    PythonAPI-->>RecommendationsAPI: Returns recommended songs
    RecommendationsAPI-->>SongRecommendations: Returns recommendations
    SongRecommendations->>SpotifyTrackAPI: GET /api/spotify/track (for each song)
    SpotifyTrackAPI->>SpotifyAuthAPI: POST /api/spotify/auth
    SpotifyAuthAPI->>Spotify: POST /api/token (client credentials)
    Spotify-->>SpotifyAuthAPI: Returns access token
    SpotifyAuthAPI-->>SpotifyTrackAPI: Returns access token
    SpotifyTrackAPI->>Spotify: GET /v1/tracks/{id}
    Spotify-->>SpotifyTrackAPI: Returns track data
    SpotifyTrackAPI-->>SongRecommendations: Returns track details
    SongRecommendations-->>User: Displays recommendations and song cards
```

## Poem

> 🐇  
> A hop, a skip, a brand new tune,  
> Song cards and tabs arrive so soon!  
> With Spotify’s beat and Python’s mind,  
> Recommendations, perfectly aligned.  
> Now music and matches intertwine—  
> Let’s dance through code, where features shine!  
> 🎶✨

<!-- walkthrough_end -->
<!-- This is an auto-generated comment: all tool run failures by coderabbit.ai -->

> [!WARNING]
> There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.
> 
> <details>
> <summary>🔧 ESLint</summary>
> 
> > If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.
> 
> npm error Exit handler never called!
> npm error This is an error with npm itself. Please report this error at:
> npm error   <https://github.com/npm/cli/issues>
> npm error A complete log of this run can be found in: /.npm/_logs/2025-05-30T11_47_58_764Z-debug-0.log
> 
> 
> 
> </details>

<!-- end of auto-generated comment: all tool run failures by coderabbit.ai -->
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKNwSPbABsvkCiQBHbGlcSHFcLzpIACIAMRJqbH8AemZsRHgGP1FEaMgAdzRkBwFmdRp6OTDYD3TKPyRYFVgwWGwBdGRub19/IJDIDEcBeoBGDRgaxiaMUmR4DFwKRWwGKIWGL2wlao8FmiIqcXwsfAAzdEZ0gmYwAWx4L1DMelh8RArINIys/yZWMi0ajwE6QACCVgAkhMwbRaOoQRg0D5ZAAaXaQbDcIE0dBw5BoSAAZW4+HEZ3k8DOVDYkBIzBGcIWREgZwSuCSHlwTWePnw+S6XjQsmZGL+LDYGCU9EQJyIyHhfwi8ny6gQWG5HjQ3G4XkywJOE3c1js2mYyAIdIwMzWGO+mWy/0lOMRr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yCdpyYmJdZl0NmHZ5dcSGAYUb1tA/oICatDEPan+AtoLghBWwVgCkJot5I49LQpxgnrpApmdww+K/yA7OAqACgl5ow33g7C5GCJObhF1hb3sEWGGIimkUQ6l1ION5EChQXTTrQ5GrwnwTvHU5DgRgU1dEUDQxGJlYyl3Vobhyup3NHm4YP8r40xiko0Ad4FaIFjZiusHo08RNJCLTS5Q/GeVRqr82gAgkq2VIoYSLCUChkQyUQSUhyV0TplJOpjNxofgp7Rlbk43UUStDQ6OBGh4JGrDmTObgEImdYSCEWQEQoDUWJHCsr4ElIuj2otZbwPWXkCLcRktRFgfUSaRi8o2sFbOLGxl5c45eYQy2P0WvaDDjeGtWYmRVEHSBViCMevI7lQoRQjBxvbodnnbb9DSKIg0oeIN+a5i+iNVQsbaCZqPD4wzwp4OmIrFiDsxDkGsfmJt4piGxCfOehQDbGp5MxVYtYt2OdwFiYw1IhsUCUVGUJlR5YkcZWM7GSCHcQgtCBhF3BphW0eAACGshEpT9wIaASCKamHh+gEIz4NQMhHfCbjPwtA9QH2lTRpQWuTougGlF7r6xUI6Ee8VYiiSmIAAnFYgECjAzgAADgsS0ArEJAZFABLQAkAAAbMBIADspiUQLQAsQMAokkEzCQBLAkITkJtAMCWcGRTfitxD43AE+MQAvjHR9Yd8RGH0BAA -->

<!-- internal state end -->
<!-- finishing_touch_checkbox_start -->

<details open="true">
<summary>✨ Finishing Touches</summary>

- [ ] <!-- {"checkboxId": "7962f53c-55bc-4827-bfbf-6a18da830691"} --> 📝 Generate Docstrings

</details>

<!-- finishing_touch_checkbox_end -->
<!-- tips_start -->

---



<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=rishabh-hub/rocket-league-music&utm_content=1):

- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
  - `I pushed a fix in commit <commit_id>, please review it.`
  - `Explain this complex logic.`
  - `Open a follow-up GitHub issue for this discussion.`
- Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples:
  - `@coderabbitai explain this code block.`
  -	`@coderabbitai modularize this function.`
- PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
  - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.`
  - `@coderabbitai read src/utils.ts and explain its main purpose.`
  - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.`
  - `@coderabbitai help me debug CodeRabbit configuration file.`

### Support

Need help? Create a ticket on our [support page](https://www.coderabbit.ai/contact-us/support) for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

### CodeRabbit Commands (Invoked using PR comments)

- `@coderabbitai pause` to pause the reviews on a PR.
- `@coderabbitai resume` to resume the paused reviews.
- `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
- `@coderabbitai full review` to do a full review from scratch and review all the files again.
- `@coderabbitai summary` to regenerate the summary of the PR.
- `@coderabbitai generate docstrings` to [generate docstrings](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR.
- `@coderabbitai generate sequence diagram` to generate a sequence diagram of the changes in this PR.
- `@coderabbitai resolve` resolve all the CodeRabbit review comments.
- `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository.
- `@coderabbitai help` to get help.

### Other keywords and placeholders

- Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed.
- Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description.
- Add `@coderabbitai` anywhere in the PR title to generate the title automatically.

### CodeRabbit Configuration File (`.coderabbit.yaml`)

- You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository.
- Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json`

### Documentation and Community

- Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->
author_association: NONE