Skip to content

Conversation

BalduinLandolt
Copy link
Contributor

@BalduinLandolt BalduinLandolt commented Aug 11, 2025

Description

This PR introduces a new V3 API for projects with a modern error handling approach. The implementation includes:

  • New /v3/projects/{id} endpoint to retrieve project information by ID (shortcode, shortname, or IRI)
  • New /v3/projects/{id}/resource-counts endpoint to get resource instance counts by class
  • Comprehensive error handling with structured JSON responses and appropriate HTTP status codes
  • Caching layer for improved performance using ZIO Cache
  • Full OpenAPI documentation for the new endpoints
  • Proper separation of concerns with domain, repository, and API layers

The V3 API is designed to be more developer-friendly with consistent error responses, better documentation, and optimized performance through caching.

Details on the RFC, for which this PoC serves, can be found here.

Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@BalduinLandolt BalduinLandolt changed the title feat: Add poc v3 route feat: Add v3 projects route proof of concept (DEV-5216) Aug 11, 2025
Copy link

linear bot commented Aug 11, 2025

@BalduinLandolt BalduinLandolt force-pushed the 07-30-poc_v3_project_route branch 2 times, most recently from 7cfdd63 to 3b4c995 Compare August 13, 2025 11:59
Copy link

codecov bot commented Aug 13, 2025

Codecov Report

❌ Patch coverage is 23.49515% with 394 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.26%. Comparing base (553b857) to head (ee872eb).
⚠️ Report is 165 commits behind head on main.

Files with missing lines Patch % Lines
...e/v3/projects/domain/service/ProjectsService.scala 0.80% 124 Missing ⚠️
...i/slice/v3/projects/domain/model/DomainTypes.scala 0.00% 68 Missing ⚠️
...lice/v3/projects/repo/service/ProjectsRepoDb.scala 2.43% 40 Missing ⚠️
.../v3/projects/repo/query/ProjectsQueryBuilder.scala 0.00% 36 Missing ⚠️
...api/slice/v3/projects/api/model/V3ErrorModel.scala 10.25% 35 Missing ⚠️
...bapi/slice/v3/projects/api/model/ProjectsDto.scala 31.11% 31 Missing ⚠️
...ce/v3/projects/repo/service/ProjectsRepoLive.scala 42.85% 28 Missing ⚠️
.../v3/projects/api/service/ProjectsRestService.scala 5.00% 19 Missing ⚠️
...ice/v3/projects/api/ProjectsEndpointsHandler.scala 61.11% 7 Missing ⚠️
...ra/webapi/slice/infrastructure/MetricsServer.scala 0.00% 4 Missing ⚠️
... and 1 more
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #3720       +/-   ##
===========================================
- Coverage   82.54%   63.26%   -19.29%     
===========================================
  Files         327      385       +58     
  Lines       22482    24820     +2338     
===========================================
- Hits        18558    15702     -2856     
- Misses       3924     9118     +5194     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@BalduinLandolt BalduinLandolt force-pushed the 07-30-poc_v3_project_route branch 5 times, most recently from 7be400d to 37b766f Compare August 13, 2025 17:45
@BalduinLandolt BalduinLandolt marked this pull request as ready for review August 13, 2025 17:51
@BalduinLandolt BalduinLandolt self-assigned this Aug 13, 2025

object ProjectsDto {

final case class ProjectShortcodeParam(value: String) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to duplicate this, you can use Shortcode directly, see other endpoints doing this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am aware of this, I tried to re-use as little as possible from our existing code base, in hope to make it as clear as possible how this slice works in isolation. I suppose I should have clarified this in the RFC, but forgot.
Of course if we intend to merge this, we should eliminate duplication where it does not make sense.

Though, particularly with our DTOs, it was pointed out to me by Julien, that we have some cases where the OpenAPI documentation does not align with the actually returned JSON structure, which we may want to look into before re-using them in any new route. (The topic is on the maintenance roadmap, and one instance I experimented around with in #3696)

opaque type ClassIri = String
opaque type ProjectShortcode = String
opaque type ProjectShortname = String
opaque type LanguageCode = String
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all the above types already exist. IMHO the domain model does not have to be duplicated. What is the thought behind creating a V3 domain model?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. See comment above.

import org.knora.webapi.slice.admin.domain.model.KnoraProject.Shortname
import org.knora.webapi.slice.v3.projects.domain.model.DomainTypes.*

trait ProjectsRepo {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have a Repository, IMHO duplicating the repo and service is not necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. See comment above.

@BalduinLandolt BalduinLandolt force-pushed the 07-30-poc_v3_project_route branch from 37b766f to f2344c6 Compare September 9, 2025 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants