CLIENT NOT FINISHED
A backend music streaming API built using Django REST Framework (DRF), designed to serve audio content to a frontend client.
This project provides a RESTful API for a music player application. The backend is developed using Django and Django REST Framework, offering endpoints to manage and stream music content. The frontend client is in progress and will interact with this API to deliver a seamless music listening experience.
- Backend: Django, Django REST Framework (DRF)
- Database: PostgreSQL
- Authentication: Token-based authentication (SIMPLE JWT)
- Environment Management:
python-dotenvfor environment variables - Audio Storage: Local file system (MP3 files stored in the server)
git clone https://github.com/reverseCode23932/Music-Player-Software-with-DRF-Server-Side.git
cd Music-Player-Software-with-DRF-Server-Side- Download PostgreSQL from the official website: https://www.postgresql.org/download/
- Run the installer and set a superuser password (usually
postgres). - Add PostgreSQL to your system PATH if not done automatically.
- Start the PostgreSQL service.
Log in to PostgreSQL:
psql -U postgresCreate a database and a user:
CREATE DATABASE music_player_db;
CREATE USER django_user WITH PASSWORD 'strong_password';
GRANT ALL PRIVILEGES ON DATABASE music_player_db TO django_user;Exit psql:
\qpython -m venv venvActivate the virtual environment:
- Windows:
.\venv\Scripts\activate- macOS/Linux:
source venv/bin/activatepip install -r requirements.txtCreate a .env file in the project root and add the following:
DEBUG=True
SECRET_KEY=your_secret_key
DB_NAME=music_player_db
DB_USER=django_user
DB_PASSWORD=strong_password
DB_HOST=localhost
DB_PORT=5432
python manage.py migratepython manage.py createsuperuserpython manage.py runserverAccess the API at http://127.0.0.1:8000/.
- Never hardcode credentials in your code. Use environment variables.
- Use a dedicated PostgreSQL user with limited privileges for Django.
- Keep the PostgreSQL server not publicly accessible; allow access only from your app server.
- Rotate passwords regularly and use strong, unique passwords.
- Consider using SSL for database connections in production.
- GET /api/songs/: List all songs
- POST /api/songs/: Upload a new song
- GET /api/songs/{id}/: Retrieve a song by ID
- PUT /api/songs/{id}/: Update a song by ID
- PATCH /api/songs/{id}/: Partial update of a song by ID
- DELETE /api/songs/{id}/: Delete a song by ID
- GET /api/playlists/: List all playlists
- POST /api/playlists/: Create a new playlist
- GET /api/playlists/{id}/: Retrieve a playlist by ID
- PUT /api/playlists/{id}/: Update a playlist by ID
- PATCH /api/playlists/{id}/: Partial update of a playlist by ID
- DELETE /api/playlists/{id}/: Delete a playlist by ID
- GET /api/users/: List all users (admin only)
- GET /api/users/{id}/: Retrieve a user by ID (admin only)
MIT License