From f69a0f72d1c21e939e5bf3604ae8097498d90a26 Mon Sep 17 00:00:00 2001 From: Tom Date: Fri, 22 Nov 2024 22:21:44 +0100 Subject: [PATCH 01/37] 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 bca06c46f3dd9d68c93d77a7d605396161c52193 Mon Sep 17 00:00:00 2001 From: Tom Date: Sat, 23 Nov 2024 18:26:21 +0100 Subject: [PATCH 02/37] 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 21d837946886ed637ae47d3b7ce5fa26c03d70de Mon Sep 17 00:00:00 2001 From: Tom Date: Sat, 23 Nov 2024 18:28:14 +0100 Subject: [PATCH 03/37] 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 b1f319aa1e29424a78b07b1d148d53b55af18927 Mon Sep 17 00:00:00 2001 From: Tom Date: Wed, 5 Mar 2025 17:38:17 +0100 Subject: [PATCH 04/37] 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 0a4db6fd0ceef05a07b7c57ca700e946a0fe83ab Mon Sep 17 00:00:00 2001 From: Tom Date: Sun, 20 Apr 2025 20:35:49 +0200 Subject: [PATCH 05/37] 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 861feab7f4f8a48a8904b62472f7d74476515d2c Mon Sep 17 00:00:00 2001 From: Tom Date: Sun, 20 Apr 2025 20:36:13 +0200 Subject: [PATCH 06/37] 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 37bb178462a2ad4bd3a1007fd80aa2071f04f7ae Mon Sep 17 00:00:00 2001 From: Tom Date: Sun, 20 Apr 2025 20:37:26 +0200 Subject: [PATCH 07/37] 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 701ab7de566e2a8e51c0b3576721875b51d6c0f8 Mon Sep 17 00:00:00 2001 From: Tom Date: Sun, 20 Apr 2025 20:43:33 +0200 Subject: [PATCH 08/37] 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 99ed2f3dc149845b05ffef5372e8ced3225c9a1e Mon Sep 17 00:00:00 2001 From: Tom Date: Sun, 20 Apr 2025 21:19:37 +0200 Subject: [PATCH 09/37] 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 a9afb389d7219e87fd541aa7a128a6e951d2c22b Mon Sep 17 00:00:00 2001 From: Tom Date: Sun, 20 Apr 2025 21:25:40 +0200 Subject: [PATCH 10/37] 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 30d749502908a5b0b612b7db10154ad4f7397ac4 Mon Sep 17 00:00:00 2001 From: Tom Date: Sun, 20 Apr 2025 21:27:51 +0200 Subject: [PATCH 11/37] 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 12e7a8f91f0a63849e083d9e90c1a15ca3ce4273 Mon Sep 17 00:00:00 2001 From: Tom Date: Sun, 20 Apr 2025 21:46:20 +0200 Subject: [PATCH 12/37] 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 da8d77e7b280032c24cec7834838f51ed20b0c42 Mon Sep 17 00:00:00 2001 From: Tom Date: Sun, 20 Apr 2025 22:17:09 +0200 Subject: [PATCH 13/37] 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 4568d61a91936f7d8930f0f5ec2217b8db5e511b Mon Sep 17 00:00:00 2001 From: Tom Date: Sun, 20 Apr 2025 22:18:15 +0200 Subject: [PATCH 14/37] 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 ee4625bf341179fecb60cf09b92eba41d8e04987 Mon Sep 17 00:00:00 2001 From: Tom Date: Sun, 20 Apr 2025 22:34:23 +0200 Subject: [PATCH 15/37] 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 876ce147fb1811e6fd57a567bdbe211a614ccc77 Mon Sep 17 00:00:00 2001 From: Tom Date: Sun, 20 Apr 2025 22:35:15 +0200 Subject: [PATCH 16/37] 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 c64989e0dee9369b811314e4c9c7043121661da1 Mon Sep 17 00:00:00 2001 From: Tom Date: Sun, 20 Apr 2025 22:35:33 +0200 Subject: [PATCH 17/37] 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 5a1927f8f89f7258788f0609dd7af22885e0f7aa Mon Sep 17 00:00:00 2001 From: Tom Date: Sun, 20 Apr 2025 22:36:14 +0200 Subject: [PATCH 18/37] 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 5ef1266a8cfcf97e380250e11099b697e52d75c1 Mon Sep 17 00:00:00 2001 From: Tom Date: Sun, 20 Apr 2025 22:36:33 +0200 Subject: [PATCH 19/37] 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 6e048eb675d450a96fad052b956ccfb3d89514e7 Mon Sep 17 00:00:00 2001 From: Tom Date: Sun, 20 Apr 2025 22:42:59 +0200 Subject: [PATCH 20/37] 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 81c6c84f7db61ed636d83b30ac9d0b9937835e26 Mon Sep 17 00:00:00 2001 From: Tom Date: Sun, 20 Apr 2025 22:45:07 +0200 Subject: [PATCH 21/37] 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 b89714b2d5b0618d8ef417946fd7df6296ed7ade Mon Sep 17 00:00:00 2001 From: Tom Date: Sun, 20 Apr 2025 22:45:56 +0200 Subject: [PATCH 22/37] 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 f48b1396300d20a79df69e0f8f7269e9776bba7b Mon Sep 17 00:00:00 2001 From: Tom Date: Sun, 20 Apr 2025 22:51:42 +0200 Subject: [PATCH 23/37] docs: update javadoc conventions to README.md --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8bfbf48..0fca97c 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,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: @@ -119,4 +121,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** \ No newline at end of file From b42e0b21b1180c2f4c7039d0f46b17c484bd3d75 Mon Sep 17 00:00:00 2001 From: Tom Date: Sun, 20 Apr 2025 22:56:50 +0200 Subject: [PATCH 24/37] docs: add java comment conventions to README.md --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0fca97c..afa81ee 100644 --- a/README.md +++ b/README.md @@ -122,4 +122,7 @@ The following are lists of conventions that either *should* be followed or *must - May be added to: - `public static` constants - other `private` members - - Should explain **what** the code does and maybe **why**, but never **how** \ No newline at end of file + - 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`) \ No newline at end of file From bc31f9855fa87d7516c4a7f6d40c24e524dc59a8 Mon Sep 17 00:00:00 2001 From: Tom Date: Sun, 20 Apr 2025 23:40:23 +0200 Subject: [PATCH 25/37] docs: add java lombok conventions to README.md --- README.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index afa81ee..c819d1c 100644 --- a/README.md +++ b/README.md @@ -125,4 +125,17 @@ The following are lists of conventions that either *should* be followed or *must - 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`) \ No newline at end of file + - 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 e0e667c679f1903817f6920be73716471b20255b Mon Sep 17 00:00:00 2001 From: Tom Date: Sun, 20 Apr 2025 23:41:07 +0200 Subject: [PATCH 26/37] 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 c819d1c..747a0d7 100644 --- a/README.md +++ b/README.md @@ -139,3 +139,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 dcf1bd64f4449b714eb47dab4f4afe10711668df Mon Sep 17 00:00:00 2001 From: Tom Date: Sun, 20 Apr 2025 23:45:38 +0200 Subject: [PATCH 27/37] docs: add git conventions to README.md --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 747a0d7..d247358 100644 --- a/README.md +++ b/README.md @@ -142,3 +142,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 5a643330565aa52fca887fdc662b6185648c54e7 Mon Sep 17 00:00:00 2001 From: Tom Date: Mon, 21 Apr 2025 00:14:35 +0200 Subject: [PATCH 28/37] 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 bdee51b2b2c7f4b404a0ec676c516269c083b0bf Mon Sep 17 00:00:00 2001 From: Tom Date: Mon, 21 Apr 2025 00:46:52 +0200 Subject: [PATCH 29/37] 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 d247358..4ddc270 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 @@ -132,7 +133,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)) @@ -149,3 +150,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). \ No newline at end of file From f107db1b57be14e28d68636c2f567c949d90343b Mon Sep 17 00:00:00 2001 From: Tom Date: Sun, 27 Apr 2025 19:18:48 +0200 Subject: [PATCH 30/37] 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 4ddc270..61febaa 100644 --- a/README.md +++ b/README.md @@ -149,7 +149,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 afaec9163ca6e7c4da9ba3702522bf2707049bd2 Mon Sep 17 00:00:00 2001 From: Tom Date: Sun, 27 Apr 2025 19:19:30 +0200 Subject: [PATCH 31/37] 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 396f1375791a18b93bc01689baf5b3c16bdf681b Mon Sep 17 00:00:00 2001 From: Tom Date: Sun, 27 Apr 2025 19:20:32 +0200 Subject: [PATCH 32/37] 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 61febaa..e1fc399 100644 --- a/README.md +++ b/README.md @@ -130,12 +130,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 06e22356daf343bcedd3e85a1ac967f450b747a9 Mon Sep 17 00:00:00 2001 From: Tom Date: Mon, 28 Apr 2025 00:04:57 +0200 Subject: [PATCH 33/37] ci: 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 33cc4a288e9b1f1f47c949f84a9ab8611a2f762e Mon Sep 17 00:00:00 2001 From: Tom Date: Mon, 28 Apr 2025 00:05:41 +0200 Subject: [PATCH 34/37] 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 28fe28ff582a9310a52dd0ce78b5fba6fc0a5a24 Mon Sep 17 00:00:00 2001 From: Tom Date: Mon, 28 Apr 2025 00:45:29 +0200 Subject: [PATCH 35/37] 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 e7772848a523754fb5b6047ab53e9cb32caa092b Mon Sep 17 00:00:00 2001 From: Tom Date: Mon, 28 Apr 2025 00:57:27 +0200 Subject: [PATCH 36/37] ci: 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 75386a9286ab029051af701edc03a8e7f1a56361 Mon Sep 17 00:00:00 2001 From: Tom Date: Thu, 10 Jul 2025 01:02:11 +0200 Subject: [PATCH 37/37] 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