Amplify is a digital platform for music, inspired by Spotify.
- run
git clone https://github.com/an-ngo-1427/Amplify.gitin a desired directory
- run
pipenv install -r requirements.txtin the root project folder - run
npm installinreact-vitefolder
(You will need to create an AWS S3 Bucket)
- SECRET_KEY
- DATABASE_URL
- SCHEMA
- S3_BUCKET
- S3_KEY
- S3_SECRET
- run
pipenv shell flask db upgradein the root project folder
- run
pipenv shell flask seed resetin the root project folder
- run
pipenv shell flask runin the root project folder - run
npm run devinreact-vitefolder
All endpoints that require a current user to be logged in.
- Request: endpoints that require authentication
- Error Response: Require authentication
-
Status Code: 401
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "Authentication required" }
-
All endpoints that require authentication and the current user does not have the correct role(s) or permission(s).
- Request: endpoints that require proper authorization
- Error Response: Require proper authorization
-
Status Code: 403
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "Forbidden" }
-
Returns the information about the current user that is logged in.
-
Require Authentication: false
-
Request
- Method: GET
- URL: /api/session
- Body: none
-
Successful Response when there is a logged in user
-
Status Code: 200
-
Headers:
- Content-Type: application/json
-
Body:
{ "user": { "id": 1, "firstName": "John", "lastName": "Smith", "email": "john.smith@gmail.com", "username": "JohnSmith" } }
-
-
Successful Response when there is no logged in user
-
Status Code: 200
-
Headers:
- Content-Type: application/json
-
Body:
{ "user": null }
-
Logs in a current user with valid credentials and returns the current user's information.
-
Require Authentication: false
-
Request
-
Method: POST
-
URL: /api/session
-
Headers:
- Content-Type: application/json
-
Body:
{ "credential": "john.smith@gmail.com", "password": "secret password" }
-
-
Successful Response
-
Status Code: 200
-
Headers:
- Content-Type: application/json
-
Body:
{ "user": { "id": 1, "firstName": "John", "lastName": "Smith", "email": "john.smith@gmail.com", "username": "JohnSmith" } }
-
-
Error Response: Invalid credentials
-
Status Code: 401
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "Invalid credentials" }
-
-
Error response: Body validation errors
-
Status Code: 400
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "Bad Request", "errors": { "credential": "Email or username is required", "password": "Password is required" } }
-
Creates a new user, logs them in as the current user, and returns the current user's information.
-
Require Authentication: false
-
Request
-
Method: POST
-
URL: /api/users
-
Headers:
- Content-Type: application/json
-
Body:
{ "firstName": "John", "lastName": "Smith", "email": "john.smith@gmail.com", "username": "JohnSmith", "password": "secret password" }
-
-
Successful Response
-
Status Code: 200
-
Headers:
- Content-Type: application/json
-
Body:
{ "user": { "id": 1, "firstName": "John", "lastName": "Smith", "email": "john.smith@gmail.com", "username": "JohnSmith" } }
-
-
Error response: User already exists with the specified email
-
Status Code: 500
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "User already exists", "errors": { "email": "User with that email already exists" } }
-
-
Error response: User already exists with the specified username
-
Status Code: 500
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "User already exists", "errors": { "username": "User with that username already exists" } }
-
-
Error response: Body validation errors
-
Status Code: 400
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "Bad Request", "errors": { "email": "Invalid email", "username": "Username is required", "firstName": "First Name is required", "lastName": "Last Name is required" } }
-
-
Users should be able to view all Songs.
- required auth: False
- Unauthorized and authorized users should be able to view all songs sorted by likes
- Request
- Method: GET
- URL: /api/songs
- Body: none
- Successful Response
{ "songs":[ { "id": 1, "title": "Song Title", "user_id": 1, "song_url": "songurl.com", "image_url": "imageurl.com", "likes": 0, "user_likes": [], "created_at": "2021-11-19 20:39:36", "updated_at": "2021-11-19 20:39:36", "artist": { "id": 1, "username": "DemoUser", "email": "demo@user.io", "first_name": "Demo", "last_name": "User" }, "album_id": 1, } ] }
- Request
-
Users should be able to upload songs.
- Required Auth: True
- Only logined user can add a song
- Request
- Method: POST
- URL: /api/songs
- Body:
{ "title": "Song Title", "audio": "song.mp3" }
- Successful Response (code 201)
{ "id": 1, "title": "Song Title", "user_id": 1, "song_url": "songurl.com", "image_url": "imageurl.com", "likes": 0, "user_likes": [], "created_at": "2021-11-19 20:39:36", "updated_at": "2021-11-19 20:39:36", "artist": { "id": 1, "username": "DemoUser", "email": "demo@user.io", "first_name": "Demo", "last_name": "User" }, "album_id": 1, } - Error Response (code 401)
{ "message": "Bad Request", "errors": { "title": "Title is required", "audio": "Audio is required" } }
- Request
-
Users should be able to update their uploaded songs.
- Required Auth:True
- Request
- Method: POST
- URL: /api/songs/:songId
- Body:
{ "title": "Song Title", "audio": "song.mp3", "image": "image.jpg", }
- Successful Response (code 200)
{ "id": 1, "title": "Song Title", "user_id": 1, "song_url": "songurl.com", "image_url": "imageurl.com", "likes": 0, "user_likes": [], "created_at": "2021-11-19 20:39:36", "updated_at": "2021-11-19 20:39:36", "artist": { "id": 1, "username": "DemoUser", "email": "demo@user.io", "first_name": "Demo", "last_name": "User" }, "album_id": 1, } - Error Response
- User not authorized (code 403)
{ "message": "Forbidden" } - Song couldnt be found (code 404)
{ "Error": "Song could not be found" } - Missing info (code 401)
{ "message": "Bad Request", "errors": { "title": "Title is required" } }
- User not authorized (code 403)
-
User is able to get details of a song by specified ID
- Required Auth: False
- Request
- Method: GET
- URL: /api/songs/:songId
- Body:none
- Successful Response
{ "id": 1, "title": "Song Title", "user_id": 1, "song_url": "songurl.com", "image_url": "imageurl.com", "likes": 0, "user_likes": [], "created_at": "2021-11-19 20:39:36", "updated_at": "2021-11-19 20:39:36", "artist": { "id": 1, "username": "DemoUser", "email": "demo@user.io", "first_name": "Demo", "last_name": "User" }, "album_id": 1, } - Error Response
{ "message":"Song not found" }
-
Users should be able to delete their uploaded songs.
- Required Auth: True
- Request
- Method: DELETE
- URL: /songs/:songId
- Body: none
- Successful Response
{ "message": "Successfully deleted song" } - Error Response
- Song could not be found
{ "errors": "Song could not be found" }- Unauthorized user
{ "message": "Forbidden" }
-
Users should be able to view all albums created by users.
- Required Auth: True
- Request
- Method: GET
- URL: /api/albums
- Body: none
- Successful Response
{ "albums":[ { "id": 1, "user_id": 1, "title": "Album Title", "image_url": "imageurl.com", "created_at": "Sun, 25 Feb 2024 20:33:49 GMT", "updated_at": "Sun, 25 Feb 2024 20:33:49 GMT", "songs": [ { "id": 1, "title": "Song Title", "user_id": 1, "song_url": "songurl.com", "image_url": "imageurl.com", "likes": 0, "user_likes": [], "created_at": "2021-11-19 20:39:36", "updated_at": "2021-11-19 20:39:36", "artist": { "id": 1, "username": "DemoUser", "email": "demo@user.io", "first_name": "Demo", "last_name": "User" }, "album_id": 1, } ], "artist": { "id": 1, "username": "DemoUser", "email": "demo@user.io", "first_name": "Demo", "last_name": "User" }, "album_id": 1 } ] }
-
Users should be able to get album details
- Required Auth: False
- Response
- Method: GET
- URL: /api/albums/:albumId
- Body: none
- Succressful Response
{ "id": 1, "user_id": 1, "title": "Album Title", "image_url": "imageurl.com", "created_at": "Sun, 25 Feb 2024 20:33:49 GMT", "updated_at": "Sun, 25 Feb 2024 20:33:49 GMT", "songs": [ { "id": 1, "title": "Song Title", "user_id": 1, "song_url": "songurl.com", "image_url": "imageurl.com", "likes": 0, "user_likes": [], "created_at": "2021-11-19 20:39:36", "updated_at": "2021-11-19 20:39:36", "artist": { "id": 1, "username": "DemoUser", "email": "demo@user.io", "first_name": "Demo", "last_name": "User" }, "album_id": 1, } ], "artist": { "id": 1, "username": "DemoUser", "email": "demo@user.io", "first_name": "Demo", "last_name": "User" }, "album_id": 1 }
-
Users should be able to add songs to an album they created.
- Required Auth: True
- Request
- Method: POST
- URL: /api/albums/:albumId/songs
- Body:
{ "song_id": 1 }
- Successful Response
{ "id": 1, "user_id": 1, "title": "Album Title", "image_url": "imageurl.com", "created_at": "Sun, 25 Feb 2024 20:33:49 GMT", "updated_at": "Sun, 25 Feb 2024 20:33:49 GMT", "songs": [ { "id": 1, "title": "Song Title", "user_id": 1, "song_url": "songurl.com", "image_url": "imageurl.com", "likes": 0, "user_likes": [], "created_at": "2021-11-19 20:39:36", "updated_at": "2021-11-19 20:39:36", "artist": { "id": 1, "username": "DemoUser", "email": "demo@user.io", "first_name": "Demo", "last_name": "User" }, "album_id": 1, } ], "artist": { "id": 1, "username": "DemoUser", "email": "demo@user.io", "first_name": "Demo", "last_name": "User" }, "album_id": 1 }
-
Users should be able to remove songs from their albums.
- Required Auth: True
- Request
- Method: DELETE
- URL: /api/albums/:albumId/songs/:songId
- Body: none
- Successful Resposne
{ "message": "Successfully Deleted song" } - Err Response
- User not authorized
{ "message": "Forbidden" }- Song not found
{ "errors": "Song could not be found" }
-
Users should be able to delete their albums.
- Required Auth: True
- Request
- Method: DELETE
- URL: /api/albums/:albumId
- Body: none
- Successful Response
{ "message": "Successfully Deleted Album" } - Err Response
- User not authorized
{ "message":"Forbidden" }- Album not found
{ "error":"Album cound not be found" }
-
Users should be able to view the likes on a song.
- Required Auth: False
- Request
- Method: GET
- URL: /api/songs/:songId/likes
- Body: none
- Successful Response
{ }
-
Users should be able to like a song.
- Required Auth: True
- Request
- Method: POST
- URL: /api/songs/:songId/likes
- Successful Response
{ "message":"successfully liked song" }
-
Users should be able to unlike a song.
- Required Auth: True
- Request
- Method: DELETE
- URL: /api/songs/:songId/likes/:likeId
- Body: none
- Successful Response
{ "message":"Successfully unliked song" }
-
Users should be able to view all of their playlists.
- Required Auth:True
- Request
- Method: GET
- URL: /playlists
- body:none
- Successfull Response
{ "playlists":[ { "id": 1, "user_id": 1, "title": "Playlist Title", "description": "Playlist Description", "image_url": "playlistimageurl.com", "created_at": "", "updated_at": "", "songs": [ { "id": 1, "title": "Song Title", "user_id": 1, "song_url": "songurl.com", "image_url": "imageurl.com", "likes": 0, "user_likes": [], "created_at": "2021-11-19 20:39:36", "updated_at": "2021-11-19 20:39:36", "artist": { "id": 1, "username": "DemoUser", "email": "demo@user.io", "first_name": "Demo", "last_name": "User" }, "album_id": 1, } ], } ] }
-
User should be able to view details of their playlist by ID
- Required Auth:True
- Request
- Method: GET
- URL: /playlists/:playlistId
- Body: none
- Successfull Response
{ "id": 1, "user_id": 1, "title": "Playlist Title", "description": "Playlist Description", "image_url": "playlistimageurl.com", "created_at": "Sun, 25 Feb 2024 20:33:49 GMT", "updated_at": "Sun, 25 Feb 2024 20:33:49 GMT", "songs": [ { "id": 1, "title": "Song Title", "user_id": 1, "song_url": "songurl.com", "image_url": "imageurl.com", "likes": 0, "user_likes": [], "created_at": "2021-11-19 20:39:36", "updated_at": "2021-11-19 20:39:36", "artist": { "id": 1, "username": "DemoUser", "email": "demo@user.io", "first_name": "Demo", "last_name": "User" }, "album_id": 1, } ], } - Error Response
{ "errors":"Playlist could not be found" }
-
Users should be able to add a song to one of their playlists.
- Required Auth: True
- Request
- Method: POST
- URL: /playlists/:playlistId/songs/:songId
- Body:
{ "playlist_id": 1, "song_id": 1 }
- Successfull Response
{ "message":"Successfully added song to playlist" } - Error Response
{ "errors":"Playlist could not be found" }{ "errors":"Song could not be found" }
-
Users should be able to remove a song from a playlist.
- Required Auth: True
- Request
- Method:DELETE
- URL: /playlists/:playlistId/songs/:songId
- Body: none
- Successfull Response
{ "message":"Successfully deleted song from playlist" }{ "errors":"Song could not be found in playList" }
