The Record Shop API is a RESTful API designed to provide a robust backend for managing a record shop's catalog. Built using Java and Spring Boot, following the MVC design pattern with a focus on best practises.
- Manage albums and artists with full CRUD operations.
- Search and filter albums by:
- Genre
- Release Year
- Artist Name
- Exception handling for robust error management.
- Database support for H2 (in-memory) during development and configurable for PostgreSQL or other relational databases
Before running the project, ensure you have the following installed:
- Java Development Kit (JDK) 17+
- Maven for building and managing dependencies
- An IDE (e.g. Intellij IDEA, Eclipse, or VS code)
- Clone the repository:
git clone https://github.com/yourusername/record-shop-api.git
cd record-shop-api- Configure the database:
- By default, the API uses H2 in-memory database for development.
- To switch to a production ready database like PostgreSQL:
- create a
application-rds.propertiesfile:
spring.datasource.url=jdbc:postgresql://localhost:5432/recordshop spring.datasource.driverClassName=org.postgresql.Driver spring.datasource.username=<your_username> spring.datasource.password=<your_password> spring.jpa.hibernate.ddl-auto=update
- Set the active profile to
rdsfor external database configuration in theapplication.propertiesfile:
spring.profiles.active=rds - create a
- Build the project:
mvn clean install- Run the application:
- Open the project in your IDE of choice.
- Navigate to the
RecordShopApiApplicationclass:
src/main/java/recordshop/RecordShopApiApplication.java - Run the
mainmethod.
| HTTP Method | Endpoint | Description |
|---|---|---|
| GET | /albums |
Get all albums. |
| GET | /albums?query=value |
Search albums by genre, release year, or artist name. |
| GET | /albums/{id} |
Get album by ID. |
| POST | /albums |
Add a new album. |
| PUT | /albums/{id} |
Update an album. |
| DELETE | /albums/{id} |
Delete an album. |
This API includes a comprehensive test suite to ensure all features function as expected.
Tests include:
- Repository tests for custom database interactions
- Service-layer tests for business logic.
- Controller tests to validate endpoints.
- Open the project in your IDE.
- Navigate to the test folder:
src/test/java - Run the test suite to validate all functionality.
Created by Kye Yee | 2024