A Spring Boot app to manage Risk and Need Assessments across HMPPS.
Swagger API documentation is available
- Java JDK 11+
- An editor/IDE
- Gradle
- Docker
- Postgres
- OAuth (running in a container)
- Offender Assessments Updates Service
- Offender Assessments API
In order to run the service locally, Nomis OAuth Service is required. This can be run locally using the docker-compose.yml file which will pull down the latest version. From the command line run:
docker-compose up
This service is built using Gradle. In order to build the project from the command line and run the tests, use:
./gradlew clean build
The created JAR file will be named "hmpps-assessments-api-<yyyy-mm-dd>.jar
", using the date that the build takes place in the format yyyy-mm-dd
.
The configuration can be changed for the api to use an in-memory H2 database by using the spring boot profile dev
. On the command line run:
SPRING_PROFILES_ACTIVE=dev
java -jar build/libs/hmpps-assessments-api-<yyyy-mm-dd>.jar
This configuration can be changed to use a Postgres database using the spring boot profile postgres
.
The service makes use of Postgres JSONB fields so it is advisable to run with postgres when making database changes to avoid issues with invlaid UUIDs breaking the build
On the command line run:
SPRING_PROFILES_ACTIVE=postgres
java -jar build/libs/hmpps-assessments-api-<yyyy-mm-dd>.jar
The generated documentation for the api can be viewed at http://localhost:8080/swagger-ui.html
./gradlew ktlintApplyToIdea addKtlintFormatGitPreCommitHook will apply ktlint styles to intellij and also add a pre-commit hook to format all changed kotlin files.
/ping
: will respondpong
to all requests. This should be used by dependent systems to check connectivity to
offender assessment service, rather than calling the/health
endpoint./health
: provides information about the application health and its dependencies. This should only be used
by offender assessment service health monitoring (e.g. pager duty) and not other systems who wish to find out the
state of offender assessment service./info
: provides information about the version of deployed application.
- Go to edit configurations for Spring Boot in run/debug configurations for
HmppsAssessmentApiApplication
in Intellij - Set active profile to
postgres
- Add the following environment variables as a single semicolon delimited line to point to the dev downstream services:
- OAUTH_ENDPOINT_URL=https://sign-in-dev.hmpps.service.justice.gov.uk/auth;
- ASSESSMENT_UPDATE_API_BASE_URL=https://asmnt-updte-dev.aks-dev-1.studio-hosting.service.justice.gov.uk;
- ASSESSMENT_API_BASE_URL=https://offender-dev.aks-dev-1.studio-hosting.service.justice.gov.uk;
- ASSESS_RISKS_AND_NEEDS_API_BASE_URL=https://assess-risks-and-needs-dev.hmpps.service.justice.gov.uk/;
- AUDIT_BASE_URL=https://audit-api-dev.hmpps.service.justice.gov.uk;
- ASSESSMENT_API_ID=<speak to another dev to get this>;
- ASSESSMENT_API_CLIENT_SECRET=<speak to another dev to get this>;
- ASSESS_RISKS_AND_NEEDS_API_ID=<speak to another dev to get this>;
- ASSESS_RISKS_AND_NEEDS_API_CLIENT_SECRET=<speak to another dev to get this>;
- AUDIT_CLIENT_ID=<speak to another dev to get this>;
- AUDIT_CLIENT_SECRET=<speak to another dev to get this>;
- Run
docker-compose up redis postgres
to start the cache layer and database - Start
HmppsAssessmentApiApplication
in Intellij - To create an oauth token do the following in Postman
- Set authorization
basic auth
and get credentials from another dev - POST https://sign-in-dev.hmpps.service.justice.gov.uk/auth/oauth/token?grant_type=password&username=<speak_to_another_dev_to_get_this>&password=<speak_to_another_dev_to_get_this> in Postman or similar
- The response will contain an
access_token
which will used as yourbearer token
when sending a request to ahmpps-assessments-api
endpoint.
- Set authorization