Add some structure

This commit is contained in:
2025-12-10 06:41:26 +01:00
parent 413f5b7cfc
commit a89628cd10
71 changed files with 140 additions and 29 deletions

View File

@@ -14,6 +14,6 @@ WORKDIR /app
COPY --from=build /app/build/libs/*.jar app.jar COPY --from=build /app/build/libs/*.jar app.jar
EXPOSE 8000 EXPOSE 8080
ENTRYPOINT ["java", "-jar", "app.jar"] ENTRYPOINT ["java", "-jar", "app.jar"]

View File

@@ -28,8 +28,9 @@ repositories {
extra["snippetsDir"] = file("build/generated-snippets") extra["snippetsDir"] = file("build/generated-snippets")
dependencies { dependencies {
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-security") implementation("org.springframework.boot:spring-boot-security")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-actuator") implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("org.springframework.boot:spring-boot-starter-data-elasticsearch") implementation("org.springframework.boot:spring-boot-starter-data-elasticsearch")
implementation("org.springframework.boot:spring-boot-starter-data-mongodb") implementation("org.springframework.boot:spring-boot-starter-data-mongodb")
@@ -38,6 +39,8 @@ dependencies {
implementation("org.springframework.boot:spring-boot-starter-opentelemetry") implementation("org.springframework.boot:spring-boot-starter-opentelemetry")
implementation("org.springframework.boot:spring-boot-starter-data-mongodb") implementation("org.springframework.boot:spring-boot-starter-data-mongodb")
implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0")
developmentOnly("org.springframework.boot:spring-boot-devtools") developmentOnly("org.springframework.boot:spring-boot-devtools")
developmentOnly("org.springframework.boot:spring-boot-docker-compose") developmentOnly("org.springframework.boot:spring-boot-docker-compose")

View File

@@ -3,7 +3,9 @@ services:
build: . build: .
container_name: boardmate-api container_name: boardmate-api
ports: ports:
- "8000:8000" - "8000:8080"
environment:
- SPRING_BOOT_DOCKER_COMPOSE_TCP_CONNECT_PORT=8080
depends_on: depends_on:
- mongodb - mongodb
- elasticsearch - elasticsearch

View File

@@ -0,0 +1,14 @@
{"t":{"$date":"2025-12-09T11:23:33.037Z"},"s":"E","c":"MONGOSH","id":1000000006,"ctx":"telemetry","msg":"Error: Failed to resolve machine ID","attr":{"stack":"Error: Failed to resolve machine ID\n at i (eval at module.exports (node:lib-boxednode/mongosh:103:20), <anonymous>:341:193848)\n at async LoggingAndTelemetry.setupTelemetry (eval at module.exports (node:lib-boxednode/mongosh:103:20), <anonymous>:341:302397)","name":"Error","message":"Failed to resolve machine ID","code":null}}
{"t":{"$date":"2025-12-09T11:23:33.054Z"},"s":"I","c":"MONGOSH","id":1000000048,"ctx":"config","msg":"Loading global configuration file","attr":{"filename":"/etc/mongosh.conf","found":false}}
{"t":{"$date":"2025-12-09T11:23:33.064Z"},"s":"I","c":"MONGOSH","id":1000000000,"ctx":"log","msg":"Starting log","attr":{"execPath":"/usr/bin/mongosh","envInfo":{"EDITOR":null,"NODE_OPTIONS":null,"TERM":null},"installationMethod":"linux-system-wide","version":"2.5.9","distributionKind":"compiled","buildArch":"x64","buildPlatform":"linux","buildTarget":"linux-x64","buildTime":"2025-10-29T17:07:55.258Z","gitVersion":"f48698c7446594d355e043f608570da5f2c68891","nodeVersion":"v20.19.5","opensslVersion":"3.0.16","sharedOpenssl":false,"runtimeArch":"x64","runtimePlatform":"linux","runtimeGlibcVersion":"2.39","deps":{"nodeDriverVersion":"6.19.0","libmongocryptVersion":"1.15.1","libmongocryptNodeBindingsVersion":"6.5.0","kerberosVersion":"2.1.0"}}}
{"t":{"$date":"2025-12-09T11:23:33.263Z"},"s":"I","c":"DEVTOOLS-CONNECT","id":1000000049,"ctx":"mongosh-connect","msg":"Loaded system CA list","attr":{"caCount":296,"asyncFallbackError":null,"systemCertsError":null,"messages":[]}}
{"t":{"$date":"2025-12-09T11:23:33.275Z"},"s":"I","c":"DEVTOOLS-CONNECT","id":1000000042,"ctx":"mongosh-connect","msg":"Initiating connection attempt","attr":{"uri":"mongodb://127.0.0.1:27017/admin?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+2.5.9","driver":{"name":"nodejs|mongosh","version":"6.19.0|2.5.9"},"devtoolsConnectVersion":"3.9.4","host":"127.0.0.1:27017"}}
{"t":{"$date":"2025-12-09T11:23:33.284Z"},"s":"I","c":"DEVTOOLS-CONNECT","id":1000000035,"ctx":"mongosh-connect","msg":"Server heartbeat succeeded","attr":{"connectionId":"127.0.0.1:27017"}}
{"t":{"$date":"2025-12-09T11:23:33.327Z"},"s":"I","c":"DEVTOOLS-CONNECT","id":1000000037,"ctx":"mongosh-connect","msg":"Connection attempt finished"}
{"t":{"$date":"2025-12-09T11:23:33.329Z"},"s":"I","c":"MONGOSH","id":1000000010,"ctx":"shell-api","msg":"Initialized context","attr":{"method":"setCtx","arguments":{}}}
{"t":{"$date":"2025-12-09T11:23:33.335Z"},"s":"I","c":"MONGOSH-SNIPPETS","id":1000000019,"ctx":"snippets","msg":"Loaded snippets","attr":{"installdir":"/data/db/.mongodb/mongosh/snippets"}}
{"t":{"$date":"2025-12-09T11:23:33.340Z"},"s":"I","c":"MONGOSH","id":1000000003,"ctx":"repl","msg":"Start loading CLI scripts"}
{"t":{"$date":"2025-12-09T11:23:33.340Z"},"s":"I","c":"MONGOSH","id":1000000013,"ctx":"repl","msg":"Evaluating script passed on the command line"}
{"t":{"$date":"2025-12-09T11:23:33.341Z"},"s":"I","c":"MONGOSH","id":1000000007,"ctx":"repl","msg":"Evaluating input","attr":{"input":"quit(0)"}}
{"t":{"$date":"2025-12-09T11:23:33.341Z"},"s":"I","c":"MONGOSH","id":1000000004,"ctx":"connect","msg":"Connecting to server","attr":{"userId":null,"telemetryAnonymousId":"693806b42d140fda009dc29b","connectionUri":"mongodb://<ip address>:27017/admin?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+2.5.9","is_localhost":true,"is_do_url":false,"is_atlas_url":false,"is_atlas":false,"server_version":null,"node_version":"v20.19.5","server_os":null,"server_arch":null,"is_enterprise":false,"auth_type":null,"is_data_federation":false,"is_stream":false,"dl_version":null,"atlas_version":null,"is_genuine":true,"non_genuine_server_name":"mongodb","is_local_atlas":false,"fcv":null,"api_version":null,"api_strict":null,"api_deprecation_errors":null,"atlas_hostname":null}}
{"t":{"$date":"2025-12-09T11:23:33.342Z"},"s":"I","c":"MONGOSH","id":1000000045,"ctx":"analytics","msg":"Flushed outstanding data","attr":{"flushError":"Trying to persist throttle state before userId is set","flushDuration":0}}

View File

@@ -0,0 +1,16 @@
{"t":{"$date":"2025-12-09T11:23:33.522Z"},"s":"E","c":"MONGOSH","id":1000000006,"ctx":"telemetry","msg":"Error: Failed to resolve machine ID","attr":{"stack":"Error: Failed to resolve machine ID\n at i (eval at module.exports (node:lib-boxednode/mongosh:103:20), <anonymous>:341:193848)\n at async LoggingAndTelemetry.setupTelemetry (eval at module.exports (node:lib-boxednode/mongosh:103:20), <anonymous>:341:302397)","name":"Error","message":"Failed to resolve machine ID","code":null}}
{"t":{"$date":"2025-12-09T11:23:33.535Z"},"s":"I","c":"MONGOSH","id":1000000005,"ctx":"config","msg":"User updated"}
{"t":{"$date":"2025-12-09T11:23:33.540Z"},"s":"I","c":"MONGOSH","id":1000000048,"ctx":"config","msg":"Loading global configuration file","attr":{"filename":"/etc/mongosh.conf","found":false}}
{"t":{"$date":"2025-12-09T11:23:33.540Z"},"s":"I","c":"MONGOSH","id":1000000000,"ctx":"log","msg":"Starting log","attr":{"execPath":"/usr/bin/mongosh","envInfo":{"EDITOR":null,"NODE_OPTIONS":null,"TERM":null},"installationMethod":"linux-system-wide","version":"2.5.9","distributionKind":"compiled","buildArch":"x64","buildPlatform":"linux","buildTarget":"linux-x64","buildTime":"2025-10-29T17:07:55.258Z","gitVersion":"f48698c7446594d355e043f608570da5f2c68891","nodeVersion":"v20.19.5","opensslVersion":"3.0.16","sharedOpenssl":false,"runtimeArch":"x64","runtimePlatform":"linux","runtimeGlibcVersion":"2.39","deps":{"nodeDriverVersion":"6.19.0","libmongocryptVersion":"1.15.1","libmongocryptNodeBindingsVersion":"6.5.0","kerberosVersion":"2.1.0"}}}
{"t":{"$date":"2025-12-09T11:23:33.618Z"},"s":"I","c":"DEVTOOLS-CONNECT","id":1000000049,"ctx":"mongosh-connect","msg":"Loaded system CA list","attr":{"caCount":296,"asyncFallbackError":null,"systemCertsError":null,"messages":[]}}
{"t":{"$date":"2025-12-09T11:23:33.628Z"},"s":"I","c":"DEVTOOLS-CONNECT","id":1000000042,"ctx":"mongosh-connect","msg":"Initiating connection attempt","attr":{"uri":"mongodb://127.0.0.1:27017/admin?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+2.5.9","driver":{"name":"nodejs|mongosh","version":"6.19.0|2.5.9"},"devtoolsConnectVersion":"3.9.4","host":"127.0.0.1:27017"}}
{"t":{"$date":"2025-12-09T11:23:33.633Z"},"s":"I","c":"DEVTOOLS-CONNECT","id":1000000035,"ctx":"mongosh-connect","msg":"Server heartbeat succeeded","attr":{"connectionId":"127.0.0.1:27017"}}
{"t":{"$date":"2025-12-09T11:23:33.659Z"},"s":"I","c":"DEVTOOLS-CONNECT","id":1000000037,"ctx":"mongosh-connect","msg":"Connection attempt finished"}
{"t":{"$date":"2025-12-09T11:23:33.671Z"},"s":"I","c":"MONGOSH","id":1000000010,"ctx":"shell-api","msg":"Initialized context","attr":{"method":"setCtx","arguments":{}}}
{"t":{"$date":"2025-12-09T11:23:33.673Z"},"s":"I","c":"MONGOSH-SNIPPETS","id":1000000024,"ctx":"snippets","msg":"Fetching snippet index","attr":{"refreshMode":"allow-cached"}}
{"t":{"$date":"2025-12-09T11:23:33.674Z"},"s":"I","c":"MONGOSH-SNIPPETS","id":1000000019,"ctx":"snippets","msg":"Loaded snippets","attr":{"installdir":"/data/db/.mongodb/mongosh/snippets"}}
{"t":{"$date":"2025-12-09T11:23:33.674Z"},"s":"I","c":"MONGOSH-SNIPPETS","id":1000000028,"ctx":"snippets","msg":"Modifying snippets package.json failed","attr":{"error":"ENOENT: no such file or directory, open '/data/db/.mongodb/mongosh/snippets/package.json'"}}
{"t":{"$date":"2025-12-09T11:23:33.745Z"},"s":"I","c":"MONGOSH","id":1000000004,"ctx":"connect","msg":"Connecting to server","attr":{"userId":null,"telemetryAnonymousId":"693806b42d140fda009dc29b","connectionUri":"mongodb://<ip address>:27017/admin?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+2.5.9","is_localhost":true,"is_do_url":false,"is_atlas_url":false,"is_atlas":false,"server_version":"8.2.2","node_version":"v20.19.5","server_os":"linux","server_arch":"x86_64","is_enterprise":false,"auth_type":null,"is_data_federation":false,"is_stream":false,"dl_version":null,"atlas_version":null,"is_genuine":true,"non_genuine_server_name":"mongodb","is_local_atlas":false,"fcv":"8.2","api_version":null,"api_strict":null,"api_deprecation_errors":null,"atlas_hostname":null}}
{"t":{"$date":"2025-12-09T11:23:33.746Z"},"s":"I","c":"MONGOSH","id":1000000002,"ctx":"repl","msg":"Started REPL","attr":{"version":"2.5.9"}}
{"t":{"$date":"2025-12-09T11:23:33.829Z"},"s":"I","c":"MONGOSH","id":1000000011,"ctx":"shell-api","msg":"Performed API call","attr":{"method":"createUser","class":"Database","db":"admin","arguments":{}}}
{"t":{"$date":"2025-12-09T11:23:33.903Z"},"s":"I","c":"MONGOSH","id":1000000045,"ctx":"analytics","msg":"Flushed outstanding data","attr":{"flushError":"Trying to persist throttle state before userId is set","flushDuration":0}}

View File

@@ -0,0 +1 @@
{"userId":"693806b42d140fda009dc29b","telemetryAnonymousId":"693806b42d140fda009dc29b","enableTelemetry":true}

View File

@@ -0,0 +1 @@
{}

View File

@@ -0,0 +1,2 @@
WiredTiger
WiredTiger 12.0.0: (November 15, 2024)

View File

@@ -0,0 +1 @@
WiredTiger lock file

View File

@@ -0,0 +1,6 @@
WiredTiger version string
WiredTiger 12.0.0: (November 15, 2024)
WiredTiger version
major=12,minor=0,patch=0
file:WiredTiger.wt
access_pattern_hint=none,allocation_size=4KB,app_metadata=,assert=(commit_timestamp=none,durable_timestamp=none,read_timestamp=none,write_timestamp=off),block_allocation=best,block_compressor=,cache_resident=false,checksum=on,collator=,columns=,dictionary=0,encryption=(keyid=,name=),format=btree,huffman_key=,huffman_value=,id=0,ignore_in_memory_cache_size=false,internal_item_max=0,internal_key_max=0,internal_key_truncate=true,internal_page_max=4KB,key_format=S,key_gap=10,leaf_item_max=0,leaf_key_max=0,leaf_page_max=32KB,leaf_value_max=0,log=(enabled=true),memory_page_image_max=0,memory_page_max=5MB,os_cache_dirty_max=0,os_cache_max=0,prefix_compression=false,prefix_compression_min=4,readonly=false,split_deepen_min_child=0,split_deepen_per_child=0,split_pct=90,tiered_object=false,tiered_storage=(auth_token=,bucket=,bucket_prefix=,cache_directory=,local_retention=300,name=,object_target_size=0),value_format=S,verbose=[],version=(major=1,minor=1),write_timestamp_usage=none,checkpoint=(WiredTigerCheckpoint.164=(addr="018081e4dca2cc978181e4fa36b91c8281e4cf2c793b808080e3014fc0e25fc0",order=164,time=1765290467,size=36864,newest_start_durable_ts=0,oldest_start_ts=0,newest_txn=7,newest_stop_durable_ts=0,newest_stop_ts=-1,newest_stop_txn=-11,prepare=0,write_gen=465,run_write_gen=452)),checkpoint_backup_info=,checkpoint_lsn=(27,9984)

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,2 @@
WiredTiger
WiredTiger 12.0.0: (November 15, 2024)

View File

@@ -0,0 +1 @@
WiredTiger lock file

View File

@@ -0,0 +1,6 @@
WiredTiger version string
WiredTiger 12.0.0: (November 15, 2024)
WiredTiger version
major=12,minor=0,patch=0
file:WiredTiger.wt
access_pattern_hint=none,allocation_size=4KB,app_metadata=,assert=(commit_timestamp=none,durable_timestamp=none,read_timestamp=none,write_timestamp=off),block_allocation=best,block_compressor=,cache_resident=false,checksum=on,collator=,columns=,dictionary=0,encryption=(keyid=,name=),format=btree,huffman_key=,huffman_value=,id=0,ignore_in_memory_cache_size=false,internal_item_max=0,internal_key_max=0,internal_key_truncate=true,internal_page_max=4KB,key_format=S,key_gap=10,leaf_item_max=0,leaf_key_max=0,leaf_page_max=32KB,leaf_value_max=0,log=(enabled=true),memory_page_image_max=0,memory_page_max=5MB,os_cache_dirty_max=0,os_cache_max=0,prefix_compression=false,prefix_compression_min=4,readonly=false,split_deepen_min_child=0,split_deepen_per_child=0,split_pct=90,tiered_object=false,tiered_storage=(auth_token=,bucket=,bucket_prefix=,cache_directory=,local_retention=300,name=,object_target_size=0),value_format=S,verbose=[],version=(major=1,minor=1),write_timestamp_usage=none,checkpoint=(WiredTigerCheckpoint.4=(addr="018081e4688f71288181e454c359c08281e4565948be808080e26fc0cfc0",order=4,time=1765290467,size=8192,newest_start_durable_ts=0,oldest_start_ts=0,newest_txn=2,newest_stop_durable_ts=0,newest_stop_ts=-1,newest_stop_txn=-11,prepare=0,write_gen=8,run_write_gen=1)),checkpoint_backup_info=,checkpoint_lsn=(4294967295,2147483647)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

Binary file not shown.

BIN
api/mongo-data/storage.bson Normal file

Binary file not shown.

View File

@@ -0,0 +1,10 @@
package be.naaturel.boardmateapi.configurations;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springdoc.core.models.GroupedOpenApi;
@Configuration
public class SwaggerConfig {
}

View File

@@ -1,26 +1,59 @@
package be.naaturel.boardmateapi.controllers; package be.naaturel.boardmateapi.controllers;
import org.apache.coyote.Response; import be.naaturel.boardmateapi.models.Move;
import be.naaturel.boardmateapi.models.Party;
import be.naaturel.boardmateapi.services.PartyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.*;
@RestController @RestController
public class PartyController { public class PartyController {
private final PartyService service;
public PartyController(){ @Autowired
public PartyController(PartyService service){
this.service = service;
} }
public ResponseEntity<?> CreateParty(){ @GetMapping("/party/{id}")
return null; public ResponseEntity<?> RetrieveParty(@PathVariable String id){
try{
service.retrieveParty(id);
return ResponseEntity
.status(HttpStatus.INTERNAL_SERVER_ERROR)
.build();
} catch (Exception e){
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
}
} }
public ResponseEntity<?> RetrieveParty(int id){ @PostMapping("/create")
return null; public ResponseEntity<?> CreateParty(@RequestBody Party party){
try{
service.create();
return ResponseEntity.
status(HttpStatus.INTERNAL_SERVER_ERROR)
.build();
} catch (Exception e){
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
}
} }
public ResponseEntity<?> AddMove(){ @PostMapping("/moves/add")
return null; public ResponseEntity<?> AddMove(@RequestBody Move move){
try{
service.addMove();
return ResponseEntity
.status(HttpStatus.OK)
.build();
} catch (Exception e){
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
}
} }
} }

View File

@@ -1,9 +1,22 @@
package be.naaturel.boardmateapi.models; package be.naaturel.boardmateapi.models;
import java.util.ArrayList;
import java.util.List; import java.util.List;
public class Party { public class Party {
private List<Move> moves; private final String whiteName;
private final String blackName;
private final int timeControl;
private final int increment;
private final List<Move> moves;
public Party(String whiteName, String blackName, int timeControl, int increment){
this.whiteName = whiteName;
this.blackName = blackName;
this.timeControl = timeControl;
this.increment = increment;
this.moves = new ArrayList<>();
}
} }

View File

@@ -1,4 +1,4 @@
package be.naaturel.boardmateapi.repository.test; package be.naaturel.boardmateapi.repository;
import be.naaturel.boardmateapi.models.Party; import be.naaturel.boardmateapi.models.Party;

View File

@@ -1,7 +1,9 @@
package be.naaturel.boardmateapi.repository.test; package be.naaturel.boardmateapi.repository;
import be.naaturel.boardmateapi.models.Party; import be.naaturel.boardmateapi.models.Party;
import org.springframework.stereotype.Repository;
@Repository
public class CustomPartyRepoImpl implements CustomPartyRepo{ public class CustomPartyRepoImpl implements CustomPartyRepo{
@Override @Override

View File

@@ -1,10 +0,0 @@
package be.naaturel.boardmateapi.repository;
import be.naaturel.boardmateapi.models.Party;
import org.springframework.data.mongodb.repository.MongoRepository;
import java.util.Optional;
public interface PartyRepo extends MongoRepository<Party, String> {
Optional<Party> findById(String id);
}

View File

@@ -1,7 +1,8 @@
package be.naaturel.boardmateapi.services; package be.naaturel.boardmateapi.services;
import be.naaturel.boardmateapi.models.Party; import be.naaturel.boardmateapi.models.Party;
import be.naaturel.boardmateapi.repository.test.CustomPartyRepoImpl; import be.naaturel.boardmateapi.repository.CustomPartyRepoImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@Service @Service
@@ -9,6 +10,7 @@ public class PartyService {
private final CustomPartyRepoImpl repo; private final CustomPartyRepoImpl repo;
@Autowired
public PartyService(CustomPartyRepoImpl repo){ public PartyService(CustomPartyRepoImpl repo){
this.repo = repo; this.repo = repo;
} }

View File

@@ -2,7 +2,8 @@
spring.application.name=boardmate-api spring.application.name=boardmate-api
#=============SERVER============= #=============SERVER=============
server.port=8000 server.port=8080
server.address=0.0.0.0
#=============SECURITY============= #=============SECURITY=============
sec.cors.authorizedHots=* sec.cors.authorizedHots=*
@@ -11,4 +12,9 @@ sec.cors.authorizedHeader=Authorization,Content-type
#=============METRICS============= #=============METRICS=============
management.endpoints.web.exposure.include=* management.endpoints.web.exposure.include=*
management.endpoint.prometheus.enabled=true management.endpoint.health.show-details=always
management.endpoint.prometheus.enabled=true
#=============DOCUMENTATION=============
springdoc.swagger-ui.path=/api-docs
springdoc.api-docs.path=/v1/api-docs