This Backend goal is to provide API for Moj Doklad application. It is written in Java 17 using Spring Boot framework. It is using PostgreSQL database.
2.1 Backend is divided into 3 layers: Controller, Service and Repository.
2.2 Service layer is using DTOs to communicate with Controller layer. Service layer is using Entities to communicate with Repository layer.
2.3 Repository layer is using JPA to communicate with database.
2.4 Controller layer is using DTOs to communicate with Service layer.
2.5 DTOs are mapped to Entities using MapStruct library.
3.1 Authentication is done using JWT.
3.2 JWT is generated using RSA algorithm.
3.3 JWT is stored in HttpOnly cookie.
3.4 JWT is valid for 1 hour.
4.1 Authorization is done using Spring Security.
4.2 Authorization is done using roles.
4.3 Roles are: ROLE_USER, ROLE_ADMIN, ROLE_STAFF.
4.4 ROLE_USER is assigned to every user.
4.5 ROLE_ADMIN is assigned to user and staff with admin privileges.
4.6 ROLE_STAFF is assigned to user and staff with staff privileges.
/api/users
5.1.1
GET /
is return list of users with 200 HTTP Status code
5.1.2GET /{id}
is return user with 200 HTTP Status code
5.1.3POST /
is create and return user with 200 HTTP Status code
5.1.4PUT /{id}
is update user and return with 200 HTTP Status code
5.1.5DELETE /{id}
is delete user with 200 HTTP Status code
5.1.6GET /{username}
is return user by username with 200 HTTP Status code
5.1.7GET /username/{username}
is return user by username with 200 HTTP Status code
5.1.8GET /documents/{id}
is return list of documents by user id with 200 HTTP Status code
5.1.9GET /documents/
is return of documents by authenticated user with 200 HTTP Status code
/api/documents
5.2.1
GET /
is return list of documents with 200 HTTP Status code
5.2.2GET /{id}
is return document with 200 HTTP Status code
5.2.3POST /
is create and return document with 200 HTTP Status code
5.2.4PUT /{id}
is update document and return with 200 HTTP Status code
5.2.5DELETE /{id}
is delete document with 200 HTTP Status code
/api/notifications
5.3.1
GET /
is return list of notifications with 200 HTTP Status code
5.3.2GET /{id}
is return notification with 200 HTTP Status code
5.3.3POST /
is create and return notification with 200 HTTP Status code
5.3.4PUT /{id}
is update notification and return with 200 HTTP Status code
5.3.5DELETE /{id}
is delete notification with 200 HTTP Status code
/api/orders
5.4.1
GET /
is return list of orders with 200 HTTP Status code
5.4.2GET /{id}
is return order with 200 HTTP Status code
5.4.3POST /
is create and return order with 200 HTTP Status code
5.4.4PUT /{id}
is update order and return with 200 HTTP Status code
5.4.5DELETE /{id}
is delete order with 200 HTTP Status code
/api/status
5.5.1
GET /
is return list of statuses with 200 HTTP Status code
5.5.2GET /{id}
is return status with 200 HTTP Status code
5.5.3POST /
is create and return status with 200 HTTP Status code
5.5.4PUT /{id}
is update status and return with 200 HTTP Status code
5.5.5DELETE /{id}
is delete status with 200 HTTP Status code
/api/auth
5.6.1
POST /login
is login user and return with 200 HTTP Status code
5.6.2POST /register
is register user and return with 200 HTTP Status code
/api/services
5.7.1
GET /
is return list of services with 200 HTTP Status code
5.7.2GET /{id}
is return service with 200 HTTP Status code
5.7.3POST /
is create and return service with 200 HTTP Status code
5.7.4PUT /{id}
is update service and return with 200 HTTP Status code
5.7.5DELETE /{id}
is delete service with 200 HTTP Status code
/api/secret
5.8.1
GET /
is return list of secrets with 200 HTTP Status code
5.8.2POST /
is create and return secret with 200 HTTP Status code5.9 DocumentDataController Endpoints
/api/documents-data
5.9.1
GET /create?count=1
is generating documents with random data to simulate real life situations.
/api/notifications-data
5.10.1
GET /create?count=1
is generating notifications with random data to simulate real life situations.
/api/users-data
5.11.1
GET /create?count=1
is generating users with random data to simulate real life situations.
/api/status-data
5.12.1
GET /create?count=1
is generating statuses with random data to simulate real life situations.
/api/orders-data
5.13.1
GET /create?count=1
is generating orders with random data to simulate real life situations.
6.1 Database is PostgreSQL.
6.2 Database is hosted on Heroku.
6.3 Database is using 1 table per entity.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.modelmapper</groupId>
<artifactId>modelmapper</artifactId>
<version>3.1.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.javafaker</groupId>
<artifactId>javafaker</artifactId>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.13.3</version>
</dependency>
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mockito/mockito-core -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.3.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.9.2</version>
<scope>test</scope>
</dependency>