It's a standard Spring Boot web application so far. Has automatic OpenTelemetry tracing to help debug and spot potential performance issues. Uses [Apimposter](https://gitea.dsv.su.se/DMC/apimposter) to mock out backend API dependencies. Reviewed-on: #1 Reviewed-by: Stefan Nenzén <nenzen@dsv.su.se>
31 lines
1.9 KiB
Markdown
31 lines
1.9 KiB
Markdown
# Studentportalen backend-for-frontend (BFF)
|
|
## Development instructions
|
|
### Prerequisites
|
|
- [JDK 24](https://adoptium.net/temurin/releases/?version=24&package=jdk)
|
|
- [Docker](https://docs.docker.com/desktop/)
|
|
- [Docker Compose](https://docs.docker.com/compose/install/) (v2.24.0 or later)
|
|
|
|
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)](http://openjdk.java.net/jeps/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`](https://docs.oracle.com/en/java/javase/24/docs/api/java.base/java/util/concurrent/CompletableFuture.html)
|
|
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](https://gitea.dsv.su.se/DMC/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.
|