Coder Social home page Coder Social logo

pcq-backend's Introduction

PCQ Backend Application

License: MIT Quality Gate Status Security Rating Vulnerabilities Maintainability Rating Coverage

This is the frontend for the protected characteristics questionnaire service. This service will ask a set of questions that will help us check we are treating people fairly and equally. It helps us to meet our commitment to equality (under the Equality Act 2010).

Overview

pcq-frontendpcq-backendpcq-consolidation-servicepcq-shared-infrastructurepcq-loader


Purpose

This is the Protected Characteristics Back-End application that will save user's answers to the database, fetch PCQ Ids that don't have an associated case record and add case information to a PCQ record in the database. The API will be invoked by two components - PCQ front-end and the Consolidation service

What's inside

The application exposes health endpoint (http://localhost:4550/health).

Plugins

The application uses the following plugins:

Building and deploying the application

Building the application

The project uses Gradle as a build tool. It already contains ./gradlew wrapper script, so there's no need to install gradle.

To build the project execute the following command:

  ./gradlew build

Running the application

To run the PostgreSQL 11 PCQ database, execute docker-compose to build the database from the postgreSQL docker image:

  docker-compose -f docker-compose.yml up pcq-database

To run the PCQ Backend application, execute the gradle run command - this also adds the PCQ schema to the database.

  ./gradlew run

Finally to use the pcq-backend application, you'll need to add the encryption package to PostgreSQL. Using your favourite SQL client run the following from the PCQ database. See .env file for dev database password.

 psql -h 0.0.0.0 -p 5050 -d pcq -u pcquser
 CREATE EXTENSION IF NOT EXISTS pgcrypto;

Environment variables

The .env file has a list of the environment variables in use by the pcq-backend and pcq-database components. These are as follows:

  • PCQ_DB_NAME
  • PCQ_DB_HOST
  • PCQ_DB_PORT
  • PCQ_DB_USERNAME
  • PCQ_DB_PASSWORD
  • FLYWAY_URL
  • FLYWAY_USER
  • FLYWAY_PASSWORD
  • FLYWAY_NOOP_STRATEGY
  • JWT_SECRET
  • DB_ENCRYPTION_KEY

There is no need to export these values if pcq-backend repo is checked out. If another service is using the pcq-backend application, the environment values are available through a batch script:

  source ./bin/set-pcq-docker-env.sh

Manually building the PCQ Database using Flyway

The pcq-backend application will automatically create the PCQ database definitions from the flyway scripts included in the build. However if you would like to add the table definitions manually you'll need to execute the gradle migrate script:

  ./gradlew -Pflyway.user=pcquser -Pflyway.password=pcqpass -Pflyway.url=jdbc:postgresql://0.0.0.0:5050/pcq flywayMigrate

Running the application in Docker

Build docker image

Create docker image:

  docker-compose build

Bring the database and pcq-backend application up in Docker. by executing the following command:

  docker-compose up

az login az acr login --name hmctspublic --subscription DCD-CNP-Prod

This will start the API container exposing the application's port (set to 4550 in this template app).

In order to test if the application is up, you can call its health endpoint:

  curl http://localhost:4550/health

You should get a response similar to this:

  {"status":"UP","diskSpace":{"status":"UP","total":249644974080,"free":137188298752,"threshold":10485760}}

Notes:

Accessing Azure Container Repository

Run the following to install the azure and kubernetes command-line tools

  brew install azure-cli
  az acs kubernetes install-cli

login to azure - you'll not need hmctsprivate access for PCQ.

  az login (will open a browser to login)
  az acr login --name hmctspublic --subscription DCD-CNP-Prod
  az acr login --name hmctsprivate --subscription DCD-CNP-Prod

Removing old docker images

Old containers can be removed by executing the following command:

  docker rm $(docker ps -a -q)

You may need to forcibly remove any relevant images by executing the following command:

  docker rmi $(docker images -q)

Finally you can remove all volumes - note this removes all existing database values:

  docker volume rm $(docker volume ls -q)

There is no need to remove postgres and java or similar core images.

Hystrix

Hystrix is a library that helps you control the interactions between your application and other services by adding latency tolerance and fault tolerance logic. It does this by isolating points of access between the services, stopping cascading failures across them, and providing fallback options. We recommend you to use Hystrix in your application if it calls any services.

Hystrix circuit breaker

This API has Hystrix Circuit Breaker already enabled. It monitors and manages all the@HystrixCommand or HystrixObservableCommand annotated methods inside @Component or @Service annotated classes.

Other

Hystrix offers much more than Circuit Breaker pattern implementation or command monitoring. Here are some other functionalities it provides:

License

This project is licensed under the MIT License - see the LICENSE file for details

pcq-backend's People

Contributors

bradley-hmcts avatar bugbare-reform avatar davejones74 avatar dependabot[bot] avatar ferdi-cocelli avatar hmcts-jenkins-cft[bot] avatar hmcts-jenkins-j-to-z[bot] avatar hmcts-jenkins-pcq[bot] avatar jamescollettcgi avatar kaanaktas avatar manojkulkarni-hmcts avatar manojkulkarnicgi avatar martinyspasov avatar mokainos avatar priyankaverma21 avatar rababrabab avatar rapolaskaseliscgi avatar reespozzi avatar renovate[bot] avatar skandala-cgi avatar sonny-hmcts avatar tchow8 avatar timja avatar yashikno avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

pcq-backend's Issues

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: Cannot find preset's package (local>hmcts/.github//renovate/automerge-minor)

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Awaiting Schedule

These updates are awaiting their schedule. Click on a checkbox to get an update now.

  • Update plugin org.springframework.boot to v3.3.4

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

docker-compose
docker-compose.yml
  • postgres 11-alpine
dockerfile
Dockerfile
  • hmctspublic.azurecr.io/base/java 21-distroless
docker/database/Dockerfile
  • postgres 11.22-alpine
github-actions
.github/workflows/swagger.yml
  • actions/checkout v4
  • actions/cache v4
  • actions/setup-java v4
gradle
build.gradle
  • org.flywaydb:flyway-database-postgresql 10.18.0
  • uk.gov.hmcts.java 0.12.63
  • io.spring.dependency-management 1.1.6
  • net.serenity-bdd.serenity-gradle-plugin 4.2.1
  • org.springframework.boot 3.3.3
  • org.owasp.dependencycheck 10.0.4
  • com.github.ben-manes.versions 0.51.0
  • info.solidsoft.pitest 1.15.0
  • org.sonarqube 5.1.0.4882
  • com.gorylenko.gradle-git-properties 2.4.2
  • io.freefair.lombok 8.10
  • org.flywaydb.flyway 10.18.0
  • checkstyle 10.18.1
  • com.azure:azure-core-http-netty 1.15.4
  • io.netty:netty-buffer 4.1.113.Final
  • io.netty:netty-codec 4.1.113.Final
  • io.netty:netty-codec-http 4.1.113.Final
  • io.netty:netty-codec-http2 4.1.113.Final
  • io.netty:netty-codec-socks 4.1.113.Final
  • io.netty:netty-common 4.1.113.Final
  • io.netty:netty-handler 4.1.113.Final
  • io.netty:netty-handler-proxy 4.1.113.Final
  • io.netty:netty-resolver 4.1.113.Final
  • io.netty:netty-transport 4.1.113.Final
  • io.netty:netty-transport-native-epoll 4.1.113.Final
  • io.netty:netty-transport-native-kqueue 4.1.113.Final
  • io.netty:netty-transport-native-unix-common 4.1.113.Final
  • io.netty:netty-codec-dns 4.1.113.Final
  • io.netty:netty-resolver-dns 4.1.113.Final
  • io.netty:netty-resolver-dns-native-macos 4.1.113.Final
  • io.netty:netty-resolver-dns-classes-macos 4.1.113.Final
  • io.netty:netty-transport-classes-epoll 4.1.113.Final
  • io.netty:netty-transport-classes-kqueue 4.1.113.Final
  • com.google.guava:guava 33.3.0-jre
  • commons-io:commons-io 2.16.1
  • org.springframework.cloud:spring-cloud-starter-openfeign 4.1.3
  • org.springframework.cloud:spring-cloud-openfeign-core 4.1.3
  • org.springframework.cloud:spring-cloud-dependencies 2023.0.3
  • com.azure:azure-storage-blob 12.27.1
  • com.github.hmcts.java-logging:logging 6.1.6
  • com.github.hmcts:pcq-commons 1.2.5
  • com.github.hmcts:service-auth-provider-java-client 5.2.0
  • com.microsoft.azure:applicationinsights-web 3.5.4
  • com.microsoft.azure:azure-storage 8.6.6
  • commons-fileupload:commons-fileupload 1.5
  • commons-net:commons-net 3.11.1
  • io.jsonwebtoken:jjwt-api 0.12.6
  • javax.xml.bind:jaxb-api 2.3.1
  • org.apache.httpcomponents:httpclient 4.5.14
  • org.flywaydb:flyway-core 10.18.0
  • org.flywaydb:flyway-database-postgresql 10.18.0
  • org.glassfish.jaxb:jaxb-runtime 4.0.5
  • org.postgresql:postgresql 42.7.4
  • org.projectlombok:lombok 1.18.34
  • org.springdoc:springdoc-openapi-starter-webmvc-ui 2.6.0
  • org.springdoc:springdoc-openapi-ui 1.8.0
  • org.springframework.cloud:spring-cloud-starter-bootstrap 4.1.4
  • org.springframework.cloud:spring-cloud-starter-openfeign 4.1.3
  • org.yaml:snakeyaml 2.3
  • com.networknt:json-schema-validator 1.5.1
  • io.jsonwebtoken:jjwt-impl 0.12.6
  • io.jsonwebtoken:jjwt-jackson 0.12.6
  • com.github.hmcts:fortify-client 1.4.4
  • com.github.tomakehurst:wiremock-jre8-standalone 3.0.1
  • info.solidsoft.gradle.pitest:gradle-pitest-plugin 1.15.0
  • io.rest-assured:json-path 5.5.0
  • io.rest-assured:rest-assured-common 5.5.0
  • io.rest-assured:rest-assured 5.5.0
  • io.rest-assured:xml-path 5.5.0
  • net.serenity-bdd:serenity-core 4.2.1
  • net.serenity-bdd:serenity-junit 4.2.1
  • net.serenity-bdd:serenity-rest-assured 4.2.1
  • net.serenity-bdd:serenity-spring 4.2.1
  • org.assertj:assertj-core 3.26.3
  • org.codehaus.sonar-plugins:sonar-pitest-plugin 0.5
  • org.hamcrest:hamcrest 3.0
  • org.pitest:pitest 1.16.3
  • org.testcontainers:postgresql 1.20.1
  • org.testcontainers:testcontainers 1.20.1
  • org.junit.jupiter:junit-jupiter-engine 5.10.3
gradle-wrapper
gradle/wrapper/gradle-wrapper.properties
  • gradle 8.10.1
helm-values
charts/pcq-backend/values.yaml
helmv3
charts/pcq-backend/Chart.yaml
  • java 5.2.1
  • job 2.1.2
terraform
infrastructure/main.tf
infrastructure/sdp.tf
infrastructure/state.tf
  • azuread 2.53.1
  • azurerm 4.2.0
infrastructure/versions.tf
  • hashicorp/terraform >= 0.13
terraform-version
infrastructure/.terraform-version
  • hashicorp/terraform 1.9.5

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.