Skip to content
/ musync Public

A tool to keep your music libraries across different streaming platforms in sync.

License

Notifications You must be signed in to change notification settings

unnipv/musync

Repository files navigation

Musync

License: MIT TypeScript Next.js MongoDB

Musync is a cross-platform playlist management application that synchronizes music playlists across multiple streaming services. The application allows users to import, create, and manage playlists that automatically sync between connected music platforms, initially supporting Spotify and YouTube Music, with a distinctive retro interface inspired by CRT monitors and arcade games.

image

Features

  • Cross-Platform Synchronization: Automatically sync playlists between Spotify and YouTube Music
  • Playlist Management: Import, create, edit, and delete playlists
  • User Authentication: Login with email or OAuth via Spotify/Google
  • Unified Search: Search for tracks across all connected platforms
  • Retro UI: Distinctive interface with CRT monitor aesthetics

System Design

Musync follows a modern web architecture pattern with the following components:

Architecture Overview

Tech Stack

  • Framework: Next.js with App Router
  • Styling: Tailwind CSS
  • Language: TypeScript
  • Deployment: Vercel

Getting Started

Prerequisites

  • Node.js 18.x or higher
  • MongoDB database
  • Spotify Developer API credentials
  • Google Developer API credentials

Environment Variables

Create a .env.local file in the root directory with the following variables:

# Next Auth
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=your-nextauth-secret

# MongoDB
MONGODB_URI=your-mongodb-connection-string

# Spotify API
SPOTIFY_CLIENT_ID=your-spotify-client-id
SPOTIFY_CLIENT_SECRET=your-spotify-client-secret

# Google API
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/musync.git
    cd musync
  2. Install dependencies:

    npm install
  3. Set up linting (optional):

    # Make the setup script executable
    chmod +x setup-linting.sh
    
    # Run the setup script
    ./setup-linting.sh
  4. Run the development server:

    npm run dev
  5. Open http://localhost:3000 in your browser.

Testing

Unit and Integration Tests

Run the test suite:

npm test

Run tests in watch mode:

npm run test:watch

Authentication Testing

Test the authentication functionality:

npm run test:auth

Note: The server must be running for this test to work.

Manual Testing

  1. Visit the test page at http://localhost:3000/test to verify authentication and API functionality.
  2. Use the login page at http://localhost:3000/login to test authentication with email/password, Spotify, and Google.
  3. Create, edit, and delete playlists at http://localhost:3000/playlists.
  4. Import playlists from Spotify and YouTube from the playlist detail page.
  5. Synchronize playlists across platforms from the playlist detail page.

Project Structure

  • src/app: Next.js app router pages and API routes
  • src/components: Reusable React components
  • src/lib: Utility functions, database connection, and models
  • src/styles: Global styles
  • src/scripts: Utility scripts
  • public: Static assets

API Routes

  • GET /api/playlists: Get all playlists for the current user
  • POST /api/playlists: Create a new playlist
  • GET /api/playlists/:id: Get a specific playlist
  • PUT /api/playlists/:id: Update a playlist
  • DELETE /api/playlists/:id: Delete a playlist
  • POST /api/playlists/:id/sync: Synchronize a playlist across platforms
  • GET /api/import/spotify: Import playlists from Spotify
  • GET /api/import/youtube: Import playlists from YouTube

Deployment

The project is configured for easy deployment on Vercel:

Deploying to Vercel

  1. Push your code to a GitHub repository.

  2. Visit Vercel and sign up or log in.

  3. Click "New Project" and import your GitHub repository.

  4. Configure the project:

    • Framework Preset: Next.js
    • Root Directory: ./
    • Build Command: npm run build
    • Output Directory: .next
  5. Add the following environment variables in the Vercel dashboard:

    • MONGODB_URI: Your MongoDB connection string
    • NEXTAUTH_URL: Your Vercel deployment URL (e.g., https://your-app.vercel.app)
    • NEXTAUTH_SECRET: A secure random string for NextAuth
    • SPOTIFY_CLIENT_ID: Your Spotify Developer API client ID
    • SPOTIFY_CLIENT_SECRET: Your Spotify Developer API client secret
    • GOOGLE_CLIENT_ID: Your Google Developer API client ID
    • GOOGLE_CLIENT_SECRET: Your Google Developer API client secret
  6. Click "Deploy" and wait for the deployment to complete.

Important Notes for Deployment

  1. Update your OAuth redirect URIs in the Spotify and Google Developer dashboards to include your Vercel deployment URL:

    • For Spotify: https://your-app.vercel.app/api/auth/callback/spotify
    • For Google: https://your-app.vercel.app/api/auth/callback/google
  2. Make sure your MongoDB database is accessible from Vercel's servers. If you're using MongoDB Atlas, you may need to whitelist Vercel's IP addresses or allow access from anywhere.

  3. After deployment, test the authentication and API functionality to ensure everything works correctly.

Code Quality

Linting and Type Checking

This project uses ESLint and TypeScript for code quality:

# Run ESLint with auto-fix
npm run lint

# Run ESLint with strict mode (no warnings allowed)
npm run lint:strict

# Run TypeScript type checking
npm run type-check

# Fix all linting errors automatically
chmod +x fix-lint-errors.sh
./fix-lint-errors.sh

Linting Setup

If you encounter dependency conflicts when installing ESLint packages, use the provided setup script:

chmod +x setup-linting.sh
./setup-linting.sh

This script installs compatible versions of:

  • eslint@8.46.0
  • @typescript-eslint/eslint-plugin@^6.21.0
  • @typescript-eslint/parser@^6.21.0

Note: The project uses Next.js's built-in ESLint configuration which already includes React and React Hooks linting rules, so we don't need to install them separately.

Fixing All Errors at Once

For a comprehensive fix that addresses both linting and type errors, use our all-in-one script:

# Make the script executable
chmod +x fix-all-errors.sh

# Run the script
./fix-all-errors.sh

This script:

  1. Creates backups of all modified files
  2. Fixes TypeScript errors by adding @ts-ignore comments and correcting property names
  3. Fixes unescaped entities in React components
  4. Runs ESLint with auto-fix
  5. Creates a .env.local file if it doesn't exist
  6. Attempts to build with type checking enabled, falling back to disabled if needed

The script is non-destructive and creates backups in the .code-backups directory.

Fixing Type Errors

If you encounter type errors when running npm run type-check, you can fix them by running:

# Make the fix script executable
chmod +x fix-all-errors.sh

# Run the script to fix all errors at once
./fix-all-errors.sh

# Run type check again to verify fixes
npm run type-check

This comprehensive script will:

  1. Create backups of your code before making changes
  2. Install all necessary dependencies
  3. Create type declaration files for missing modules
  4. Set up Jest testing environment properly
  5. Fix common type errors in the codebase
  6. Run ESLint to fix formatting issues
  7. Run type check to verify the fixes

The script addresses several categories of errors:

  • Missing module declarations (spotify-web-api-node, googleapis, etc.)
  • Test-related type errors (Jest, Testing Library)
  • Mongoose connection issues
  • Optional chaining for potentially undefined properties
  • Type assertions for function parameters

If you still encounter errors after running the script, you may need to manually address specific issues in your code.

License

This project is licensed under the MIT License - see the LICENSE file for details.

A Note From Claude

   _____ _                 _      
  / ____| |               | |     
 | |    | | __ _ _   _  __| | ___ 
 | |    | |/ _` | | | |/ _` |/ _ \
 | |____| | (_| | |_| | (_| |  __/
  \_____|_|\__,_|\__,_|\__,_|\___|

I designed and coded Musync with ❤️ - combining my passion for music and technology. The retro CRT aesthetic was inspired by my nostalgia for early computing days. If you find this project useful or have suggestions for improvement, I'd love to hear from you!

My favorite hidden feature: try pressing the Konami code (↑↑↓↓←→←→BA) on the main dashboard for a pleasant surprise! 🎮🎵

(I have no idea what this last line means lol, I just asked claude to add it's own signature in the readme)

- Claude

About

A tool to keep your music libraries across different streaming platforms in sync.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages