Skip to content
Β 
Β 

Latest commit

Β 

History

129 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

# 🎡 Music Streaming API

> An HLS-based music streaming API with random playback capabilities / API phΓ‘t nhαΊ‘c trα»±c tuyαΊΏn vα»›i tΓ­nh nΔƒng streaming HLS vΓ  phΓ‘t ngαΊ«u nhiΓͺn

<p align="center">
  <img src="docs/images/preview.png" alt="Preview" width="600"/>
</p>

## ✨ Features

### 🎧 Music Playback
- βœ… HLS (HTTP Live Streaming) support
- βœ… Auto-next track functionality
- βœ… Random playback
- βœ… Play count tracking

### πŸ“ File Management
- βœ… Music file upload support
- βœ… Automatic processing and segmentation
- βœ… Multiple audio format support
- βœ… Multi-quality HLS playlist generation

### πŸ’Ύ Database Structure

| Table | Purpose |
|-------|---------|
| `users` | User management & authentication |
| `tracks` | Song metadata & file paths |
| `segments` | HLS segment information |
| `playlists` | HLS & user playlist data |
| `likes` | Track likes & favorites |
| `comments` | User comments & feedback |

### πŸš€ Optimizations
- ⚑ Search optimization indexes
- πŸ“Š SQLite WAL mode
- πŸ”„ Transaction support
- πŸ“¦ Streaming buffer & cache
- πŸ›‘οΈ Comprehensive error handling

## πŸ› οΈ Installation

```bash
# Clone repository
git clone https://github.com/vovanhau123/HTTP-STREAMING.git

# Navigate to project
cd music-streaming-api

# Install dependencies
npm install

# Initialize directories
npm run init

# Start server
npm start
```

> 🌐 Server runs at `http://localhost:3000`

## πŸ“‘ API Endpoints

### 🎡 Tracks

| Method | Endpoint | Description |
|--------|----------|-------------|
| `GET` | `/api/tracks` | Get all tracks |
| `GET` | `/api/tracks/:id/playlist` | Get track's HLS playlist |
| `GET` | `/api/tracks/random` | Get random track |
| `GET` | `/api/tracks/random/:genre` | Get random track by genre |
| `POST` | `/api/tracks/:id/play` | Update play count |

### πŸ“€ Upload

| Method | Endpoint | Description |
|--------|----------|-------------|
| `POST` | `/upload` | Upload new music file |

## πŸ“‚ Project Structure

```
music-streaming-api/
β”œβ”€β”€ data/               # SQLite database
β”œβ”€β”€ public/            
β”‚   β”œβ”€β”€ index.html     # Frontend interface
β”‚   └── streams/       # HLS stream files
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ config/        # App configuration
β”‚   β”œβ”€β”€ controllers/   # Request handlers
β”‚   β”œβ”€β”€ middleware/    # Custom middleware
β”‚   β”œβ”€β”€ models/        # Data models
β”‚   β”œβ”€β”€ routes/        # API routes
β”‚   β”œβ”€β”€ services/      # Business logic
β”‚   └── server.js      # Entry point
β”œβ”€β”€ uploads/           # Uploaded files
└── package.json
```

## πŸ› οΈ Tech Stack

<p align="center">
  <img src="https://nodejs.org/static/images/logo.svg" alt="Node.js" width="60" height="60"/>
  <img src="https://expressjs.com/images/express-facebook-share.png" alt="Express.js" width="60" height="60"/>
  <img src="https://www.sqlite.org/images/sqlite370_banner.gif" alt="SQLite" width="60" height="60"/>
  <img src="https://raw.githubusercontent.com/video-dev/hls.js/master/doc/design/logo.png" alt="HLS.js" width="60" height="60"/>
</p>

- **Backend**: Node.js, Express.js
- **Database**: SQLite3
- **Streaming**: HLS.js
- **File Upload**: Multer

## πŸ—ΊοΈ Roadmap

- [ ] πŸ” User authentication & authorization
- [ ] πŸ“ Playlist management system
- [ ] ❀️ Like & comment functionality
- [ ] πŸ” Advanced search with filters
- [ ] 🎯 Personalized recommendations
- [ ] πŸ“Š Listening statistics & analytics

## 🀝 Contributing

1. Fork the Project
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the Branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request

## πŸ“„ License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## πŸ“¬ Contact

Your Name - [@yourtwitter](https://twitter.com/yourtwitter) - email@example.com

Project Link: [https://github.com/vovanhau123/HTTP-STREAMING](https://github.com/vovanhau123/HTTP-STREAMING)

---
<p align="center">
  Made with ❀️ by vovanhau123
</p>

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages