Studentportalen backend-for-frontend (BFF)

Development instructions

Prerequisites

Start the application with ./mvnw spring-boot:run. Spring will automatically run the required Docker containers. The application will be available at http://localhost:8080 and tracing telemetry can be viewed at http://localhost:16686.

If running via some other means start the containers with docker compose up. Activate the Spring Boot profile "development". Make sure you're using the correct JVM arguments (--enable-preview). Optionally add -javaagent:opentelemetry-javaagent.jar -Dotel.javaagent.configuration-file=opentelemetry-javaagent.properties to enable OpenTelemetry tracing.

Preview features (--enable-preview)

Due to wanting to make many concurrent calls to various backend APIs, preview features have been enabled to gain access to Structured Concurrency (JEP 499). See src/main/java/se/dsv/studentportalen/bff/TestController.java for an example of how to use it. To see it in action browse to http://localhost:8080/test and check the tracing data, and you'll see that the overall duration is much lower than if the calls were made sequentially.

An alternative would be to use CompletableFuture but that would require writing Java in a completely different style with a lot of callbacks instead of the imperative-looking code that Structured Concurrency offers.

Mocking backend APIs

Apimposter is used to mock the backend APIs. The mock data is defined in src/mock-api. See the linked documentation for details on how to define the mock data.