Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/carlo-colombo/mms
https://github.com/carlo-colombo/mms
Last synced: 15 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/carlo-colombo/mms
- Owner: carlo-colombo
- Created: 2023-09-22T15:38:03.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-09-25T10:11:07.000Z (over 1 year ago)
- Last Synced: 2024-10-31T19:12:41.299Z (2 months ago)
- Language: Java
- Size: 72.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Music Metadata Service
## API
APIs are defined in the OpenAPI format, Java classes for the API and API Models are generated from the spec. Documentation is available at
https://carlo-colombo.github.io/mms/## Requirements
* Java 17
* Docker for test containers## Assumptions
* This service is called from other services, and authentication is built in the platform where these services are running.
* When an alias is added to an artist the alias became the new main name## Implementation details
* UUID are used to identify artist and track instead of numerical id to avoid exposing information to the user of the service.
* the additional table `main_name` has been created to avoid circular dependency between `alias` and `artist`.## Known issues
* When tracks are created they do not link back to artist. _Justification_: I set up a many-to-many relation between artists and tracks as a track could have many artists and an artist could have multiple tracks, but I am not able to correctly configure the entities to have them save the intermediate table and I think I already invested enough time in understanding the issue and I think I can leave it out of the exercise in the spirit of limiting the time invested.
* Running tests requires to bring up a postgres container before being able to execute the tests. _Workaround_: run `./gradlew run` in another terminal to have a database running.## How to run
To run against a test container just execute `./gradlew run`, to instead set the database
to an external database set the environment variables and run it.```bash
export DATASOURCES_DEFAULT_USERNAME=postgres
export DATASOURCES_DEFAULT_PASSWORD=mysecretpassword
export DATASOURCES_DEFAULT_URL=jdbc:postgresql://localhost:5432/postgres
```## Build images
* native (~115MB, Startup completed in 158ms) `./gradlew dockerBuildNative` (longer time to compile to native using GraalVM)
* jvm (~350MB, Startup completed in 1023ms ) `./gradlew dockerBuild`### Run
```bash
export DATASOURCES_DEFAULT_USERNAME=postgres
export DATASOURCES_DEFAULT_PASSWORD=mysecretpassword
export DATASOURCES_DEFAULT_URL=jdbc:postgresql://localhost:5432/postgres# exposes port 8080 as we are using postgres container network for the service as well
docker run -it -p 8080:8080 --rm --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword postgresdocker run -it --rm --network=container:some-postgres -e DATASOURCES_DEFAULT_URL -e DATASOURCES_DEFAULT_USERNAME -e DATASOURCES_DEFAULT_PASSWORD metadata-music-service:latest
```## How to run tests
`./gradlew run` to bring up a postgres testcontainer
`./gradlew test --rerun` (to always execute them)## Database schema
```mermaid
erDiagram
artist {
uuid id PK
}
alias {
int id PK
string name
uuid artist_id FK
}
main_name {
uuid artist_id PK
int alias_id FK
}
artist_of_the_day {
date date PK
uuid artist_id FK
}
track {
uuid id PK
string genre
string title
string album
int length_in_seconds
}alias }|--|| artist : ""
main_name ||--|| artist : ""
main_name ||--|| alias: ""
artist_of_the_day }|--o|artist:""
artist }o--o{ track : ""
```