Skip to content

refactor #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 133 additions & 0 deletions .github/workflows/services_builder.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
name: Builder Services

on:
pull_request:
branches:
- master
push:
branches:
- master

jobs:
build-core-service:
name: Build Core Service
runs-on: ubuntu-latest
steps:
# TODO: Remove all "mock step" and uncomment ppl code
- name: mock step
run: |
echo "mock step :)"
# - name: Build And Test Core Service
# run: |
# docker build --target builder -f Docker/core-service/Dockerfile -t core-service-builder . && \
# docker run --rm core-service-builder ./gradlew test --warning-mode all :CoreService:build && \
# docker build --target package -f Docker/core-service/Dockerfile -t core-service .

# - name: Save Core Service Final Image
# run: |
# docker save core-service | gzip > core-service.tar.gz

# - name: Upload Core Service Final Image
# uses: actions/upload-artifact@v4
# with:
# name: core-service.tar.gz
# path: core-service.tar.gz
# retention-days: 1

functional-test-core-service:
name: Functional Test Core Service
runs-on: ubuntu-latest
needs: build-core-service
steps:
- name: mock step
run: |
echo "mock step :)"




build-sensor-manager-service:
name: Build Sensor Manager Service
runs-on: ubuntu-latest
steps:
# TODO: Remove all "mock step" and uncomment ppl code
- name: mock step
run: |
echo "mock step :)"
# - name: Build Test And Packege Sensor Manager Service
# run: |
# docker build --target builder -f Docker/sensor-manager-service/Dockerfile -t sensor-manager-service-builder . && \
# docker run --rm sensor-manager-service-builder ./gradlew test --warning-mode all :SensorManagerService:build && \
# docker build --target package -f Docker/sensor-manager-service/Dockerfile -t sensor-manager-service .

# - name: Save Sensor Manager Service Final Image
# run: |
# docker save sensor-manager-service | gzip > sensor-manager-service.tar.gz

# - name: Upload Sensor Manager Service Final Image
# uses: actions/upload-artifact@v4
# with:
# name: sensor-manager-service.tar.gz
# path: sensor-manager-service.tar.gz
# retention-days: 1

functional-test-sensor-manager-service:
name: Functional Test Sensor Manager Service
runs-on: ubuntu-latest
needs: build-sensor-manager-service
steps:
- name: mock step
run: |
echo "mock step :)"




build-executor-manager-service:
name: Build Executor Manager Service
runs-on: ubuntu-latest
steps:
# TODO: Remove all "mock step" and uncomment ppl code
- name: mock step
run: |
echo "mock step :)"
# - name: Build Test And Packege Executor Manager Service
# run: |
# docker build --target builder -f Docker/executor-manager-service/Dockerfile -t executor-manager-service-builder . && \
# docker run --rm executor-manager-service-builder ./gradlew test --warning-mode all :ExecutorManagerService:build && \
# docker build --target package -f Docker/executor-manager-service/Dockerfile -t executor-manager-service .

# - name: Save Executor Manager Service Final Image
# run: |
# docker save executor-manager-service | gzip > executor-manager-service.tar.gz

# - name: Upload Executor Manager Service Final Image
# uses: actions/upload-artifact@v4
# with:
# name: executor-manager-service.tar.gz
# path: executor-manager-service.tar.gz
# retention-days: 1

functional-test-executor-manager-service:
name: Functional Test Executor Manager Service
runs-on: ubuntu-latest
needs: build-executor-manager-service
steps:
- name: mock step
run: |
echo "mock step :)"




end-to-end-backend-test:
name: End To End Backend Test
runs-on: ubuntu-latest
needs:
- functional-test-core-service
- functional-test-sensor-manager-service
- functional-test-executor-manager-service
steps:
- name: mock step
run: |
echo "mock step :)"
27 changes: 0 additions & 27 deletions .github/workflows/test.yml

This file was deleted.

23 changes: 23 additions & 0 deletions Docker/core-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM gradle:8.10.1-jdk11 AS builder
WORKDIR /app

COPY ../../Services/gradlew /app/
COPY ../../Services/gradle /app/gradle/
COPY ../../Services/build.gradle /app/
COPY ../../Services/settings.gradle /app/
COPY ../../Services/CoreService /app/CoreService
COPY ../../Services/Common /app/Common

RUN chmod +x ./gradlew

RUN ./gradlew :CoreService:assemble --no-daemon



FROM openjdk:11-jre-slim AS package
WORKDIR /app

COPY --from=builder /app/CoreService/build/libs/*.jar /app/core-service.jar

CMD ["java", "-jar", "/app/core-service.jar"]

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ EXPOSE 8080

WORKDIR /app

COPY . /app
COPY ../.. /app

RUN mvn package -f /app
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,21 @@ Main platform communicates with sensors using the TCP network protocol.
Prepared collection available: [here](https://www.postman.com/collections/b1f839feccff33a996f7)
- Automatic tests are provided by GitHub actions and a configured CI pipeline for launching JUnit tests using Maven triggered on every push changes.

## Architecture
```mermaid
graph TD;
%% Reverse Proxy
Nginx[Nginx Reverse Proxy] -->|Routes requests| AuthenticationService
Nginx -->|Routes requests| CoreService
Nginx -->|Routes requests| SensorManagerService

%% Authentication Service
AuthenticationService -->|Stores user data| AuthDatabase[(Auth Database)]

%% Queue and Communication
CoreService -->|Sends tasks| Queue[(Message Broker)]
Queue -->|Receives tasks| ExecutionManagerService

%% Core Communication
CoreService -->|Handles sensor management| SensorManagerService
```
3 changes: 3 additions & 0 deletions Services/Common/Model/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
tasks.jar {
enabled = true
}
3 changes: 3 additions & 0 deletions Services/Common/Utils/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
tasks.jar {
enabled = true
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package pl.piotr.iotdbmanagement.utils;
package com.iotdbmanagement.common.utils;

import java.util.Objects;
import java.util.function.Function;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package pl.piotr.iotdbmanagement.utils;
package com.iotdbmanagement.common.utils;

import java.util.Objects;
import java.util.function.Function;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package pl.piotr.iotdbmanagement.utils;
package com.iotdbmanagement.common.utils;

import java.util.Objects;
import java.util.function.Function;
Expand Down
28 changes: 28 additions & 0 deletions Services/CoreService/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
dependencies {
implementation(project(":Common:Model"))
implementation(project(":Common:Utils"))

implementation(libs.spring.boot.starter)
implementation(libs.spring.boot.starter.data.jpa)
implementation(libs.spring.boot.starter.web)
implementation(libs.spring.boot.starter.security)
implementation(libs.spring.boot.starter.validation)
implementation(libs.gson)
implementation(libs.h2)
implementation(libs.jaxb.api)
implementation(libs.jaxb.runtime)

testImplementation(libs.spring.boot.starter.test)
testImplementation(libs.junit.vintage.engine)
testImplementation(libs.json.path)
testImplementation(libs.h2)
}

test {
useJUnitPlatform()
testLogging {
events "PASSED", "FAILED", "SKIPPED"
showStandardStreams = true
exceptionFormat "full"
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package pl.piotr.iotdbmanagement;
package com.iotdbmanagement.core;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class ClientApiApplication {
public class CoreServiceApplication {

public static void main(String[] args) {
SpringApplication.run(ClientApiApplication.class, args);
SpringApplication.run(CoreServiceApplication.class, args);
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package pl.piotr.iotdbmanagement.configuration;
package com.iotdbmanagement.core.configuration;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package pl.piotr.iotdbmanagement.configuration;
package com.iotdbmanagement.core.configuration;

import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package pl.piotr.iotdbmanagement.configuration.auth;
package com.iotdbmanagement.core.configuration.auth;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package pl.piotr.iotdbmanagement.configuration.auth;
package com.iotdbmanagement.core.configuration.auth;

import com.iotdbmanagement.core.user.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
Expand All @@ -8,8 +9,7 @@
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;
import pl.piotr.iotdbmanagement.service.UserService;
import pl.piotr.iotdbmanagement.user.User;
import com.iotdbmanagement.core.service.UserService;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package pl.piotr.iotdbmanagement.configuration.auth;
package com.iotdbmanagement.core.configuration.auth;

import lombok.SneakyThrows;
import org.springframework.security.crypto.password.PasswordEncoder;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package pl.piotr.iotdbmanagement.connectionstats;
package com.iotdbmanagement.core.connectionstats;

import lombok.*;
import lombok.experimental.SuperBuilder;
import pl.piotr.iotdbmanagement.measurementtype.MeasurementType;
import pl.piotr.iotdbmanagement.sensor.Sensor;
import com.iotdbmanagement.core.sensor.Sensor;

import javax.persistence.*;
import java.time.LocalDate;
import java.util.List;

@Getter
@Setter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package pl.piotr.iotdbmanagement.connectionstats;
package com.iotdbmanagement.core.connectionstats;

import com.iotdbmanagement.core.sensor.Sensor;
import org.springframework.data.jpa.repository.JpaRepository;
import pl.piotr.iotdbmanagement.sensor.Sensor;

import java.time.LocalDate;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package pl.piotr.iotdbmanagement.controller;
package com.iotdbmanagement.core.controller;

import com.iotdbmanagement.core.dto.user.DeleteUserRequest;
import com.iotdbmanagement.core.dto.user.UpdatePasswordRequest;
import com.iotdbmanagement.core.user.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import pl.piotr.iotdbmanagement.dto.user.DeleteUserRequest;
import pl.piotr.iotdbmanagement.dto.user.UpdatePasswordRequest;
import pl.piotr.iotdbmanagement.service.UserService;
import pl.piotr.iotdbmanagement.user.User;
import com.iotdbmanagement.core.service.UserService;

import javax.validation.Valid;
import java.util.Optional;
Expand Down
Loading