To build whole module run `mvn clean install`. This command also copy FE part of application to output `.jar`. <br>
To run application from command line you have to set your database (if running locally - see developer\`s guide) and run command `mvn spring-boot:run -{profile}`.
To build whole module run `mvn clean install`. This command also copy frontend part of the application to output `.jar`. <br>
To run application from command line, you have to set your database (see developer\`s guide how to run it locally) and run command `mvn spring-boot:run {profile}`.
Application supports 3 profiles:
* production `-Pprod`
* development `-Pdev`
* testing (mainly for Gitlab CI tests) `-Ptest`
Application supports 2 profiles:
* production: `-Pprod`
* development: `-Pdev`
---
## Developer\`s guide
Application is divided into frontend application via [React](https://reactjs.org/) library, [THREE.js](https://threejs.org/) and other supplement packages.
Application is divided into the frontend application via [React](https://reactjs.org/) library, [THREE.js](https://threejs.org/) and other supplement packages.
Backend is written in [Spring Boot](https://spring.io/projects/spring-boot)(version 2.7.5).
### Frontend application
Can be found inside `frontend` folder in `Web` module. There are also environment files that determine if application is used in production or development mode (`.env.development` and `.env.production`).
There are defined backend base URLs and other specific variables. For tooling is used [Vite](https://vitejs.dev/).
Can be found inside `frontend` folder in `Web` module. Proxy servers for development are set in: `vite.config.ts`. For tooling is used [Vite](https://vitejs.dev/).
Main language is [Typescript](https://www.typescriptlang.org/) so everything has to be correctly typed (no usage of `any`). And UI component library is [MUI](https://mui.com/).
@@ -61,12 +59,12 @@ and after every change and save content is reloaded.
### Backend application
Firstly we have to set up `application.properties` more precisely development properties that will match our local setup. Go inside folder: `./src/main/resources`. Here open file: `application-dev.properties`.
This file should contain only your local values (aka postgres database name, username and password). So after creating local database fill these attributes correctly and **!DO NOT PULL THIS FILE TO ORIGIN!**.
Firstly, we have to set up `application.yml` more precisely development properties that will match our local setup. Go inside folder: `./src/main/resources`. Here open file: `application-dev.yml`.
This file should contain only your local values (aka postgres database name, username and password). So after creating local database fill these attributes correctly and **!DO NOT PUSH THIS FILE TO ORIGIN!**.
After this setup we can run command: `mvn clean install -Pdev` if we didn't before for whole project. This will create runnable `.jar` file with frontend application bundled in.
After this setup we can run command: `mvn clean install` if we didn't before for whole project. This will create runnable `.jar` file with frontend application bundled in.
<br>
To start server run command: `mvn spring-boot:run-Pdev`(notice all commands are run with `-Pdev` argument to say application that we want to start it in development profile, so it will pick development properties).
To start server run command: `mvn spring-boot:run` (`-Pdev`profile is default profile set in `pom.xml` it will start it in development profile, so it will pick development properties).
#### Manipulating database
@@ -75,12 +73,25 @@ that will run at the start of application (only changelogs that didn't already r
inside folder: `./src/main/resources/db/changelog`. Naming convention is: `changelog-{id}` where id is integer incrementing by 1 (it has to be unique) and this file is after included into main
file `master-changelog.xml`. Each changelog can contain multiple `<changeSet>` tags where each have to have unique id starting with id of file.
#### Running tests
To run tests, the developer has to have installed [Docker](https://www.docker.com/). No registration or running special images are needed only start docker. Tests will create `@Testcontainer` with PostgreSQL database to have
the same environment as in production. `AbstractIntegratrionTest` contains all setup and `@MockBean` necessary. This implementation has one limitation that is impossibility running all tests at once because
the container is not shared across classes. Developer has to start each test class manually.
#### Mail service
To test mail service in development, install NPM package [maildev](https://www.npmjs.com/package/maildev) which provide simple GUI and mail server. All properties for Spring Boot application are already
implemented in `application-dev.yml` file. If you want to run mail server on different ports you have to change these settings also.
#### Folder system:
*`config` - all configuration files (Spring security, Jwt tokens etc.)
*`controllers` - all REST API controllers
*`dto` - special data classes used for mapping objects for transport between FE and BE
*`filter` - used for Spring security (authentication, authorization...)
*`exceptions` - all custom exceptions and main `@ControllerAdvice` are defined here
*`mail` - classes for mail service
*`models` - application models (database follows these object as tables)
*`repostory` - folder for files to handle operations with models (deletion, update etc)
*`security` - all classes for Spring Security - filters, permission evaluators
*`services` - folder for business logic of every endpoint