An open API service indexing awesome lists of open source software.

https://github.com/inseefr/queen-back-office

Back-office services for Queen
https://github.com/inseefr/queen-back-office

Last synced: 4 months ago
JSON representation

Back-office services for Queen

Awesome Lists containing this project

README

          

![Build](https://github.com/InseeFr/Queen-Back-Office/actions/workflows/release.yml/badge.svg)

# Queen-Back-Office
Back-office services for Queen
REST API used for communication with Queen/Stromae UI

## Modules
- queen-application: api module for queen
- queen-domain: business logic
- queen-domain-pilotage: business logic for habilitations/interviewer specific features
- queen-domain-depositproof: business logic for deposit proof generation
- queen-infra-db: db access to queen data
- queen-infra-depositproof: deposit proof generation
- queen-infra-pilotage: access to pilotage api (check habilitations, ...)

## Requirements
For building and running the application you need:
- Java 21
- Maven 3

## Install and execute unit tests
Use the maven clean and maven install
```shell
mvn clean install
```

## Running the application locally
On queen-application module:
```shell
mvn spring-boot:run
```

## Database
Queen-Back-Office uses postgresql as data source

## Deployment
### 1. Package the application
```shell
mvn clean package
```
The jar will be generated in `/target` repository

### 2. Launch app with embedded tomcat
```shell
java -jar app.jar
```

### 3. Application Access
To access the swagger-ui, use this url : [http://localhost:8080/swagger-ui/index.html](http://localhost:8080/swagger-ui/index.html)

## Docker/Kubernetes

A Dockerfile is present on this root project to deploy a container. You can [get docker images on docker hub](https://hub.docker.com/r/inseefr/queen-back-office/tags)

[Helm chart repository](https://github.com/InseeFr/Helm-Charts/) is available for the queen backoffice/db/frontend

## Liquibase
Liquibase is enabled by default and run changelogs if needed.

### Generate diff changelog between twos databases
On queen-infra-db module:

```shell
# Don't forget to edit configuration properties in pom.xml for this
mvn liquibase:diff
```

#### Properties
Minimal configuration for dev purpose only (no auth, no habilitation checks on pilotage api)
User is considered as authenticated admin user

```yaml
application:
corsOrigins: https://test.com #mandatory
# define folder where temp files will be created
# /!\ do not use the OS default temp folder or java.io.tmpdir as it causes security issues
# give only access rights to this folder to the user executing the tomcat process
temp-folder: /opt/app/app-temp
spring:
datasource:
url: jdbc:postgresql://localhost:5432/defaultSchema
username:
password:
driver-class-name: org.postgresql.Driver
jpa:
show-sql: true
jackson:
serialization:
indent_output: true
logging:
file:
name: /path/to/log/folder/queen.log
level:
root: INFO
feature:
oidc:
enabled: false

# enable swagger
swagger:
enabled: true

# enable pilotage api
pilotage:
enabled: false

# enable cache
cache:
enabled: true

# enable comment endpoints
comments:
enabled: true

# enable interviewer features
interviewer-mode:
enabled: false
```

Configuration example with OIDC/habilitations/interviewer features enabled

```yaml
application:
corsOrigins: https://test.com #mandatory
# define folder where temp files will be created
# /!\ do not use the OS default temp folder or java.io.tmpdir as it causes security issues
# give only access rights to this folder to the user executing the tomcat process
temp-folder: /opt/app/app-temp
roles:
interviewer: interviewer_role
reviewer: reviewer_role
admin: admin_role
webclient: webclient_role
reviewer-alternative: reviewer_alternative_role
spring:
datasource:
url: jdbc:postgresql://localhost:5432/defaultSchema
username:
password:
driver-class-name: org.postgresql.Driver
logging:
file:
name: /path/to/log/folder/queen.log
level:
root: INFO
feature:
oidc:
enabled: true
auth-server-host: https://auth-server.host
auth-server-url: ${feature.oidc.auth-server-host}/auth
client-id: my-client-id
realm: my-realm
principal-attribute: id-claim
role-claim: role-claim

# enable swagger
swagger:
enabled: true

# enable pilotage api
pilotage:
enabled: true
url:
alternative-habilitation:
url: http://alternative.url
campaignids-regex: ((edt)|(EDT))(\d|\S){1,}

# enable cache
cache:
enabled: true

# enable comment endpoints
comments:
enabled: true

# enable interviewer features
interviewer-mode:
enabled: true
```

## End-Points
- Campaign
- `GET /campaigns` : Retrieve the campaigns the current user has access to
- `GET /admin/campaigns` : Retrieve all campaigns
- `POST /campaigns` : Create a new campaign
- `POST /campaign/context` : Integrate a full campaign (campaign/nomenclatures/questionnaires. The results of the integration indicate the successful/failed integrations
- `DELETE /campaign/{id}` : Delete a campaign

- Questionnaire
- `GET /questionnaire/{id}` : Retrieve the data structure of a questionnaire
- `GET /campaign/{id}/questionnaires` : Retrieve the data structure of all questionnaires linked to a campaign
- `GET /campaign/{idCampaign}/questionnaire-id` : Retrieve all the questionnaire ids for a campaign
- `POST /questionnaire-models` : Create a new questionnaire

- Interrogation
- `GET /interrogations` : Retrieve all interrogations id
- `GET /interrogations/{id}` : Retrieve the interrogation
- `GET /interrogations/{id}/deposit-prof` : Generate and retrieve a deposit proof (pdf file) for an interrogation
- `GET /campaign/{id}/interrogations` : Retrieve all the interrogations of a campaign
- `PUT /interrogations/{id}` : Update an interrogation
- `GET /interrogations/interviewer` : Retrieve all the interrogations of the current interviewer
- `POST /campaign/{id}/interrogation` : Create or update an interrogation
- `DELETE /interrogations/{id}` : Delete an interrogation

- Data
- `GET /interrogations/{id}/data` : Retrieve the data of an interrogation
- `PUT /interrogations/{id}/data` : Update the data of an interrogation

- Comment
- `GET /interrogations/{id}/comment` : Retrieve the comment of an interrogation
- `PUT /interrogations/{id}/comment` : Update the comment of an interrogation

- Nomenclatures
- `GET /questionnaire/{id}/required-nomenclatures` : Retrieve all required nomenclatures of a questionnaire
- `GET /campaign/{id}/required-nomenclatures` : Retrieve all required nomenclatures of a campaign
- `GET /nomenclature/{id}` : Retrieve the json value of a nomenclature
- `POST /nomenclature` : Create/update a nomenclature
- `GET /nomenclatures` : Retrieve all nomenclatures ids

- Personalization
- `GET /interrogations/{id}/personalization` : Retrieve the personalization of an interrogation
- `PUT /interrogations/{id}/personalization` : Update the personalization of an interrogation

- Metadata
- `GET /campaign/{id}/metadata` : Retrieve campaign metadata
- `GET /questionnaire/{id}/metadata` : Retrieve campaign metadata

- Paradata
- `POST /paradata` : Create a paradata event for an interrogation

- StateData
- `GET /interrogations/{id}/state-data` : Retrieve the state-data of an interrogation
- `PUT /interrogations/{id}/state-data` : Update the state-data of an interrogation
- `POST /interrogations/state-data` : Get state-data for all interrogations defined in request body

## Libraries used
- spring-boot-data-jpa
- spring-boot-security
- spring-boot-web
- spring-boot-tomcat
- spring-boot-test
- spring-boot-starter-oauth2-resource-server
- liquibase
- postgresql
- junit
- springdoc
- caffeine (cache)

## License
Please check [LICENSE](https://github.com/InseeFr/Queen-Back-Office/blob/main/LICENSE) file