Manage and organize your music.
This application is created for the purpose of testing my development skills for a position.
The application manages data and relations in the given music database.
A standalone Apollo server runs under the hood, which uses Express in the background. The exposed endpoint for GraphQL access is /gql.
The following schema has been implemented:
- Album(id, title)
- Artist(id, name)
- Track(id, name, composer, milliseconds, bytes, price)
Implemented queries:
- albums(title: String): Returns albums with at least a 90% match based on the title.
- album(id: ID!): Retrieves a specific album by its ID.
- artists(name: String): Returns artists with at least a 90% match based on the name. - artist(id: ID!): Retrieves a specific artist by their ID.
- track(id: ID!): Retrieves a specific track by its ID.
FYI: The lookup based on match percentage is done with fuzzysort.
Running the project requires nodejs and npm.
The best way to install them is using nvm.
For further instructions have a look at the official download page.
git clone git@github.com:benhorv/musicdb.git
cd musicdb
npm install
The command above installs all dependencies listed in package.json.
You have to download the database file from here. Then create a database directory in the project root and copy it there. Be careful, the filename must be chinook.db.
cd musicdb
mkdir database
cp path/to/chinook.db ./database/chinook.dbnpm start
This starts the server on port 4000.
npm start starts a server on http://localhost:4000/. You can access the GraphQL endpoint at http://localhost:4000/gql.
The application can be tested straightaway at http://localhost:4000/gql in your browser, which opens the Apollo GraphQL sandbox UI.
query {
albums {
id
title
}
}query {
albums(title: "Facelift") {
id
title
}
}query {
album(id: 5) {
id
title
}
}query {
artists {
id
name
}
}query {
artists(name: "AC/DC") {
id
name
}
}query {
track(id: 8) {
id
name
composer
milliseconds
bytes
price
}
}query {
track(id: 8) {
id
name
composer
milliseconds
bytes
price
artist {
id
name
}
album {
id
title
}
}
}query {
album(id: 6) {
id
title
tracks {
id
name
composer
milliseconds
bytes
price
}
}
}query {
artist(id: 5) {
id
name
albums {
id
title
}
tracks {
id
name
composer
milliseconds
bytes
price
}
}
}Vitest is used for testing. I chose this because it works with TypeScript out of the box.
Run the tests with
npm test