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
Home Screen |
Real-time Chat |
Admin Dashboard |
Album View |
- π΅ 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.
- π¬ 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.
- πͺ 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.
| 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 |
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 documentationThe project demonstrates modern React development with:
- Custom Hooks: Reusable logic for music playback and chat functionality.
- Context Providers: Global authentication state with Clerk.
- Code Splitting: Lazy loading routes to reduce bundle size.
- Zustand Stores: Lightweight state management for music, chat, and player.
// 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 });
},
}));// Socket.IO integration for real-time messaging
socket.on('newMessage', (message) => {
useChatStore.getState().addMessage(message);
});
socket.emit('sendMessage', {
receiverId: userId,
content: messageContent,
});- Node.js 16+
- MongoDB instance (local or Atlas)
- Cloudinary account for media storage
- Clerk account for authentication
-
Clone the repository
git clone https://github.com/Niteshagarwal01/Spotifyclone.git cd Spotifyclone -
Install dependencies
# Install backend dependencies cd backend npm install # Install frontend dependencies cd ../frontend npm install
-
Set up environment variables
Create
.envfiles 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
-
Start development servers
# Start backend (from backend directory) npm run dev # Start frontend (from frontend directory) npm run dev
-
Seed data (Optional)
# From backend directory npm run seed:albums npm run seed:songs
Modify Tailwind theme in frontend/tailwind.config.js:
export default {
theme: {
extend: {
colors: {
'spotify-green': '#1DB954',
'spotify-black': '#191414',
},
},
},
};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_keyFrontend:
VITE_CLERK_PUBLISHABLE_KEY=your_clerk_publishable_key
VITE_API_URL=http://localhost:5000- Code Splitting: Route-based and component-based splitting with React.lazy.
- Lazy Loading: Images and audio files loaded on demand.
- Memoization:
React.memoanduseMemofor expensive operations. - Bundle Analysis: Optimized imports and tree shaking with Vite.
- API Optimization: Efficient data fetching with caching strategies.
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
Contributions are welcome! Please feel free to:
- Report bugs and issues.
- Suggest new features.
- Submit pull requests.
This project is open source and available under the MIT License.



