Skip to content

pejamz/akt

 
 

Repository files navigation

AKT - Auktorisoidun kääntäjän tutkintojärjestelmä

  • Maven 3.1+
  • JDK 17
  • PostgreSQL 12.9
  • node v16.13.1 (no need to install if you only build)
  • npm 8.1.3 (no need to install if you only build)

Development

Create and start database, backend, and frontend containers:

docker-compose up

Or

Start up a certain service:

docker-compose up frontend | backend | postgres

To disable default Spring Security configurations, create the following environment variable and restart the containers:

export AKT_UNSECURE=true
docker-compose up

In case of errors, clean cache and recreate volumes:

docker-compose down
docker-compose up --build --force-recreate --renew-anon-volumes

The React app runs on > http://localhost:4000.

 

Backend

Build and Run

Using Maven

mvn clean install
mvn spring-boot:run -Dspring-boot.run.profiles=dev

Or

Using Maven Wrapper

./mvnw clean install
./mvnw spring-boot:run -Dspring-boot.run.profiles=dev

and the app runs on > http://localhost:8080

Required packages get installed automatically.

 

Authentication and Authorisation

Production Profile

CAS configurations are used by default.

 

Development Profile

Dev profile configurations are used by default.

Dev profile uses the following credentials:

  • clerk:clerk
    • User with clerk (virkailija) privileges
  • user:user
    • User with no privileges

Dev profile enables HTTP basic and form authentication for easier command-line tool access.

In order to disable Spring Boot Security use property:

  -Dspring-boot.run.jvmArguments=-Ddev.web.security.off=true

Or

Set AKT_UNSECURE=true environment variable as shown here.

 

Scheduled tasks

EmailScheduledSending does scheduling of sending unsent emails. Every 10 seconds (FIXED_DELAY) it fetches a batch of at most 10 unsent emails (BATCH_SIZE), and tries to send them. If there are loads of emails in the queue, it may send at max. 3600 emails in an hour.

ExpiringAuthorisationsEmailCreator does scheduling of finding expiring authorisations, and creating reminder emails about them. It is run every 12 hours (FIXED_DELAY). The reminder emails that are created are eventually sent via EmailScheduledSending.

 

Styling

Prettier Java is used as a code formatter. It enforces a consistent style by parsing your code and re-printing it with its own rules.

To reformat all Java files, run:

mvn validate

CI/CD validates that the files are formatted properly (maven profile travis).

 

Organizing imports

If you are using an IDE such as IntelliJ, you might want to configure it to organize imports.

For IntelliJ, you can use the following configurations:

ìmport * is disabled: Code Style -> Java -> Imports:

Class count to use import with '*': 999
Names count to use static import with '*': 999

Frontend

Build and Run

npm install
npm run start  # Starts Webpack DevServer 
npm run build # Builds the app for production to the dist folder.

Running tests

End-to-end tests:

npm run test:cypress

Unit and Integration tests

npm run test:jest
npm run test:jest -- -u  # Regenerate snapshots

Styling

In order to keep code clean and easily maintainable please use the following VS Code Extensions.

To reformat all frontend files, run:

npm run lint

Documentation

Health check and overall information

Health check:

http://localhost:8080/akt/api/actuator/health

General information about the running application:

http://localhost:8080/akt/api/actuator/info

OpenAPI

http://localhost:8080/akt/api/api-docs

Swagger

http://localhost:8080/akt/api/swagger-ui.html

In order to make requests work in swagger UI, the application needs to be run with parameter:

mvn spring-boot:run -Dtomcat.util.http.parser.HttpParser.requestTargetAllow=|{}

Localizations

Frontend localizations

I18next is used as an internationalization framework. Localizations are stored in JSON files and committed to git.

For inspection and modification by OPH clerks, it's possible to create an excel sheet as shown below:

 

JSON to XLSX

npx i18n-json-to-xlsx-converter --convert common.json, translation.json

XLSX to JSON

npx i18n-json-to-xlsx-converter --convert translation.xlsx

 

External localisations

Koodisto

Koodisto service is used to fetch language translations. To update translations run:

cd scripts
./koodisto_langs.sh

The above script fetches language codes from the Koodisto service and transforms them into localization files. The created localization files are stored in git.

About

AKT-palvelu

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 60.3%
  • Java 35.1%
  • SCSS 2.7%
  • HTML 1.0%
  • JavaScript 0.5%
  • Shell 0.3%
  • Dockerfile 0.1%