Skip to main content

Evaluation

Overview (C4 Component)

Black-box description of components

ComponentResponsibility (why does it exist?)Provided interface(s)Consumed interface(s)
EvaluationControllerEntry point for writing & reading provider evaluations.REST /api/v1/evaluations/** (OpenAPI)
EvaluationServiceExecutes use-cases (create, list, compute averages); validates categories; resolves author & provider; enforces pagination.Spring service APIEvaluationRepository, EvaluationCategoryRepository, ProviderRepository, UserRepository, MapStruct mappers
EvaluationRepositoryPersistence of the Evaluation aggregate; custom JPQL projection for per-category averages.Spring-Data JPAMySQL via JDBC
EvaluationCategoryRepositoryCRUD for master data of evaluation categories.Spring-Data JPAMySQL
ProviderRepositoryLook-up provider to attach an evaluation (re-use from Provider module).Spring-Data JPAMySQL
UserRepositoryFetch authenticated author entity.Spring-Data JPAMySQL
EvaluationMapper / CategoryMapper / CategoryRatingMapperMapStruct conversion between REST DTOs and JPA entities, bidirectional wiring of ratings.Java interface
Entities (Evaluation, EvaluationCategory, EvaluationCategoryRating)ORM layer; Evaluation roots the aggregate and owns its list of category ratings.JPA
JPQL projection CategoryAvgProjectionInterface-based projection returned by EvaluationRepository::findAvgPerCategory.

Important internal interfaces

NameSignature / ProtocolNotes
addEvaluationPOST /api/v1/evaluations/{providerOpsCode} – body EvalCreateRequestAuthenticated users only; stores global + per-category ratings, comment, author email taken from JWT principal.
getEvaluationsGET /api/v1/evaluations/{providerOpsCode} – paging offset/limit, sorting sortBy, sortOrderReturns EvaluationPageResponse = list + totals + averageGlobalRating + per-category averages.
getEvaluationCategoriesGET /api/v1/evaluations/categoriesPublic endpoint returning the master data (EvalCategory[]).
findAvgPerCategoryEvaluationRepository::findAvgPerCategory(String opsCode)List<CategoryAvgProjection>Pure JPQL, re-used by service to build EvaluationPageResponse.categoryAverageRatings.
@Query("""
select cat.id as categoryId,
cat.name as name,
cat.description as description,
coalesce(avg(r.rating),0) as avgRating
from EvaluationCategoryRating r
join r.evaluation e
join r.category cat
where e.provider.operationalCode = :opsCode
group by cat.id, cat.name, cat.description
""")
List<CategoryAvgProjection> findAvgPerCategory(String opsCode);

Used by the service to build the categoryAverageRatings section without loading all evaluations in memory.