Skip to content
Merged
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
7 changes: 6 additions & 1 deletion backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.8.5</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand Down Expand Up @@ -79,4 +84,4 @@
</plugin>
</plugins>
</build>
</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,30 @@

import com.algorithmrace.visualizer.dto.CatalogResponse;
import com.algorithmrace.visualizer.service.CatalogService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/catalog")
@Tag(name = "Catalog", description = "Endpoints for retrieving supported algorithms and metadata")
public class CatalogController {
private final CatalogService catalogService;

public CatalogController(CatalogService catalogService) {
this.catalogService = catalogService;
}

@Operation(
summary = "Get algorithm catalog",
description = "Retrieves the full catalog of available sorting, searching, and pathfinding algorithms along with their metadata."
)
@ApiResponse(responseCode = "200", description = "Successfully retrieved catalog")
@GetMapping
public CatalogResponse catalog() {
return catalogService.catalog();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import com.algorithmrace.visualizer.dto.SearchingSimulationRequest;
import com.algorithmrace.visualizer.dto.SortingSimulationRequest;
import com.algorithmrace.visualizer.service.SimulationService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
Expand All @@ -13,25 +16,41 @@

@RestController
@RequestMapping("/api/simulations")
@Tag(name = "Simulations", description = "Endpoints for running algorithm race simulations")
public class SimulationController {
private final SimulationService simulationService;

public SimulationController(SimulationService simulationService) {
this.simulationService = simulationService;
}

@Operation(
summary = "Run sorting simulation",
description = "Executes sorting algorithm simulations and returns step-by-step race performance data."
)
@ApiResponse(responseCode = "200", description = "Sorting simulation executed successfully")
@PostMapping("/sorting")
public RaceResponse sorting(@Valid @RequestBody SortingSimulationRequest request) {
return simulationService.simulateSorting(request);
}

@Operation(
summary = "Run searching simulation",
description = "Executes searching algorithm simulations and returns step-by-step race performance data."
)
@ApiResponse(responseCode = "200", description = "Searching simulation executed successfully")
@PostMapping("/searching")
public RaceResponse searching(@Valid @RequestBody SearchingSimulationRequest request) {
return simulationService.simulateSearching(request);
}

@Operation(
summary = "Run pathfinding simulation",
description = "Executes pathfinding algorithm simulations and returns step-by-step race performance data."
)
@ApiResponse(responseCode = "200", description = "Pathfinding simulation executed successfully")
@PostMapping("/pathfinding")
public RaceResponse pathfinding(@Valid @RequestBody PathfindingSimulationRequest request) {
return simulationService.simulatePathfinding(request);
}
}
}
5 changes: 4 additions & 1 deletion backend/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ app:
cors:
allowed-origins: ${CORS_ALLOWED_ORIGINS:http://localhost:5173,https://algorithm-race-visualizer.vercel.app}

springdoc:
swagger-ui:
path: /swagger-ui.html

management:
endpoints:
Expand All @@ -26,4 +29,4 @@ management:
include: health
endpoint:
health:
show-details: never
show-details: never
Loading