[x] code is separated into layers: API (controller), domain (model + service), infra (repository)
[x] layers communicate like: Controller -> Service -> Repository and ONLY like that.
[x] Service can use other Services, Repository can use other Repositories, Service can use only one Repository!
[x] If endpoint has a PUT edit endpoint, it should ideally also have a PATCH edit endpoint, where PUT takes whole object, and PATCH just some of the object fields.
API layer
[x] input data validation, conversion, etc. should be handled in Controller
[x] Controller can call Service, controller also uses Dtos and Mappers
[x] Controller is the only place in the app that knows about users as in their credentials and authorities
[x] Use Authentication authentication as parameter and authentication.getPrincipal() to get logged in User
[x] Use @...Mapping(params = ...) to separate logic depending on parameter
Domain layer
[x] Services return Model objects, there are no Dtos in any Service
[x] Exceptions are thrown in Services
[x] Thrown exceptions are semantic!
Infrastructure layer
[x] All SQL calls are prepared to do things in the DBMS
[x] No tolerance for situations such as getting huge amounts of data from database just to filter it in backend
DDD plan
Controller
->Service
->Repository
and ONLY like that.Service
can use otherServices
,Repository
can use otherRepositories
,Service
can use only oneRepository
!PUT
edit endpoint, it should ideally also have aPATCH
edit endpoint, wherePUT
takes whole object, andPATCH
just some of the object fields.API layer
Controller
Controller
can callService
, controller also usesDtos
andMappers
Controller
is the only place in the app that knows about users as in their credentials and authoritiesAuthentication authentication
as parameter andauthentication.getPrincipal()
to get logged inUser
@...Mapping(params = ...)
to separate logic depending on parameterDomain layer
Services
returnModel
objects, there are noDtos
in anyService
Services
Infrastructure layer