From f09ea486324364e78ef590d269729aa223275236 Mon Sep 17 00:00:00 2001 From: Tom Weelborg <135610355+tom-weelborg@users.noreply.github.com> Date: Fri, 22 Nov 2024 22:21:44 +0100 Subject: [PATCH 01/38] build: add Spring Boot --- .gitignore | 41 ++++++++-- pom.xml | 82 +++++++++++++++++++ .../java/dev/devlink/DevLinkApplication.java | 13 +++ src/main/resources/application.yml | 10 +++ .../dev/devlink/DevLinkApplicationTests.java | 13 +++ 5 files changed, 152 insertions(+), 7 deletions(-) create mode 100644 pom.xml create mode 100644 src/main/java/dev/devlink/DevLinkApplication.java create mode 100644 src/main/resources/application.yml create mode 100644 src/test/java/dev/devlink/DevLinkApplicationTests.java diff --git a/.gitignore b/.gitignore index 2f43530..b435447 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,12 @@ +HELP.md target/ +!**/src/main/**/target/ +!**/src/test/**/target/ + +### Maven ### +.mvn +mvnw +mvnw.cmd pom.xml.tag pom.xml.releaseBackup pom.xml.versionsBackup @@ -6,12 +14,31 @@ pom.xml.next release.properties dependency-reduced-pom.xml buildNumber.properties -.mvn/timing.properties -# https://github.com/takari/maven-wrapper#usage-without-binary-jar -.mvn/wrapper/maven-wrapper.jar -# Eclipse m2e generated files -# Eclipse Core -.project -# JDT-specific (Eclipse Java Development Tools) +### STS ### +.apt_generated .classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..5bf1470 --- /dev/null +++ b/pom.xml @@ -0,0 +1,82 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 3.3.5 + + + dev + devlink + 0.0.1-SNAPSHOT + DevLink + Backend for the DevLink platform - developed with Java Spring Boot + + + + + + + + + + + + + + + 17 + + + + org.springframework.boot + spring-boot-starter-data-jpa + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-devtools + runtime + true + + + org.postgresql + postgresql + runtime + + + org.projectlombok + lombok + true + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + org.projectlombok + lombok + + + + + + + + diff --git a/src/main/java/dev/devlink/DevLinkApplication.java b/src/main/java/dev/devlink/DevLinkApplication.java new file mode 100644 index 0000000..8c0308c --- /dev/null +++ b/src/main/java/dev/devlink/DevLinkApplication.java @@ -0,0 +1,13 @@ +package dev.devlink; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class DevLinkApplication { + + public static void main(String[] args) { + SpringApplication.run(DevLinkApplication.class, args); + } + +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml new file mode 100644 index 0000000..73cd62f --- /dev/null +++ b/src/main/resources/application.yml @@ -0,0 +1,10 @@ +spring: + application: + name: DevLink + datasource: + url: ${DATABASE_URL} + username: ${DATABASE_USERNAME} + password: ${DATABASE_PASSWORD} + jpa: + hibernate: + ddl-auto: update \ No newline at end of file diff --git a/src/test/java/dev/devlink/DevLinkApplicationTests.java b/src/test/java/dev/devlink/DevLinkApplicationTests.java new file mode 100644 index 0000000..bc288bc --- /dev/null +++ b/src/test/java/dev/devlink/DevLinkApplicationTests.java @@ -0,0 +1,13 @@ +package dev.devlink; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class DevLinkApplicationTests { + + @Test + void contextLoads() { + } + +} From 959b4d72a549b3154158f05e0e96d018e03cc91d Mon Sep 17 00:00:00 2001 From: Tom Weelborg <135610355+tom-weelborg@users.noreply.github.com> Date: Sat, 23 Nov 2024 18:26:21 +0100 Subject: [PATCH 02/38] chore: add .env file integration --- .env.example | 9 +++++++++ .gitignore | 2 ++ src/main/resources/application.yml | 6 +++++- 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..a0c5e89 --- /dev/null +++ b/.env.example @@ -0,0 +1,9 @@ +# Database settings +DATABASE_USERNAME=your_database_username_here +DATABASE_PASSWORD=your_database_password_here +DATABASE_HOST=your_database_host_here +DATABASE_PORT=your_database_port_here +DATABASE_NAME=your_database_name_here + +# Application settings +SPRING_PROFILES_ACTIVE=dev # OR: prod \ No newline at end of file diff --git a/.gitignore b/.gitignore index b435447..b047168 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,8 @@ target/ !**/src/main/**/target/ !**/src/test/**/target/ +.env + ### Maven ### .mvn mvnw diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 73cd62f..b212557 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,8 +1,12 @@ spring: + config: + import: optional:file:.env[.properties] application: name: DevLink + profiles: + active: ${SPRING_PROFILES_ACTIVE} datasource: - url: ${DATABASE_URL} + url: jdbc:postgresql://${DATABASE_HOST}:${DATABASE_PORT}/${DATABASE_NAME} username: ${DATABASE_USERNAME} password: ${DATABASE_PASSWORD} jpa: From db9958b4326ff360b69b40b3941a8c24b4047705 Mon Sep 17 00:00:00 2001 From: Tom Weelborg <135610355+tom-weelborg@users.noreply.github.com> Date: Sat, 23 Nov 2024 18:28:14 +0100 Subject: [PATCH 03/38] chore: add Docker integration --- Dockerfile | 11 +++++++++++ docker-compose.yml | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f8ec8f4 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM maven:3.8.5-openjdk-17 AS build +WORKDIR /app +COPY src ./src +COPY pom.xml ./ +RUN mvn -f ./pom.xml clean package -DskipTests + +FROM openjdk:17-jdk-slim +WORKDIR /app +COPY --from=build /app/target/*.jar app.jar +EXPOSE 8080 +ENTRYPOINT ["java", "-jar", "app.jar"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..50d3fef --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,32 @@ +services: + backend: + build: + dockerfile: Dockerfile + container_name: devlink-backend + environment: + SPRING_PROFILES_ACTIVE: ${SPRING_PROFILES_ACTIVE} + DATABASE_HOST: database + DATABASE_PORT: 5432 + DATABASE_NAME: ${DATABASE_NAME} + DATABASE_USERNAME: ${DATABASE_USERNAME} + DATABASE_PASSWORD: ${DATABASE_PASSWORD} + ports: + - "8080:8080" + depends_on: + - database + + database: + image: postgres:16.3 + container_name: devlink-database + environment: + POSTGRES_USER: ${DATABASE_USERNAME} + POSTGRES_PASSWORD: ${DATABASE_PASSWORD} + POSTGRES_DB: ${DATABASE_NAME} + volumes: + - postgres_data:/var/lib/postgresql/data + ports: + - "${DATABASE_PORT}:5432" + restart: always + +volumes: + postgres_data: \ No newline at end of file From 0504cd57a58881a182c870128cc0f6f80015411f Mon Sep 17 00:00:00 2001 From: Tom Weelborg <135610355+tom-weelborg@users.noreply.github.com> Date: Wed, 5 Mar 2025 17:38:17 +0100 Subject: [PATCH 04/38] style: add brackets to .env.example --- .env.example | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.env.example b/.env.example index a0c5e89..7fcbe42 100644 --- a/.env.example +++ b/.env.example @@ -1,9 +1,9 @@ # Database settings -DATABASE_USERNAME=your_database_username_here -DATABASE_PASSWORD=your_database_password_here -DATABASE_HOST=your_database_host_here -DATABASE_PORT=your_database_port_here -DATABASE_NAME=your_database_name_here +DATABASE_USERNAME= +DATABASE_PASSWORD= +DATABASE_HOST= +DATABASE_PORT= +DATABASE_NAME= # Application settings SPRING_PROFILES_ACTIVE=dev # OR: prod \ No newline at end of file From c7920a13d2f33b750b479f52244deea618b39584 Mon Sep 17 00:00:00 2001 From: Tom Weelborg <135610355+tom-weelborg@users.noreply.github.com> Date: Sun, 20 Apr 2025 20:35:49 +0200 Subject: [PATCH 05/38] chore: exclude .env.example from .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index b047168..95f1929 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ target/ !**/src/test/**/target/ .env +!.env.example ### Maven ### .mvn From d869b01cc9ea1cce189ba9617fd4ab128855056b Mon Sep 17 00:00:00 2001 From: Tom Weelborg <135610355+tom-weelborg@users.noreply.github.com> Date: Sun, 20 Apr 2025 20:36:13 +0200 Subject: [PATCH 06/38] chore: update postgres version to latest in docker-compose.yml --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 50d3fef..2ac005a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,7 +16,7 @@ services: - database database: - image: postgres:16.3 + image: postgres:latest container_name: devlink-database environment: POSTGRES_USER: ${DATABASE_USERNAME} From 570507a4c4da939ae159580573fa8a740d627b79 Mon Sep 17 00:00:00 2001 From: Tom Weelborg <135610355+tom-weelborg@users.noreply.github.com> Date: Sun, 20 Apr 2025 20:37:26 +0200 Subject: [PATCH 07/38] chore: remove restart attribute from database in docker-compose.yml --- docker-compose.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 2ac005a..f1d4b55 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -26,7 +26,6 @@ services: - postgres_data:/var/lib/postgresql/data ports: - "${DATABASE_PORT}:5432" - restart: always volumes: postgres_data: \ No newline at end of file From 0d91401f8dac3a424ff881c2dedf67cf57258029 Mon Sep 17 00:00:00 2001 From: Tom Weelborg <135610355+tom-weelborg@users.noreply.github.com> Date: Sun, 20 Apr 2025 20:43:33 +0200 Subject: [PATCH 08/38] docs: update README.md title --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bdb7e76..a033823 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,3 @@ -# devlink-backend-java +# DevLink Backend + Backend for the DevLink platform - developed with Java Spring From aa826241f0b9bf35dce32fbc3f95bac33b4d14ff Mon Sep 17 00:00:00 2001 From: Tom Weelborg <135610355+tom-weelborg@users.noreply.github.com> Date: Sun, 20 Apr 2025 21:19:37 +0200 Subject: [PATCH 09/38] build: add instancio --- pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pom.xml b/pom.xml index 5bf1470..b3bcf54 100644 --- a/pom.xml +++ b/pom.xml @@ -60,6 +60,12 @@ spring-boot-starter-test test + + org.instancio + instancio-junit + 5.4.1 + test + From d7eb5b39b12b12427c95dcc8051935fb04c965d2 Mon Sep 17 00:00:00 2001 From: Tom Weelborg <135610355+tom-weelborg@users.noreply.github.com> Date: Sun, 20 Apr 2025 21:25:40 +0200 Subject: [PATCH 10/38] docs: add technology overview section to README.md --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index a033823..829a4b1 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,16 @@ # DevLink Backend Backend for the DevLink platform - developed with Java Spring + +## Technology Overview + +- [Java Spring](https://spring.io/) for dependency injection + - [Spring Boot](https://spring.io/projects/spring-boot) as REST web server + - [Spring Data JPA](https://spring.io/projects/spring-data-jpa) as ORM +- [PostgreSQL](https://www.postgresql.org/) as DBMS +- [Lombok](https://projectlombok.org/) for boilerplate code reduction +- Unit testing: + - [JUnit](https://junit.org/junit5/) as testing framework + - [AssertJ](https://assertj.github.io/doc/) for assertions + - [mockito](https://site.mockito.org/) for mocking + - [Instancio](https://www.instancio.org/) for test data generation \ No newline at end of file From 2c7584bad757f1ef460082f541b9725e863ea84d Mon Sep 17 00:00:00 2001 From: Tom Weelborg <135610355+tom-weelborg@users.noreply.github.com> Date: Sun, 20 Apr 2025 21:27:51 +0200 Subject: [PATCH 11/38] docs: add setup guide section to README.md --- README.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 829a4b1..fa96cd1 100644 --- a/README.md +++ b/README.md @@ -13,4 +13,19 @@ Backend for the DevLink platform - developed with Java Spring - [JUnit](https://junit.org/junit5/) as testing framework - [AssertJ](https://assertj.github.io/doc/) for assertions - [mockito](https://site.mockito.org/) for mocking - - [Instancio](https://www.instancio.org/) for test data generation \ No newline at end of file + - [Instancio](https://www.instancio.org/) for test data generation + +## Installation and Usage + +1. Have [Docker](https://www.docker.com/) set up and running +2. Clone the repository, e.g. with: + ```sh + git clone https://github.com/DevLink-dev/devlink-backend-java.git + cd devlink-backend-java + ``` +3. Make a **copy** of [`.env.example`](.env.example) and rename it to `.env` (will be git-ignored) +4. Add your environment secrets to [`.env`](.env) (will be used by both the database and the Spring application) +5. Start Docker containers for database and Spring application: + ```sh + docker compose up -d + ``` \ No newline at end of file From 8919e965b107202427508b067abf9351b701c2ef Mon Sep 17 00:00:00 2001 From: Tom Weelborg <135610355+tom-weelborg@users.noreply.github.com> Date: Sun, 20 Apr 2025 21:46:20 +0200 Subject: [PATCH 12/38] docs: add reference to frontend to README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index fa96cd1..527411d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # DevLink Backend +> see also: [DevLink Frontend](https://github.com/DevLink-dev/devlink-frontend-svelte)! + Backend for the DevLink platform - developed with Java Spring ## Technology Overview From 324fb29b038c877d35c72749353dabae7b56c5f4 Mon Sep 17 00:00:00 2001 From: Tom Weelborg <135610355+tom-weelborg@users.noreply.github.com> Date: Sun, 20 Apr 2025 22:17:09 +0200 Subject: [PATCH 13/38] docs: add project description section to README.md --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index 527411d..e90ac61 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,20 @@ Backend for the DevLink platform - developed with Java Spring +## Description + +The DevLink Backend allows developers to link up and share project ideas to work on as a community. + +This project provides a REST API that allows users to create and manage their own profiles. +They can also create, manage and join projects to work on as a community. +This allows developers to link up all around the world and learn new skills that will help them master coding and get the job they want. + +This project is developed using the [Java Spring Framework](https://spring.io). +It allows the use of [well-established tools](https://spring.io/projects) included in it. +This reduces the amount of work required to implement new features. +Using a widespread high-level language like Java also assures that the project is easy to maintain and update. +Tools like [Lombok](https://projectlombok.org/) are used to reduce boilerplate code. + ## Technology Overview - [Java Spring](https://spring.io/) for dependency injection From a964beeafc7dbc6b026e89a8b32ee4589c3aea6e Mon Sep 17 00:00:00 2001 From: Tom Weelborg <135610355+tom-weelborg@users.noreply.github.com> Date: Sun, 20 Apr 2025 22:18:15 +0200 Subject: [PATCH 14/38] docs: add frontend reference to setup section to README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e90ac61..3c6cf2c 100644 --- a/README.md +++ b/README.md @@ -44,4 +44,6 @@ Tools like [Lombok](https://projectlombok.org/) are used to reduce boilerplate c 5. Start Docker containers for database and Spring application: ```sh docker compose up -d - ``` \ No newline at end of file + ``` + +To use this project, it is advised to use the corresponding [Frontend](https://github.com/DevLink-dev/devlink-frontend-svelte). \ No newline at end of file From 8b5ba456ed3de20d8e957f1fd2538d4f367c6d2f Mon Sep 17 00:00:00 2001 From: Tom Weelborg <135610355+tom-weelborg@users.noreply.github.com> Date: Sun, 20 Apr 2025 22:34:23 +0200 Subject: [PATCH 15/38] docs: add development section with conventions to README.md --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3c6cf2c..526b6f8 100644 --- a/README.md +++ b/README.md @@ -46,4 +46,12 @@ Tools like [Lombok](https://projectlombok.org/) are used to reduce boilerplate c docker compose up -d ``` -To use this project, it is advised to use the corresponding [Frontend](https://github.com/DevLink-dev/devlink-frontend-svelte). \ No newline at end of file +To use this project, it is advised to use the corresponding [Frontend](https://github.com/DevLink-dev/devlink-frontend-svelte). + +## Development + +This project is developed following the conventions listed below. + +### Conventions + +The following are lists of conventions that either *should* be followed or *must* be followed when contributing to this project. \ No newline at end of file From db072c9485acbaabb411a6d14f3455244e0e374b Mon Sep 17 00:00:00 2001 From: Tom Weelborg <135610355+tom-weelborg@users.noreply.github.com> Date: Sun, 20 Apr 2025 22:35:15 +0200 Subject: [PATCH 16/38] docs: add java package conventions to README.md --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 526b6f8..6b37aa4 100644 --- a/README.md +++ b/README.md @@ -54,4 +54,9 @@ This project is developed following the conventions listed below. ### Conventions -The following are lists of conventions that either *should* be followed or *must* be followed when contributing to this project. \ No newline at end of file +The following are lists of conventions that either *should* be followed or *must* be followed when contributing to this project. + +#### Java + +- Packages: + - Names must be `snake_case` \ No newline at end of file From 42475142781151db753164792ff7ff00be8fcf0c Mon Sep 17 00:00:00 2001 From: Tom Weelborg <135610355+tom-weelborg@users.noreply.github.com> Date: Sun, 20 Apr 2025 22:35:33 +0200 Subject: [PATCH 17/38] docs: add url conventions to README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 6b37aa4..ed195c1 100644 --- a/README.md +++ b/README.md @@ -58,5 +58,6 @@ The following are lists of conventions that either *should* be followed or *must #### Java +- URLs must be `kebab-case` - Packages: - Names must be `snake_case` \ No newline at end of file From fa4347e04e347c9eab7d9a02638b5575a4c4e71a Mon Sep 17 00:00:00 2001 From: Tom Weelborg <135610355+tom-weelborg@users.noreply.github.com> Date: Sun, 20 Apr 2025 22:36:14 +0200 Subject: [PATCH 18/38] docs: add java class conventions to README.md --- README.md | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ed195c1..39c012f 100644 --- a/README.md +++ b/README.md @@ -60,4 +60,27 @@ The following are lists of conventions that either *should* be followed or *must - URLs must be `kebab-case` - Packages: - - Names must be `snake_case` \ No newline at end of file + - Names must be `snake_case` +- Classes: + - Names must be `PascalCase` + - Annotations should have the following order: + - Spring: + - Bean type (`@Component`, `@Configuration`, `@RestController`, `@Service`, ...) + - JPA: + - `@Entity` + - Constraints (`@UniqueConstraint`, ...) + - Lombok: + - constructors: + - `@AllArgsConstructor` + - `@NoArgsConstructor` + - `@RequiredArgsConstructor` + - `@Getter` + - `@Setter` + - `@EqualsAndHashCode` + - ... + - Should be structured as follows: + - `static` constants and variables + - Instance attributes + - Constructors + - `static` functions + - Instance methods \ No newline at end of file From cbc0ac34adcba747f4f33173386a6db894af7bdb Mon Sep 17 00:00:00 2001 From: Tom Weelborg <135610355+tom-weelborg@users.noreply.github.com> Date: Sun, 20 Apr 2025 22:36:33 +0200 Subject: [PATCH 19/38] docs: add java static constants conventions to README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 39c012f..0bb2f6f 100644 --- a/README.md +++ b/README.md @@ -83,4 +83,6 @@ The following are lists of conventions that either *should* be followed or *must - Instance attributes - Constructors - `static` functions - - Instance methods \ No newline at end of file + - Instance methods +- `static` Constants: + - Names must be `SCREAMING_SNAKE_CASE` \ No newline at end of file From 385510aa2e9e61fe5888dfd95f96a625d43372ff Mon Sep 17 00:00:00 2001 From: Tom Weelborg <135610355+tom-weelborg@users.noreply.github.com> Date: Sun, 20 Apr 2025 22:42:59 +0200 Subject: [PATCH 20/38] docs: add java variable conventions to README.md --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0bb2f6f..bf76d80 100644 --- a/README.md +++ b/README.md @@ -85,4 +85,7 @@ The following are lists of conventions that either *should* be followed or *must - `static` functions - Instance methods - `static` Constants: - - Names must be `SCREAMING_SNAKE_CASE` \ No newline at end of file + - Names must be `SCREAMING_SNAKE_CASE` +- Instance Attributes and Method Parameters: + - Names must be `camelCase` + - Should be `final` unless there is a reason to change \ No newline at end of file From e0da11ca3da7d0f4ebebface7359aa129ec5a8b3 Mon Sep 17 00:00:00 2001 From: Tom Weelborg <135610355+tom-weelborg@users.noreply.github.com> Date: Sun, 20 Apr 2025 22:45:07 +0200 Subject: [PATCH 21/38] docs: add java method conventions to README.md --- README.md | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bf76d80..66d05c7 100644 --- a/README.md +++ b/README.md @@ -88,4 +88,27 @@ The following are lists of conventions that either *should* be followed or *must - Names must be `SCREAMING_SNAKE_CASE` - Instance Attributes and Method Parameters: - Names must be `camelCase` - - Should be `final` unless there is a reason to change \ No newline at end of file + - Should be `final` unless there is a reason to change +- Methods: + - Names must be `camelCase` + - Should be at most around **15** lines long + - Should reference down to other `private` methods unless there is a specific reason not to (top-down structure) + - Indentations should not be more than 3 levels deep (counting method indentation level in class as zero) + ```java + public class Foo { + // This is level 0. + public void bar() { + // This is level 1. + for (int i = 0; i < 10; i++) { + // This is level 2. + for (int j = 0; j < 10; j++) { + // This is level 3. + if ((i + j) % 2 == 0) { + // This is level 4 (forbidden). + break; + } + } + } + } + } + ``` \ No newline at end of file From 095b1ff0fe82985724e248a285f25c8d992e450f Mon Sep 17 00:00:00 2001 From: Tom Weelborg <135610355+tom-weelborg@users.noreply.github.com> Date: Sun, 20 Apr 2025 22:45:56 +0200 Subject: [PATCH 22/38] docs: add javadoc conventions to README.md --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 66d05c7..8bfbf48 100644 --- a/README.md +++ b/README.md @@ -111,4 +111,12 @@ The following are lists of conventions that either *should* be followed or *must } } } - ``` \ No newline at end of file + ``` +- Javadoc: + - Must be added to: + - `public` methods and functions of classes, excluding getters, setters and constructors + - Should be added to: + - all `private` members of which the purpose is not obvious or the logic is difficult to comprehend + - May be added to: + - `public static` constants + - other `private` members \ No newline at end of file From 60d3a74f35f4b945239d41246b0eb70310f92222 Mon Sep 17 00:00:00 2001 From: Tom Weelborg <135610355+tom-weelborg@users.noreply.github.com> Date: Sun, 20 Apr 2025 22:51:42 +0200 Subject: [PATCH 23/38] docs: update javadoc conventions to README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8bfbf48..c2c876c 100644 --- a/README.md +++ b/README.md @@ -119,4 +119,5 @@ The following are lists of conventions that either *should* be followed or *must - all `private` members of which the purpose is not obvious or the logic is difficult to comprehend - May be added to: - `public static` constants - - other `private` members \ No newline at end of file + - other `private` members + - Should explain **what** the code does and maybe **why**, but never **how** From bcce2b3ccf6665bbc919946cafb1587bb62ee29d Mon Sep 17 00:00:00 2001 From: Tom Weelborg <135610355+tom-weelborg@users.noreply.github.com> Date: Sun, 20 Apr 2025 22:56:50 +0200 Subject: [PATCH 24/38] docs: add java comment conventions to README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index c2c876c..10eb7c9 100644 --- a/README.md +++ b/README.md @@ -121,3 +121,6 @@ The following are lists of conventions that either *should* be followed or *must - `public static` constants - other `private` members - Should explain **what** the code does and maybe **why**, but never **how** +- Comments: + - Should be avoided except for Javadoc + - Necessary information regarding behavior should be added as Javadoc instead (e.g. `@apiNote`, `@implNote`, `@implSpec`) From c2cae709dbf1dd27fd4d3d8674169a8330e5b391 Mon Sep 17 00:00:00 2001 From: Tom Weelborg <135610355+tom-weelborg@users.noreply.github.com> Date: Sun, 20 Apr 2025 23:40:23 +0200 Subject: [PATCH 25/38] docs: add java lombok conventions to README.md --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 10eb7c9..4af6547 100644 --- a/README.md +++ b/README.md @@ -124,3 +124,16 @@ The following are lists of conventions that either *should* be followed or *must - Comments: - Should be avoided except for Javadoc - Necessary information regarding behavior should be added as Javadoc instead (e.g. `@apiNote`, `@implNote`, `@implSpec`) +- Lombok should be used to reduce boilerplate code and increase readability: + - Generation for: + - [Getters/Setters](https://projectlombok.org/features/GetterSetter) + - [equals()/hashCode()](https://projectlombok.org/features/EqualsAndHashCode) + - [Constructors](https://projectlombok.org/features/constructor) + - [Builders](https://projectlombok.org/features/Builder) including with [inheritance](https://projectlombok.org/features/experimental/SuperBuilder) + - [Loggers](https://projectlombok.org/features/log) + - [Utilities](https://projectlombok.org/features/experimental/UtilityClass) + - [Exceptions](https://projectlombok.org/features/experimental/StandardException) + - Can be used to set access levels of methods ([Getters/Setters](https://projectlombok.org/features/GetterSetter) and [Constructors](https://projectlombok.org/features/constructor)) + - Can be used with annotations on methods and constructors using [onX](https://projectlombok.org/features/experimental/onX) + - Can be used to include or exclude fields for [equals()/hashCode()](https://projectlombok.org/features/EqualsAndHashCode) + - Other annotations than the ones mentioned above should not be used as some are difficult to comprehend or maintain From 1a3561f0fd36f23775dffe9d5855cf4b5d31c9b7 Mon Sep 17 00:00:00 2001 From: Tom Weelborg <135610355+tom-weelborg@users.noreply.github.com> Date: Sun, 20 Apr 2025 23:41:07 +0200 Subject: [PATCH 26/38] docs: add java warning conventions to README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 4af6547..bbf74a2 100644 --- a/README.md +++ b/README.md @@ -137,3 +137,6 @@ The following are lists of conventions that either *should* be followed or *must - Can be used with annotations on methods and constructors using [onX](https://projectlombok.org/features/experimental/onX) - Can be used to include or exclude fields for [equals()/hashCode()](https://projectlombok.org/features/EqualsAndHashCode) - Other annotations than the ones mentioned above should not be used as some are difficult to comprehend or maintain +- Code must compile without Compiler Warnings +- Code should compile without relevant Sonar/SonarQube Warnings + From 9b3832839e00147e626f88af8a4d4f7fd2cbfb04 Mon Sep 17 00:00:00 2001 From: Tom Weelborg <135610355+tom-weelborg@users.noreply.github.com> Date: Sun, 20 Apr 2025 23:45:38 +0200 Subject: [PATCH 27/38] docs: add git conventions to README.md --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index bbf74a2..886662f 100644 --- a/README.md +++ b/README.md @@ -140,3 +140,10 @@ The following are lists of conventions that either *should* be followed or *must - Code must compile without Compiler Warnings - Code should compile without relevant Sonar/SonarQube Warnings +#### Git + +- There are no comments including `TODO` on the `main` or `develop` branches +- Branch names are as follows: + - features: `feature/_` + - bugs: `bugfix/_` +- Commit messages are written according to [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) From 89c9e575e6e9b110dfa372ea3aba83856470e788 Mon Sep 17 00:00:00 2001 From: Tom Weelborg <135610355+tom-weelborg@users.noreply.github.com> Date: Mon, 21 Apr 2025 00:14:35 +0200 Subject: [PATCH 28/38] build: add openapi support --- pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pom.xml b/pom.xml index b3bcf54..3d07da8 100644 --- a/pom.xml +++ b/pom.xml @@ -38,6 +38,11 @@ org.springframework.boot spring-boot-starter-web + + org.springdoc + springdoc-openapi-ui + 1.8.0 + org.springframework.boot From 761f2977b86741aa235e955725481d1be8e7f504 Mon Sep 17 00:00:00 2001 From: Tom Weelborg <135610355+tom-weelborg@users.noreply.github.com> Date: Mon, 21 Apr 2025 00:46:52 +0200 Subject: [PATCH 29/38] docs: add logging to README.md --- README.md | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 886662f..f3224a7 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ Tools like [Lombok](https://projectlombok.org/) are used to reduce boilerplate c - [Spring Data JPA](https://spring.io/projects/spring-data-jpa) as ORM - [PostgreSQL](https://www.postgresql.org/) as DBMS - [Lombok](https://projectlombok.org/) for boilerplate code reduction +- [Log4j 2](https://logging.apache.org/log4j/2.x/) for logging - Unit testing: - [JUnit](https://junit.org/junit5/) as testing framework - [AssertJ](https://assertj.github.io/doc/) for assertions @@ -130,7 +131,7 @@ The following are lists of conventions that either *should* be followed or *must - [equals()/hashCode()](https://projectlombok.org/features/EqualsAndHashCode) - [Constructors](https://projectlombok.org/features/constructor) - [Builders](https://projectlombok.org/features/Builder) including with [inheritance](https://projectlombok.org/features/experimental/SuperBuilder) - - [Loggers](https://projectlombok.org/features/log) + - [Loggers](https://projectlombok.org/features/log): preferred is `@Log4j2` - [Utilities](https://projectlombok.org/features/experimental/UtilityClass) - [Exceptions](https://projectlombok.org/features/experimental/StandardException) - Can be used to set access levels of methods ([Getters/Setters](https://projectlombok.org/features/GetterSetter) and [Constructors](https://projectlombok.org/features/constructor)) @@ -147,3 +148,43 @@ The following are lists of conventions that either *should* be followed or *must - features: `feature/_` - bugs: `bugfix/_` - Commit messages are written according to [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) + +### Logging +with [Log4j 2](https://logging.apache.org/log4j/2.x/) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LevelUsage
TraceTrace events are used for extremely fine-grained diagnostic information, which can be helpful for tracking down very specific issues or understanding the detailed flow of a program.
DebugDebug is used for internal system events that are not necessarily observable from the outside, but useful when determining how something happened.
InfoInformation events describe things happening in the system that correspond to its responsibilities and functions.
WarnWhen service is degraded, endangered, or maybe behaving outside its expected parameters, Warning-level events are used.
ErrorWhen functionality is unavailable or expectations are broken, an Error event is used.
FatalThe most critical level, Fatal events demand immediate attention.
+ +Usage guidelines are taken from [here](https://github.com/solid-stack-solutions/voycar-backend/blob/main/README.md#logging). From 01d19e88b43bd158c1d0c136ff002809696d5063 Mon Sep 17 00:00:00 2001 From: Tom Weelborg <135610355+tom-weelborg@users.noreply.github.com> Date: Sun, 27 Apr 2025 19:18:48 +0200 Subject: [PATCH 30/38] docs: add conventional commit explanation to README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f3224a7..a8d8861 100644 --- a/README.md +++ b/README.md @@ -147,7 +147,8 @@ The following are lists of conventions that either *should* be followed or *must - Branch names are as follows: - features: `feature/_` - bugs: `bugfix/_` -- Commit messages are written according to [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) +- Commit messages are written according to [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/): + - [List of Commit Types](https://github.com/pvdlg/conventional-commit-types?tab=readme-ov-file#commit-types) ### Logging with [Log4j 2](https://logging.apache.org/log4j/2.x/) From 785f67096d737d0f75ae454e16b9738cd2f71406 Mon Sep 17 00:00:00 2001 From: Tom Weelborg <135610355+tom-weelborg@users.noreply.github.com> Date: Sun, 27 Apr 2025 19:19:30 +0200 Subject: [PATCH 31/38] build: add spring validation --- pom.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pom.xml b/pom.xml index 3d07da8..effd618 100644 --- a/pom.xml +++ b/pom.xml @@ -34,6 +34,10 @@ org.springframework.boot spring-boot-starter-data-jpa
+ + org.springframework.boot + spring-boot-starter-validation + org.springframework.boot spring-boot-starter-web From b0acc587922eee9bd9c5c53470a2104823dee317 Mon Sep 17 00:00:00 2001 From: Tom Weelborg <135610355+tom-weelborg@users.noreply.github.com> Date: Sun, 27 Apr 2025 19:20:32 +0200 Subject: [PATCH 32/38] docs: allow more lombok annotations in README.md --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index a8d8861..8f41510 100644 --- a/README.md +++ b/README.md @@ -128,12 +128,18 @@ The following are lists of conventions that either *should* be followed or *must - Lombok should be used to reduce boilerplate code and increase readability: - Generation for: - [Getters/Setters](https://projectlombok.org/features/GetterSetter) + - [Delegation](https://projectlombok.org/features/experimental/Delegate) - [equals()/hashCode()](https://projectlombok.org/features/EqualsAndHashCode) - [Constructors](https://projectlombok.org/features/constructor) + - [Copy Constructors as Setters](https://projectlombok.org/features/With) + - [toString()](https://projectlombok.org/features/ToString) - [Builders](https://projectlombok.org/features/Builder) including with [inheritance](https://projectlombok.org/features/experimental/SuperBuilder) - [Loggers](https://projectlombok.org/features/log): preferred is `@Log4j2` - [Utilities](https://projectlombok.org/features/experimental/UtilityClass) - [Exceptions](https://projectlombok.org/features/experimental/StandardException) + - Threading: + - [Synchronization](https://projectlombok.org/features/Synchronized) + - [Locking](https://projectlombok.org/features/Locked) - Can be used to set access levels of methods ([Getters/Setters](https://projectlombok.org/features/GetterSetter) and [Constructors](https://projectlombok.org/features/constructor)) - Can be used with annotations on methods and constructors using [onX](https://projectlombok.org/features/experimental/onX) - Can be used to include or exclude fields for [equals()/hashCode()](https://projectlombok.org/features/EqualsAndHashCode) From 555f8072d7b8e32e7e80f3959f17805e140d49c1 Mon Sep 17 00:00:00 2001 From: Tom Weelborg <135610355+tom-weelborg@users.noreply.github.com> Date: Mon, 28 Apr 2025 00:04:57 +0200 Subject: [PATCH 33/38] chore: change to static postgres image version --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index f1d4b55..cb9c23f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,7 +16,7 @@ services: - database database: - image: postgres:latest + image: postgres:17.4 container_name: devlink-database environment: POSTGRES_USER: ${DATABASE_USERNAME} From c332039f72777ee4cc84cd8d8a86cd6b241d4b7e Mon Sep 17 00:00:00 2001 From: Tom Weelborg <135610355+tom-weelborg@users.noreply.github.com> Date: Mon, 28 Apr 2025 00:05:41 +0200 Subject: [PATCH 34/38] build: update to spring version 3.4.5 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index effd618..1d252b9 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.springframework.boot spring-boot-starter-parent - 3.3.5 + 3.4.5 dev From 24e1575642a7300a1a3c7c0b6349cd1736db6ec9 Mon Sep 17 00:00:00 2001 From: Tom Weelborg <135610355+tom-weelborg@users.noreply.github.com> Date: Mon, 28 Apr 2025 00:45:29 +0200 Subject: [PATCH 35/38] build: update to java 24 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1d252b9..1c036d4 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ - 17 + 24 From 06aecdefbaab725b2e4cf5e66e5d10659fe4ee6d Mon Sep 17 00:00:00 2001 From: Tom Weelborg <135610355+tom-weelborg@users.noreply.github.com> Date: Mon, 28 Apr 2025 00:57:27 +0200 Subject: [PATCH 36/38] chore: update Dockerfile to jdk 24 --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index f8ec8f4..9c95e7a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,10 @@ -FROM maven:3.8.5-openjdk-17 AS build +FROM maven:3.9.9-eclipse-temurin-24 AS build WORKDIR /app COPY src ./src COPY pom.xml ./ RUN mvn -f ./pom.xml clean package -DskipTests -FROM openjdk:17-jdk-slim +FROM eclipse-temurin:24-jdk WORKDIR /app COPY --from=build /app/target/*.jar app.jar EXPOSE 8080 From 075ab3392ada9a39d563fd594cb9c587f255218f Mon Sep 17 00:00:00 2001 From: Tom Weelborg <135610355+tom-weelborg@users.noreply.github.com> Date: Thu, 10 Jul 2025 01:02:11 +0200 Subject: [PATCH 37/38] build: change version of springdoc openapi --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 1c036d4..a47f9d5 100644 --- a/pom.xml +++ b/pom.xml @@ -44,8 +44,8 @@ org.springdoc - springdoc-openapi-ui - 1.8.0 + springdoc-openapi-starter-webmvc-ui + 2.8.9 From 27131fb2615102decab86e3ea0d1aee0e8b9f9ac Mon Sep 17 00:00:00 2001 From: Tom Weelborg <135610355+tom-weelborg@users.noreply.github.com> Date: Mon, 6 Apr 2026 16:50:57 +0200 Subject: [PATCH 38/38] docs: add java interface conventions to README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 8f41510..c7f15ea 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,8 @@ The following are lists of conventions that either *should* be followed or *must - Constructors - `static` functions - Instance methods +- Interfaces: + - Names must begin with `I` and continue in `PascalCase` - `static` Constants: - Names must be `SCREAMING_SNAKE_CASE` - Instance Attributes and Method Parameters: