Skip to content

Music Shop is a platform where you can search your favourite music and purchase songs that you like.

License

Notifications You must be signed in to change notification settings

panaitescu-paul/Music-Shop-Platform-PHP-2021

Repository files navigation

Music Shop Platform - PHP

Music Shop is a platform where you can search your favourite music and purchase songs that you like.

The application’s architecture is divided into a Backend that serves database information in a RESTful API, and a Frontend that consumes this information using Ajax calls.

Preview:

alt text

alt text

alt text

alt text

alt text

alt text

alt text

alt text

alt text

alt text

API Documentation

Main usage:

http://<server_name>/WAD-MA2/<end_point>

Endpoints for API documentation:

Method Usage Description
GET / Returns the API description for CRUD methods applied on Albums, Artists, Tracks, Customers

Examples:

GET http://localhost/WAD-MA2/

Endpoints for Artists:

Method Usage Description
GET /artists Returns information of all artists
GET /artists/<artist_id> Returns detailed information of the artist with ID <artist_id>
GET /artists/?name=<search_text> Returns information of those artists whose name contains <search_text>
POST /artists

Request body
Adds a new artist

name
POST /artists/<artist_id>

Request body
Updates the artist with ID <artist_id>

name
DELETE /artists/<artist_id> Deletes the artist with ID <artist_id>

Examples for Artists:

GET http://localhost/WAD-MA2/artists
GET http://localhost/WAD-MA2/artists/1
GET http://localhost/WAD-MA2/artists/?name=John
POST http://localhost/WAD-MA2/artists
POST http://localhost/WAD-MA2/artists/1
DELETE http://localhost/WAD-MA2/artists/1

Endpoints for Albums:

Method Usage Description
GET /albums Returns information of all albums
GET /albums/<album_id> Returns detailed information of the album with ID <album_id>
GET /albums/?title=<search_text> Returns information of those albums whose title contains <search_text>
POST /albums

Request body
Adds a new album

title
POST /albums/<album_id>

Request body
Updates the album with ID <album_id>

title
DELETE /albums/<album_id> Deletes the album with ID <album_id>

Examples for Albums:

GET http://localhost/WAD-MA2/albums
GET http://localhost/WAD-MA2/albums/1
GET http://localhost/WAD-MA2/albums/?title=Album1
POST http://localhost/WAD-MA2/albums
POST http://localhost/WAD-MA2/albums/1
DELETE http://localhost/WAD-MA2/albums/1

Endpoints for Tracks:

Method Usage Description
GET /tracks Returns information of all tracks
GET /tracks/<track_id> Returns detailed information of the track with ID <track_id>
GET /tracks/?name=<search_text> Returns information of those tracks whose name contains <search_text>
POST /tracks

Request body
Adds a new track

name, albumId, mediaTypeId, genderId, composer, milliseconds, bytes, unitPrice
POST /tracks/<track_id>

Request body
Updates the track with ID <track_id>

name, albumId, mediaTypeId, genderId, composer, milliseconds, bytes, unitPrice
DELETE /tracks/<track_id> Deletes the track with ID <track_id>

Examples for Tracks:

GET http://localhost/WAD-MA2/tracks
GET http://localhost/WAD-MA2/tracks/1
GET http://localhost/WAD-MA2/tracks/?name=Track1
POST http://localhost/WAD-MA2/tracks
POST http://localhost/WAD-MA2/tracks/1
DELETE http://localhost/WAD-MA2/tracks/1

Endpoints for Customers:

Method Usage Description
GET /customers Returns information of all customers
GET /customers/<customer_id> Returns detailed information of the customer with ID <customer_id>
GET /customers/?email=<search_text> Returns information of those customers whose email is <search_text>
POST /customers


Request body
Adds a new customer

firstName, lastName, password, company, address, city, state, country, postalCode, phone, fax, email
POST /customers/<customer_id>


Request body
Updates the customer with ID <customer_id>

firstName, lastName, password, company, address, city, state, country, postalCode, phone, fax, email, newPassword
DELETE /customers/<customer_id> Deletes the customer with ID <customer_id>

Examples for Customers:

GET http://localhost/WAD-MA2/customers
GET http://localhost/WAD-MA2/customers/1
GET http://localhost/WAD-MA2/customers/?email=name@gmail.com
POST http://localhost/WAD-MA2/customers
POST http://localhost/WAD-MA2/customers/1
DELETE http://localhost/WAD-MA2/customers/1

Sample Output:

Get Artist with id 1

{
    "ArtistId": "1",
    "Name": "AC/DC"
}

Get Album with id 1

{
    "AlbumId": "1",
    "Title": "For Those About To Rock We Salute You",
    "ArtistId": "1"
}

Get Track with id 1

{
    "TrackId": "1",
    "Name": "For Those About To Rock (We Salute You)",
    "AlbumId": "1",
    "MediaTypeId": "1",
    "GenreId": "1",
    "Composer": "Angus Young, Malcolm Young, Brian Johnson",
    "Milliseconds": "343719",
    "Bytes": "11170334",
    "UnitPrice": "0.99"
}

Get Customer with id 1

{
    "CustomerId": "1",
    "FirstName": "Luís",
    "LastName": "Gonçalves",
    "Password": "$2y$10$WtD6WywiBP7qNi8yZj7gYuIhjTy1xsAwAKSEgXj/ftRZWTLjz1cpu",
    "Company": "Embraer - Empresa Brasileira de Aeronáutica S.A.",
    "Address": "Av. Brigadeiro Faria Lima, 2170",
    "City": "São José dos Campos",
    "State": "SP",
    "Country": "Brazil",
    "PostalCode": "12227-000",
    "Phone": "+55 (12) 3923-5555",
    "Fax": "+55 (12) 3923-5566",
    "Email": "luisg@embraer.com.br"
}

Get Artists with the name John

[
    {
        "ArtistId": "222",
        "Name": "Academy of St. Martin in the Fields, John Birch, Sir Neville Marriner & Sylvia McNair"
    },
    {
        "ArtistId": "263",
        "Name": "Equale Brass Ensemble, John Eliot Gardiner & Munich Monteverdi Orchestra and Choir"
    },
    {
        "ArtistId": "170",
        "Name": "Jack Johnson"
    },
    {
        "ArtistId": "218",
        "Name": "Orchestre Révolutionnaire et Romantique & John Eliot Gardiner"
    }
]

Get Albums with the title Song

[
    {
        "AlbumId": "262",
        "Title": "Quiet Songs",
        "ArtistId": "197"
    },
    {
        "AlbumId": "137",
        "Title": "The Song Remains The Same (Disc 1)",
        "ArtistId": "22"
    },
    {
        "AlbumId": "138",
        "Title": "The Song Remains The Same (Disc 2)",
        "ArtistId": "22"
    }
]

Get Tracks with the name Radio Song

[
    {
        "TrackId": "1472",
        "Name": "Radio Song",
        "AlbumId": "119",
        "MediaTypeId": "1",
        "GenreId": "4",
        "Composer": "C. Cester/C. Muncey/N. Cester",
        "Milliseconds": "272117",
        "Bytes": "8871509",
        "UnitPrice": "0.99"
    },
    {
        "TrackId": "2284",
        "Name": "Radio Song",
        "AlbumId": "187",
        "MediaTypeId": "1",
        "GenreId": "4",
        "Composer": "Bill Berry/Michael Stipe/Mike Mills/Peter Buck",
        "Milliseconds": "255477",
        "Bytes": "8421172",
        "UnitPrice": "0.99"
    }
]

Get Customers with the email n@gmail.com

[
    {
        "CustomerId": "24",
        "FirstName": "Frank",
        "LastName": "Ralston",
        "Password": "$2y$10$WtD6WywiBP7qNi8yZj7gYuIhjTy1xsAwAKSEgXj/ftRZWTLjz1cpu",
        "Company": null,
        "Address": "162 E Superior Street",
        "City": "Chicago",
        "State": "IL",
        "Country": "USA",
        "PostalCode": "60611",
        "Phone": "+1 (312) 332-3232",
        "Fax": null,
        "Email": "fralston@gmail.com"
    }
]

Author:

Paul Panaitescu