Brickstore is a Spring Boot RESTful API service that implements a catalog and administrative APIs for a small e-commerce/store platform. The codebase follows modern Spring Boot practices (Spring Boot 3.x, Java 21), uses Gradle (Kotlin DSL) for build, Flyway for database migrations, and adopts RFC7807 Problem Details for API error responses.
- Project overview
- Key features
- Tech stack
- Getting started
- Requirements
- Build and run (local)
- Run with Docker (development)
- Configuration and profiles
- Error contract (Problem Details)
- API documentation
- Tests
- Contributing
- License
This repository implements the Brickstore backend service. It provides REST endpoints for domain entities (countries, currencies, users, roles, etc.), integrates database migrations with Flyway, and includes full test coverage using JUnit 5 + Spring Test (MockMvc). The project aims to be a small, well-documented platform to demonstrate best-practice patterns for a Spring REST API.
- RESTful API built with Spring Boot and Spring MVC
- RFC7807-compliant error responses (Problem Details) with compatibility fields for existing clients
- Request tracing via
X-Request-Idand inclusion ofrequestIdandinstance(URN) in error responses - Domain-specific
typeURIs derived fromErrorCodevalues (e.g./problems/country-not-found) - Flyway migrations for schema management (test and main migrations separated)
- OpenAPI / Swagger UI available via springdoc
- Gradle wrapper included for reproducible builds
- Java 21
- Spring Boot 3.x (Spring MVC)
- Gradle (Kotlin DSL)
- Flyway (DB migrations)
- H2 for tests, Postgres used as default dev DB
- JUnit 5, Spring Test (MockMvc)
- springdoc-openapi for API docs
These instructions help you run the service locally for development and testing.
- JDK 21
- Git
- Docker (optional, recommended for DB/dev environment)
- Gradle wrapper is included; you can use
./gradlew(macOS/Linux) orgradlew.bat(Windows)
- Clone the repository:
git clone git@github.com:basilex/brickstore.git
cd brickstore- Build and run tests:
./gradlew clean test- Run the application (dev profile):
./gradlew bootRun --args='--spring.profiles.active=dev'By default the application reads configuration from src/main/resources/application.yaml and profile overrides in application-dev.yaml.
Run the Postgres database and application using Docker Compose (development):
docker compose -f docker-compose.dev.yml up --buildThis starts dependent services defined in docker-compose.dev.yml and the application image.
See docs/Docker.md for a fuller guide including Makefile helpers (make up-dev, make open-swagger, make up-dev-open, etc.).
VS Code troubleshooting
If VS Code becomes slow or the integrated terminal behaves erratically, large state files in VS Code's globalStorage can be a common cause (for example heavy Copilot/extension caches). This repository includes a safe helper to rotate or remove large files:
- Interactive (moves files >5MB to a timestamped backup on your Desktop):
make cleanup-vscode-storage
- Non-interactive delete (dangerous — use with care):
DELETE=1 FORCE=1 ./scripts/cleanup-vscode-globalstorage.sh
See scripts/cleanup-vscode-globalstorage.sh for options (THRESHOLD_BYTES, BACKUP_DIR, DELETE, FORCE).
application.yamlcontains shared configuration.application-dev.yamlandapplication-test.yamlcontain profile-specific overrides.- Tests run with the
testprofile (H2 in-memory DB and test-specific Flyway migrations).
Brickstore uses RFC7807 Problem Details for error responses and provides backward-compatible fields to avoid breaking clients. Important notes:
type: a URI identifying the problem type. For domain errors we derive a stable local path fromErrorCodevalues (e.g.COUNTRY_NOT_FOUND->/problems/country-not-found). For unknown errors this defaults toabout:blank.title/status: HTTP status and a short titledetail/details: human-readable message(s)instance: set tourn:uuid:<requestId>when a request id is availablerequestId: theX-Request-Idused for request correlation- Legacy fields such as
status,error,details, andtimestampare preserved in responses for compatibility with existing clients and tests.
Example error response (404 Not Found):
{
"type": "/problems/country-not-found",
"title": "Not Found",
"status": 404,
"detail": "Country with id 123 not found",
"requestId": "b7e3b2f9-...",
"instance": "urn:uuid:b7e3b2f9-...",
"timestamp": "2025-12-14T...",
"errorCode": "COUNTRY_NOT_FOUND"
}See src/main/java/com/platform/brickstore/api/exception/ProblemErrorAttributes.java and GlobalExceptionHandler.java for the concrete mapping logic.
OpenAPI documentation is available via springdoc. When the application is running in dev mode, visit:
- Swagger UI:
http://localhost:8080/swagger-ui.html(or/swagger-ui/index.htmldepending on springdoc version) - OpenAPI JSON:
http://localhost:8080/v3/api-docs
Run unit and integration tests locally:
./gradlew clean testTests use H2 and test-specific Flyway migrations located under src/test/resources/db/test-migration.
There are integration tests verifying the /error contract and Problem Details formatting.
Contributions are welcome. A suggested workflow:
- Create a feature branch from
dev(namedfeature/...orchore/...). - Run tests and ensure they pass locally.
- Push the branch and open a Pull Request against
dev. - Add a clear PR description and link related issues.
Please keep commits focused and tests passing. If you change the error contract, update docs/API_ERRORS.md and the changelog.
src/main/java/com/platform/brickstore/api/exception/GlobalExceptionHandler.java— application exception handlers producingProblemDetailresponses.src/main/java/com/platform/brickstore/api/exception/ProblemErrorAttributes.java— customErrorAttributesshaping/erroroutput.src/main/java/com/platform/brickstore/api/filter/RequestIdFilter.java— request id propagation and MDC integration.src/main/java/com/platform/brickstore/api/exception/ErrorCode.java— canonical error codes used to derivetypeURIs.src/test/java— tests includingErrorAttributesIntegrationTest.
- See
CHANGELOG.mdfor high-level changes. - See
docs/API_ERRORS.mdfor more details about the Problem Details migration and canonicaltypeURIs.
See the LICENSE file at the project root.
If you'd like, I can adapt this README to include badges (build, coverage), example requests/responses for common endpoints, or a quickstart Docker Compose recipe. Which would you prefer next?
Spring Restful API service
- 2025-12-14: Migrate API error responses to RFC7807 Problem Details. The application now returns RFC7807-style JSON for exceptions and the default
/errorendpoint, while preserving legacy fields (status,error,details,timestamp) for backward compatibility. Responses include arequestIdandinstance(URN) for request correlation. Domain-specifictypeURIs are generated fromErrorCodevalues (for exampleCOUNTRY_NOT_FOUND->/problems/country-not-found). Seedocs/API_ERRORS.mdandCHANGELOG.mdfor more details.