Skip to content

Niteshagarwal01/Spotifyclone

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Logo

Spotify Clone

A modern Spotify clone built with React, TypeScript, Node.js, and Socket.IO, featuring real-time chat, music streaming, admin dashboard, and social features.

Features β€’ Tech Stack β€’ Quick Start β€’ Development β€’ Screenshots


πŸ“Έ Screenshots

Home Page

Home Page

Home Screen
Home Screen
Chat Feature
Real-time Chat
Admin Dashboard
Admin Dashboard
Album Page
Album View

✨ Features

Core Functionality

  • 🎡 Music Streaming: Browse and play songs with a custom audio player.
  • πŸ’Ώ Album Management: Explore albums with detailed track listings.
  • πŸ” Search: Search for songs, albums, and artists in real-time.
  • πŸ“± Responsive Design: Optimized for desktop, tablet, and mobile devices.
  • 🎨 Custom Player: Audio player with playback controls and progress tracking.
  • πŸ‘₯ Social Features: Friends activity feed showing what others are listening to.

Advanced Features

  • πŸ’¬ Real-time Chat: Socket.IO powered messaging system.
  • ⚑ Performance Optimized: Code splitting, lazy loading, and efficient state management.
  • 🎨 Modern UI: Tailwind CSS with shadcn/ui components.
  • πŸ” Authentication: Secure OAuth integration with Clerk.
  • πŸ“Š Admin Dashboard: Manage songs, albums, and view statistics.
  • 🎯 State Management: Zustand for lightweight and efficient state handling.

User Experience

  • πŸŽͺ Smooth Animations: Framer Motion for transitions and effects.
  • 🎡 Playlist Management: Create and manage custom playlists.
  • πŸ“‹ Activity Feed: See what friends are listening to in real-time.
  • ⚑ Fast Loading: Optimized API calls and caching strategies.

πŸ› οΈ Tech Stack

Area Technology
Frontend React 18, TypeScript, Vite
Styling Tailwind CSS, shadcn/ui
State Management Zustand
Routing React Router v6
Authentication Clerk
Backend Node.js, Express.js
Database MongoDB
Real-time Socket.IO
File Storage Cloudinary
API RESTful API with Express

πŸ“‚ File Structure

spotifyclone/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ controller/      # API controllers
β”‚   β”‚   β”œβ”€β”€ models/          # MongoDB models
β”‚   β”‚   β”œβ”€β”€ routes/          # Express routes
β”‚   β”‚   β”œβ”€β”€ middleware/      # Authentication middleware
β”‚   β”‚   β”œβ”€β”€ lib/             # Database, Socket.IO, Cloudinary setup
β”‚   β”‚   └── index.js         # Server entry point
β”‚   └── package.json
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/      # Reusable UI components
β”‚   β”‚   β”œβ”€β”€ pages/           # Page components
β”‚   β”‚   β”œβ”€β”€ stores/          # Zustand stores
β”‚   β”‚   β”œβ”€β”€ layout/          # Layout components
β”‚   β”‚   β”œβ”€β”€ providers/       # Context providers
β”‚   β”‚   β”œβ”€β”€ types/           # TypeScript types
β”‚   β”‚   └── lib/             # Utility functions
β”‚   β”œβ”€β”€ public/              # Static assets
β”‚   └── package.json
β”œβ”€β”€ .env.example             # Environment variables template
└── README.md                # Project documentation

βš™οΈ How It Works

Advanced React Patterns

The project demonstrates modern React development with:

  1. Custom Hooks: Reusable logic for music playback and chat functionality.
  2. Context Providers: Global authentication state with Clerk.
  3. Code Splitting: Lazy loading routes to reduce bundle size.
  4. Zustand Stores: Lightweight state management for music, chat, and player.

Zustand State Management

// Music store example
export const useMusicStore = create<MusicStore>((set) => ({
  songs: [],
  albums: [],
  currentAlbum: null,
  isLoading: false,
  fetchAlbums: async () => {
    set({ isLoading: true });
    const response = await axiosInstance.get('/albums');
    set({ albums: response.data, isLoading: false });
  },
}));

Real-time Chat Implementation

// Socket.IO integration for real-time messaging
socket.on('newMessage', (message) => {
  useChatStore.getState().addMessage(message);
});

socket.emit('sendMessage', {
  receiverId: userId,
  content: messageContent,
});

πŸš€ Quick Start

Prerequisites

  • Node.js 16+
  • MongoDB instance (local or Atlas)
  • Cloudinary account for media storage
  • Clerk account for authentication

Installation

  1. Clone the repository

    git clone https://github.com/Niteshagarwal01/Spotifyclone.git
    cd Spotifyclone
  2. Install dependencies

    # Install backend dependencies
    cd backend
    npm install
    
    # Install frontend dependencies
    cd ../frontend
    npm install
  3. Set up environment variables

    Create .env files in both backend and frontend directories:

    Backend .env:

    MONGODB_URI=your_mongodb_uri
    PORT=5000
    ADMIN_EMAIL=your_admin_email
    NODE_ENV=development
    CLOUDINARY_CLOUD_NAME=your_cloudinary_name
    CLOUDINARY_API_KEY=your_cloudinary_key
    CLOUDINARY_API_SECRET=your_cloudinary_secret
    CLERK_PUBLISHABLE_KEY=your_clerk_publishable_key
    CLERK_SECRET_KEY=your_clerk_secret_key

    Frontend .env:

    VITE_CLERK_PUBLISHABLE_KEY=your_clerk_publishable_key
  4. Start development servers

    # Start backend (from backend directory)
    npm run dev
    
    # Start frontend (from frontend directory)
    npm run dev
  5. Seed data (Optional)

    # From backend directory
    npm run seed:albums
    npm run seed:songs

🎨 Customization

Theme Customization

Modify Tailwind theme in frontend/tailwind.config.js:

export default {
  theme: {
    extend: {
      colors: {
        'spotify-green': '#1DB954',
        'spotify-black': '#191414',
      },
    },
  },
};

Environment Variables

Backend:

MONGODB_URI=mongodb://localhost:27017/spotify-clone
PORT=5000
ADMIN_EMAIL=admin@example.com
NODE_ENV=development
CLOUDINARY_CLOUD_NAME=your_cloud_name
CLOUDINARY_API_KEY=your_api_key
CLOUDINARY_API_SECRET=your_api_secret
CLERK_PUBLISHABLE_KEY=your_publishable_key
CLERK_SECRET_KEY=your_secret_key

Frontend:

VITE_CLERK_PUBLISHABLE_KEY=your_clerk_publishable_key
VITE_API_URL=http://localhost:5000

πŸ“Š Performance Optimizations

  • Code Splitting: Route-based and component-based splitting with React.lazy.
  • Lazy Loading: Images and audio files loaded on demand.
  • Memoization: React.memo and useMemo for expensive operations.
  • Bundle Analysis: Optimized imports and tree shaking with Vite.
  • API Optimization: Efficient data fetching with caching strategies.

⚠️ Limitations & Roadmap

Current Limitations

  • Requires Clerk account for authentication.
  • Cloudinary required for media storage.
  • Basic error handling for network failures.

Planned Features

  • Playlist creation and management
  • Liked songs collection
  • Advanced search filters
  • User profiles and customization
  • Lyrics integration
  • Podcast support
  • Comprehensive test suite
  • PWA support for offline playback

🀝 Contributing

Contributions are welcome! Please feel free to:

  1. Report bugs and issues.
  2. Suggest new features.
  3. Submit pull requests.

πŸ“„ License

This project is open source and available under the MIT License.


Built with ❀️ using modern React and TypeScript

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors