SpringBoot Kotlin web app for interfacing with the Naomi model for joint small-area estimation of HIV prevalence, ART coverage, and HIV incidence via the hintr package.
Requirements:
- Docker
- npm
- openjdk 11 Mac users may find it easier to install adoptopenjdk-11k rather than openjdk-11:
wget -qO - https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | sudo apt-key add -
add-apt-repository --yes https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/
apt-get update
apt-get install adoptopenjdk-11-hotspot -y
- coreutils or realpath (Mac users only)
- Clone this repo
- Run
npm install
fromsrc/app/static
- Run
./scripts/run-development-dependencies.sh
to start docker instances of hint-db and hintr and add a test user with usernametest.user@example.com
and passwordpassword
. - Run
npm run build
fromsrc/app/static
to compile front-end dependencies. - Run app from your IDE or by
./src/gradlew -p src :app:bootRun
to serve the app on port 8080
To run with hot reloading of the front end, after installing npm packages and running development dependencies.
- Open a terminal at
src/app/static
and runnpm run serve
- In another terminal, from the root run
src/gradlew -PhotReload=true -p src app:bootRun
For more information about developing the front-end see src/app/static/README
By default, when running up the app locally we use our own authentication system. On production we are using Auth0 to manage users and enable SSO with the ADR. Sometimes it can be useful to run up the local app using Auth0 authentication, so we can develop or test those slightly different UIs. To run locally with Auth0
- Read the secrets from vault
vault read secret/hint/oauth2/development
if you want to use the production auth0 tenant with dev ADR. - Place these into the
config.properties
at./src/app/src/main/resources/config.properties
in the following wayoauth2_client_id
to be theid
valueoauth2_client_secret
to be thesecret
valueoauth2_client_url
to be theurl
valueoauth2_client_audience
to be theaudience
valueoauth2_client_adr_server_url
to be theadr_server_url
value
- Set the
oauth2_login_method
inconfig.properties
to true - Ensure that you do not commit the secret to github
Ensure dependencies are running and then execute tests on the command line or through IntelliJ
./scripts/run-development-dependencies.sh
./src/gradlew -p src :app:test
To run a specific test alone, add --test
+ the fully qualified class name to the command. For example, the command for running ProjectsControllerTests.kt would be: ./src/gradlew -p src :app:test --tests org.imperial.mrc.hint.unit.controllers.ProjectsControllerTests
./src/gradlew -p src :app:detektMain
If the database schema has changed, you can regenerate the database interface code (in /src/databaseInterface)
by running ./src/gradlew -p src :generateDatabaseInterface:run
while the database container is running.
HINT Versions are recorded here. The latest version should match the value of currentHintVersion in
src/app/static/src/app/hintVersion.ts
If you make any change to the application which affects its functionality (i.e. anything other than a refactor, or documentation or CI change, you should update the version by adding an entry to NEWS.md and setting currentHintVersion).
Versions should follow the semantic versioning format, so you should update the:
- MAJOR version when you make incompatible changes (e.g. a change to serialised version state format),
- MINOR version when you add functionality in a backwards compatible manner, and
- PATCH version when you make backwards compatible bug fixes.
This may cause relatively frequently conflicts since more than one person is likely to be working on a new version at a time. In this case, you should give your branch its own new version number, rather than rolling your changes into the same version number as changes from another branch.
A docker image containing the app is created as part of the GitHub actions build. A CLI image is also created as part of the GitHub build.
Run docker run -p 8080:8080 --name hint ghcr.io/hivtools/hint:branch_name
to run a built image. The app will not start until
config is provided at /etc/hint/config.properties
. This config is added during deployment with
hint-deploy